_ZN7roaring7RoaringC2EmPKj:
  104|  14.2k|    Roaring(size_t n, const uint32_t *data) : Roaring() {
  105|  14.2k|        api::roaring_bitmap_add_many(&roaring, n, data);
  106|  14.2k|    }
_ZN7roaring7RoaringC2Ev:
   95|  21.3k|    Roaring() : roaring{} {
   96|       |        // The empty constructor roaring{} silences warnings from pedantic
   97|       |        // static analyzers.
   98|  21.3k|        api::roaring_bitmap_init_cleared(&roaring);
   99|  21.3k|    }
_ZN7roaring7RoaringD2Ev:
  950|  64.1k|    ~Roaring() {
  951|  64.1k|        if (!(roaring.high_low_container.flags & ROARING_FLAG_FROZEN)) {
  ------------------
  |  |   47|  64.1k|#define ROARING_FLAG_FROZEN UINT8_C(0x2)
  ------------------
  |  Branch (951:13): [True: 64.1k, False: 0]
  ------------------
  952|  64.1k|            api::roaring_bitmap_clear(&roaring);
  953|  64.1k|        } else {
  954|       |            // The roaring member variable copies the `roaring_bitmap_t` and
  955|       |            // nested `roaring_array_t` structures by value and is freed in the
  956|       |            // constructor, however the underlying memory arena used for the
  957|       |            // container data is not freed with it. Here we derive the arena
  958|       |            // pointer from the second arena allocation in
  959|       |            // `roaring_bitmap_frozen_view` and free it as well.
  960|      0|            roaring_bitmap_free(
  961|      0|                (roaring_bitmap_t *)((char *)
  962|      0|                                         roaring.high_low_container.containers -
  963|      0|                                     sizeof(roaring_bitmap_t)));
  964|      0|        }
  965|  64.1k|    }
_ZN7roaring7Roaring11runOptimizeEv:
  529|  14.2k|    bool runOptimize() noexcept {
  530|  14.2k|        return api::roaring_bitmap_run_optimize(&roaring);
  531|  14.2k|    }
_ZN7roaring7Roaring11shrinkToFitEv:
  538|  7.12k|    size_t shrinkToFit() noexcept {
  539|  7.12k|        return api::roaring_bitmap_shrink_to_fit(&roaring);
  540|  7.12k|    }
_ZN7roaring7Roaring3addEj:
  217|  7.12k|    void add(uint32_t x) noexcept { api::roaring_bitmap_add(&roaring, x); }
_ZN7roaring7Roaring10addCheckedEj:
  224|  7.12k|    bool addChecked(uint32_t x) noexcept {
  225|  7.12k|        return api::roaring_bitmap_add_checked(&roaring, x);
  226|  7.12k|    }
_ZN7roaring7Roaring8addRangeEmm:
  231|  7.12k|    void addRange(const uint64_t min, const uint64_t max) noexcept {
  232|  7.12k|        return api::roaring_bitmap_add_range(&roaring, min, max);
  233|  7.12k|    }
_ZN7roaring7Roaring7addManyEmPKj:
  245|  7.12k|    void addMany(size_t n_args, const uint32_t *vals) noexcept {
  246|  7.12k|        api::roaring_bitmap_add_many(&roaring, n_args, vals);
  247|  7.12k|    }
_ZN7roaring7Roaring6removeEj:
  277|  7.12k|    void remove(uint32_t x) noexcept {
  278|  7.12k|        api::roaring_bitmap_remove(&roaring, x);
  279|  7.12k|    }
_ZN7roaring7Roaring13removeCheckedEj:
  286|  7.12k|    bool removeChecked(uint32_t x) noexcept {
  287|  7.12k|        return api::roaring_bitmap_remove_checked(&roaring, x);
  288|  7.12k|    }
_ZN7roaring7Roaring11removeRangeEmm:
  293|  7.12k|    void removeRange(uint64_t min, uint64_t max) noexcept {
  294|  7.12k|        return api::roaring_bitmap_remove_range(&roaring, min, max);
  295|  7.12k|    }
_ZN7roaring7Roaring17removeRangeClosedEjj:
  300|  7.12k|    void removeRangeClosed(uint32_t min, uint32_t max) noexcept {
  301|  7.12k|        return api::roaring_bitmap_remove_range_closed(&roaring, min, max);
  302|  7.12k|    }
_ZNK7roaring7Roaring7maximumEv:
  334|  7.12k|    uint32_t maximum() const noexcept {
  335|  7.12k|        return api::roaring_bitmap_maximum(&roaring);
  336|  7.12k|    }
_ZNK7roaring7Roaring7minimumEv:
  341|  7.12k|    uint32_t minimum() const noexcept {
  342|  7.12k|        return api::roaring_bitmap_minimum(&roaring);
  343|  7.12k|    }
_ZNK7roaring7Roaring8containsEj:
  348|  7.12k|    bool contains(uint32_t x) const noexcept {
  349|  7.12k|        return api::roaring_bitmap_contains(&roaring, x);
  350|  7.12k|    }
_ZNK7roaring7Roaring13containsRangeEmm:
  355|  7.12k|    bool containsRange(const uint64_t x, const uint64_t y) const noexcept {
  356|  7.12k|        return api::roaring_bitmap_contains_range(&roaring, x, y);
  357|  7.12k|    }
_ZNK7roaring7Roaring6selectEjPj:
  563|  7.12k|    bool select(uint32_t rnk, uint32_t *element) const noexcept {
  564|  7.12k|        return api::roaring_bitmap_select(&roaring, rnk, element);
  565|  7.12k|    }
_ZNK7roaring7Roaring9intersectERKS0_:
  577|  7.12k|    bool intersect(const Roaring &r) const noexcept {
  578|  7.12k|        return api::roaring_bitmap_intersect(&roaring, &r.roaring);
  579|  7.12k|    }
_ZNK7roaring7Roaring13jaccard_indexERKS0_:
  588|  7.12k|    double jaccard_index(const Roaring &r) const noexcept {
  589|  7.12k|        return api::roaring_bitmap_jaccard_index(&roaring, &r.roaring);
  590|  7.12k|    }
_ZNK7roaring7Roaring14or_cardinalityERKS0_:
  595|  7.12k|    uint64_t or_cardinality(const Roaring &r) const noexcept {
  596|  7.12k|        return api::roaring_bitmap_or_cardinality(&roaring, &r.roaring);
  597|  7.12k|    }
_ZNK7roaring7Roaring18andnot_cardinalityERKS0_:
  602|  7.12k|    uint64_t andnot_cardinality(const Roaring &r) const noexcept {
  603|  7.12k|        return api::roaring_bitmap_andnot_cardinality(&roaring, &r.roaring);
  604|  7.12k|    }
_ZNK7roaring7Roaring15xor_cardinalityERKS0_:
  610|  7.12k|    uint64_t xor_cardinality(const Roaring &r) const noexcept {
  611|  7.12k|        return api::roaring_bitmap_xor_cardinality(&roaring, &r.roaring);
  612|  7.12k|    }
_ZNK7roaring7Roaring4rankEj:
  622|  7.12k|    uint64_t rank(uint32_t x) const noexcept {
  623|  7.12k|        return api::roaring_bitmap_rank(&roaring, x);
  624|  7.12k|    }
_ZNK7roaring7Roaring14getSizeInBytesEb:
  769|  14.2k|    size_t getSizeInBytes(bool portable = true) const noexcept {
  770|  14.2k|        if (portable) {
  ------------------
  |  Branch (770:13): [True: 14.2k, False: 0]
  ------------------
  771|  14.2k|            return api::roaring_bitmap_portable_size_in_bytes(&roaring);
  772|  14.2k|        } else {
  773|      0|            return api::roaring_bitmap_size_in_bytes(&roaring);
  774|      0|        }
  775|  14.2k|    }
_ZNK7roaring7RoaringanERKS0_:
  831|  7.12k|    Roaring operator&(const Roaring &o) const {
  832|  7.12k|        roaring_bitmap_t *r = api::roaring_bitmap_and(&roaring, &o.roaring);
  833|  7.12k|        if (r == NULL) {
  ------------------
  |  Branch (833:13): [True: 0, False: 7.12k]
  ------------------
  834|      0|            ROARING_TERMINATE("failed materialization in and");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  835|      0|        }
  836|  7.12k|        return Roaring(r);
  837|  7.12k|    }
_ZN7roaring7RoaringC2EPNS_3api16roaring_bitmap_sE:
  121|  35.6k|    explicit Roaring(roaring_bitmap_t *s) noexcept : roaring(*s) {
  122|  35.6k|        roaring_free(s);  // deallocate the passed-in pointer
  123|  35.6k|    }
_ZNK7roaring7RoaringmiERKS0_:
  844|  7.12k|    Roaring operator-(const Roaring &o) const {
  845|  7.12k|        roaring_bitmap_t *r = api::roaring_bitmap_andnot(&roaring, &o.roaring);
  846|  7.12k|        if (r == NULL) {
  ------------------
  |  Branch (846:13): [True: 0, False: 7.12k]
  ------------------
  847|      0|            ROARING_TERMINATE("failed materialization in andnot");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  848|      0|        }
  849|  7.12k|        return Roaring(r);
  850|  7.12k|    }
_ZNK7roaring7RoaringorERKS0_:
  857|  7.12k|    Roaring operator|(const Roaring &o) const {
  858|  7.12k|        roaring_bitmap_t *r = api::roaring_bitmap_or(&roaring, &o.roaring);
  859|  7.12k|        if (r == NULL) {
  ------------------
  |  Branch (859:13): [True: 0, False: 7.12k]
  ------------------
  860|      0|            ROARING_TERMINATE("failed materialization in or");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  861|      0|        }
  862|  7.12k|        return Roaring(r);
  863|  7.12k|    }
_ZNK7roaring7RoaringeoERKS0_:
  870|  7.12k|    Roaring operator^(const Roaring &o) const {
  871|  7.12k|        roaring_bitmap_t *r = api::roaring_bitmap_xor(&roaring, &o.roaring);
  872|  7.12k|        if (r == NULL) {
  ------------------
  |  Branch (872:13): [True: 0, False: 7.12k]
  ------------------
  873|      0|            ROARING_TERMINATE("failed materialization in xor");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  874|      0|        }
  875|  7.12k|        return Roaring(r);
  876|  7.12k|    }
_ZN7roaring7RoaringoRERKS0_:
  397|  7.12k|    Roaring &operator|=(const Roaring &r) noexcept {
  398|  7.12k|        api::roaring_bitmap_or_inplace(&roaring, &r.roaring);
  399|  7.12k|        return *this;
  400|  7.12k|    }
_ZN7roaring7RoaringaNERKS0_:
  375|  7.12k|    Roaring &operator&=(const Roaring &r) noexcept {
  376|  7.12k|        api::roaring_bitmap_and_inplace(&roaring, &r.roaring);
  377|  7.12k|        return *this;
  378|  7.12k|    }
_ZN7roaring7RoaringmIERKS0_:
  385|  7.12k|    Roaring &operator-=(const Roaring &r) noexcept {
  386|  7.12k|        api::roaring_bitmap_andnot_inplace(&roaring, &r.roaring);
  387|  7.12k|        return *this;
  388|  7.12k|    }
_ZN7roaring7RoaringeOERKS0_:
  407|  7.12k|    Roaring &operator^=(const Roaring &r) noexcept {
  408|  7.12k|        api::roaring_bitmap_xor_inplace(&roaring, &r.roaring);
  409|  7.12k|        return *this;
  410|  7.12k|    }
_ZNK7roaring7RoaringeqERKS0_:
  477|  14.2k|    bool operator==(const Roaring &r) const noexcept {
  478|  14.2k|        return api::roaring_bitmap_equals(&roaring, &r.roaring);
  479|  14.2k|    }
_ZNK7roaring7Roaring11cardinalityEv:
  420|  7.12k|    uint64_t cardinality() const noexcept {
  421|  7.12k|        return api::roaring_bitmap_get_cardinality(&roaring);
  422|  7.12k|    }
_ZNK7roaring7Roaring7isEmptyEv:
  427|  14.2k|    bool isEmpty() const noexcept {
  428|  14.2k|        return api::roaring_bitmap_is_empty(&roaring);
  429|  14.2k|    }
_ZNK7roaring7Roaring13toUint32ArrayEPj:
  460|  7.12k|    void toUint32Array(uint32_t *ans) const noexcept {
  461|  7.12k|        api::roaring_bitmap_to_uint32_array(&roaring, ans);
  462|  7.12k|    }
_ZNK7roaring7Roaring8isSubsetERKS0_:
  444|  7.12k|    bool isSubset(const Roaring &r) const noexcept {
  445|  7.12k|        return api::roaring_bitmap_is_subset(&roaring, &r.roaring);
  446|  7.12k|    }
_ZNK7roaring7Roaring14isStrictSubsetERKS0_:
  451|  7.12k|    bool isStrictSubset(const Roaring &r) const noexcept {
  452|  7.12k|        return api::roaring_bitmap_is_strict_subset(&roaring, &r.roaring);
  453|  7.12k|    }
_ZN7roaring7Roaring4flipEmm:
  485|  7.12k|    void flip(uint64_t range_start, uint64_t range_end) noexcept {
  486|  7.12k|        api::roaring_bitmap_flip_inplace(&roaring, range_start, range_end);
  487|  7.12k|    }
_ZN7roaring7Roaring10flipClosedEjj:
  493|  7.12k|    void flipClosed(uint32_t range_start, uint32_t range_end) noexcept {
  494|  7.12k|        api::roaring_bitmap_flip_inplace_closed(&roaring, range_start,
  495|  7.12k|                                                range_end);
  496|  7.12k|    }
_ZN7roaring7Roaring20removeRunCompressionEv:
  502|  7.12k|    bool removeRunCompression() noexcept {
  503|  7.12k|        return api::roaring_bitmap_remove_run_compression(&roaring);
  504|  7.12k|    }
_ZN7roaring7RoaringC2ERKS0_:
  129|  7.12k|    Roaring(const Roaring &r) : Roaring() {
  130|  7.12k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (130:13): [True: 0, False: 7.12k]
  ------------------
  131|      0|            ROARING_TERMINATE("failed roaring_bitmap_overwrite in constructor");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  132|      0|        }
  133|  7.12k|        api::roaring_bitmap_set_copy_on_write(
  134|  7.12k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  135|  7.12k|    }
_ZN7roaring7RoaringC2EOS0_:
  141|  7.12k|    Roaring(Roaring &&r) noexcept : roaring(r.roaring) {
  142|       |        //
  143|       |        // !!! This clones the bits of the roaring structure to a new location
  144|       |        // and then overwrites the old bits...assuming that this will still
  145|       |        // work.  There are scenarios where this could break; e.g. if some of
  146|       |        // those bits were pointers into the structure memory itself.  If such
  147|       |        // things were possible, a roaring_bitmap_move() API would be needed.
  148|       |        //
  149|  7.12k|        api::roaring_bitmap_init_cleared(&r.roaring);
  150|  7.12k|    }
_ZN7roaring7RoaringaSERKS0_:
  171|  7.12k|    Roaring &operator=(const Roaring &r) {
  172|  7.12k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (172:13): [True: 0, False: 7.12k]
  ------------------
  173|      0|            ROARING_TERMINATE("failed memory alloc in assignment");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  174|      0|        }
  175|  7.12k|        api::roaring_bitmap_set_copy_on_write(
  176|  7.12k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  177|  7.12k|        return *this;
  178|  7.12k|    }
_ZN7roaring7RoaringaSEOS0_:
  184|  7.12k|    Roaring &operator=(Roaring &&r) noexcept {
  185|  7.12k|        api::roaring_bitmap_clear(&roaring);  // free this class's allocations
  186|       |
  187|       |        // !!! See notes in the Move Constructor regarding roaring_bitmap_move()
  188|       |        //
  189|  7.12k|        roaring = r.roaring;
  190|  7.12k|        api::roaring_bitmap_init_cleared(&r.roaring);
  191|       |
  192|  7.12k|        return *this;
  193|  7.12k|    }
_ZN7roaring7Roaring8readSafeEPKcm:
  743|  14.2k|    static Roaring readSafe(const char *buf, size_t maxbytes) {
  744|  14.2k|        roaring_bitmap_t *r =
  745|  14.2k|            api::roaring_bitmap_portable_deserialize_safe(buf, maxbytes);
  746|  14.2k|        if (r == NULL) {
  ------------------
  |  Branch (746:13): [True: 7.11k, False: 7.14k]
  ------------------
  747|  7.11k|            ROARING_TERMINATE("failed alloc while reading");
  ------------------
  |  |   27|  7.11k|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  748|  7.11k|        }
  749|  7.14k|        return Roaring(r);
  750|  14.2k|    }
_ZNK7roaring7Roaring5writeEPcb:
  686|  7.12k|    size_t write(char *buf, bool portable = true) const noexcept {
  687|  7.12k|        if (portable) {
  ------------------
  |  Branch (687:13): [True: 7.12k, False: 0]
  ------------------
  688|  7.12k|            return api::roaring_bitmap_portable_serialize(&roaring, buf);
  689|  7.12k|        } else {
  690|      0|            return api::roaring_bitmap_serialize(&roaring, buf);
  691|      0|        }
  692|  7.12k|    }
_ZNK7roaring7Roaring8toStringEv:
  893|  7.12k|    std::string toString() const noexcept {
  894|  7.12k|        struct iter_data {
  895|  7.12k|            std::string str{};  // The empty constructor silences warnings from
  896|       |                                // pedantic static analyzers.
  897|  7.12k|            char first_char = '{';
  898|  7.12k|        } outer_iter_data;
  899|  7.12k|        if (!isEmpty()) {
  ------------------
  |  Branch (899:13): [True: 7.11k, False: 12]
  ------------------
  900|  7.11k|            iterate(
  901|  7.11k|                [](uint32_t value, void *inner_iter_data) -> bool {
  902|  7.11k|                    ((iter_data *)inner_iter_data)->str +=
  903|  7.11k|                        ((iter_data *)inner_iter_data)->first_char;
  904|  7.11k|                    ((iter_data *)inner_iter_data)->str +=
  905|  7.11k|                        std::to_string(value);
  906|  7.11k|                    ((iter_data *)inner_iter_data)->first_char = ',';
  907|  7.11k|                    return true;
  908|  7.11k|                },
  909|  7.11k|                (void *)&outer_iter_data);
  910|  7.11k|        } else
  911|     12|            outer_iter_data.str = '{';
  912|  7.12k|        outer_iter_data.str += '}';
  913|  7.12k|        return outer_iter_data.str;
  914|  7.12k|    }
_ZNK7roaring7Roaring7iterateEPFbjPvES1_:
  551|  7.11k|    void iterate(api::roaring_iterator iterator, void *ptr) const {
  552|  7.11k|        api::roaring_iterate(&roaring, iterator, ptr);
  553|  7.11k|    }
_ZZNK7roaring7Roaring8toStringEvENKUljPvE_clEjS1_:
  901|  3.49G|                [](uint32_t value, void *inner_iter_data) -> bool {
  902|  3.49G|                    ((iter_data *)inner_iter_data)->str +=
  903|  3.49G|                        ((iter_data *)inner_iter_data)->first_char;
  904|  3.49G|                    ((iter_data *)inner_iter_data)->str +=
  905|  3.49G|                        std::to_string(value);
  906|  3.49G|                    ((iter_data *)inner_iter_data)->first_char = ',';
  907|  3.49G|                    return true;
  908|  3.49G|                },
_ZNK7roaring7Roaring5beginEv:
 1113|  14.2k|inline RoaringSetBitBiDirectionalIterator Roaring::begin() const {
 1114|  14.2k|    return RoaringSetBitBiDirectionalIterator(*this);
 1115|  14.2k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorC2ERKNS_7RoaringEb:
 1007|   351k|                                                bool exhausted = false) {
 1008|   351k|        if (exhausted) {
  ------------------
  |  Branch (1008:13): [True: 337k, False: 14.2k]
  ------------------
 1009|   337k|            i.parent = &parent.roaring;
 1010|   337k|            i.container_index = INT32_MAX;
 1011|   337k|            i.has_value = false;
 1012|   337k|            i.current_value = UINT32_MAX;
 1013|   337k|        } else {
 1014|  14.2k|            api::roaring_iterator_init(&parent.roaring, &i);
 1015|  14.2k|        }
 1016|   351k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratorneERKS0_:
 1104|   337k|    bool operator!=(const RoaringSetBitBiDirectionalIterator &o) const {
 1105|   337k|        return i.current_value != *o || i.has_value != o.i.has_value;
  ------------------
  |  Branch (1105:16): [True: 330k, False: 7.12k]
  |  Branch (1105:41): [True: 0, False: 7.12k]
  ------------------
 1106|   337k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratordeEv:
 1021|   337k|    value_type operator*() const { return i.current_value; }
_ZNK7roaring7Roaring3endEv:
 1117|   337k|inline RoaringSetBitBiDirectionalIterator Roaring::end() const {
 1118|   337k|    return RoaringSetBitBiDirectionalIterator(*this, true);
 1119|   337k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorppEi:
 1052|   330k|    type_of_iterator operator++(int) {  // i++, must return orig. value
 1053|   330k|        RoaringSetBitBiDirectionalIterator orig(*this);
 1054|   330k|        api::roaring_uint32_iterator_advance(&i);
 1055|   330k|        return orig;
 1056|   330k|    }
_ZN7roaring34RoaringSetBitBiDirectionalIterator13equalorlargerEj:
 1067|  7.12k|    CROARING_DEPRECATED void equalorlarger(uint32_t val) {
 1068|  7.12k|        api::roaring_uint32_iterator_move_equalorlarger(&i, val);
 1069|  7.12k|    }

binarySearch:
   53|  8.28M|                            uint16_t ikey) {
   54|  8.28M|    const int32_t gap = 16;
   55|  8.28M|    if (lenarray < gap) {
  ------------------
  |  Branch (55:9): [True: 3.77M, False: 4.50M]
  ------------------
   56|  5.55M|        for (int32_t j = 0; j < lenarray; j++) {
  ------------------
  |  Branch (56:29): [True: 5.54M, False: 6.96k]
  ------------------
   57|  5.54M|            if (array[j] >= ikey) {
  ------------------
  |  Branch (57:17): [True: 3.77M, False: 1.77M]
  ------------------
   58|  3.77M|                return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (58:24): [True: 3.60M, False: 164k]
  ------------------
   59|  3.77M|            }
   60|  5.54M|        }
   61|  6.96k|        return -(lenarray + 1);
   62|  3.77M|    }
   63|  4.50M|    const int32_t num_blocks = lenarray / gap;
   64|  4.50M|    int32_t base = 0;
   65|  4.50M|    int32_t n = num_blocks;
   66|  8.72M|    while (n > 3) {
  ------------------
  |  Branch (66:12): [True: 4.22M, False: 4.50M]
  ------------------
   67|  4.22M|        int32_t quarter = n >> 2;
   68|       |
   69|  4.22M|        int32_t k1 = array[(base + quarter + 1) * gap - 1];
   70|  4.22M|        int32_t k2 = array[(base + 2 * quarter + 1) * gap - 1];
   71|  4.22M|        int32_t k3 = array[(base + 3 * quarter + 1) * gap - 1];
   72|       |
   73|  4.22M|        int32_t c1 = (k1 < ikey);
   74|  4.22M|        int32_t c2 = (k2 < ikey);
   75|  4.22M|        int32_t c3 = (k3 < ikey);
   76|       |
   77|  4.22M|        base += (c1 + c2 + c3) * quarter;
   78|  4.22M|        n -= 3 * quarter;
   79|  4.22M|    }
   80|  8.24M|    while (n > 1) {
  ------------------
  |  Branch (80:12): [True: 3.73M, False: 4.50M]
  ------------------
   81|  3.73M|        int32_t half = n >> 1;
   82|  3.73M|        base = (array[(base + half + 1) * gap - 1] < ikey) ? base + half : base;
  ------------------
  |  Branch (82:16): [True: 505k, False: 3.23M]
  ------------------
   83|  3.73M|        n -= half;
   84|  3.73M|    }
   85|  4.50M|    int32_t lo = (array[(base + 1) * gap - 1] < ikey) ? base + 1 : base;
  ------------------
  |  Branch (85:18): [True: 1.94M, False: 2.56M]
  ------------------
   86|       |
   87|  4.50M|    if (lo < num_blocks) {
  ------------------
  |  Branch (87:9): [True: 4.17M, False: 329k]
  ------------------
   88|  4.17M|        const int32_t start = lo * gap;
   89|  4.17M|#if defined(CROARING_IS_X64)
   90|       |        // SSE2: subs_epu16 yields zero where lane >= ikey. movemask of an
   91|       |        // epi16 compare gives 2 bits per lane; ctz>>1 = lane index. Scan
   92|       |        // the first 8 lanes first and exit early when they contain the
   93|       |        // answer; otherwise the block-narrowing invariant guarantees the
   94|       |        // second-half mask is non-zero.
   95|  4.17M|        __m128i needle = _mm_set1_epi16((short)ikey);
   96|  4.17M|        __m128i zero = _mm_setzero_si128();
   97|  4.17M|        __m128i v0 = _mm_loadu_si128((const __m128i *)(array + start));
   98|  4.17M|        __m128i ge0 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v0), zero);
   99|  4.17M|        unsigned m0 = (unsigned)_mm_movemask_epi8(ge0);
  100|  4.17M|        if (m0 != 0) {
  ------------------
  |  Branch (100:13): [True: 3.06M, False: 1.10M]
  ------------------
  101|  3.06M|            int32_t j = start + (int32_t)(roaring_trailing_zeroes(m0) >> 1);
  102|  3.06M|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (102:20): [True: 2.36M, False: 706k]
  ------------------
  103|  3.06M|        }
  104|  1.10M|        __m128i v1 = _mm_loadu_si128((const __m128i *)(array + start + 8));
  105|  1.10M|        __m128i ge1 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v1), zero);
  106|  1.10M|        unsigned m1 = (unsigned)_mm_movemask_epi8(ge1);
  107|  1.10M|        int32_t j = start + 8 + (int32_t)(roaring_trailing_zeroes(m1) >> 1);
  108|  1.10M|        return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (108:16): [True: 474k, False: 633k]
  ------------------
  109|       |#else
  110|       |        const int32_t end = start + gap;
  111|       |        for (int32_t j = start; j < end; j++) {
  112|       |            if (array[j] >= ikey) {
  113|       |                return (array[j] == ikey) ? j : -(j + 1);
  114|       |            }
  115|       |        }
  116|       |        // Unreachable: the narrowing guarantees the last element of the
  117|       |        // selected block is >= ikey.
  118|       |        return -(end + 1);
  119|       |#endif
  120|  4.17M|    }
  121|       |
  122|  1.85M|    for (int32_t j = num_blocks * gap; j < lenarray; j++) {
  ------------------
  |  Branch (122:40): [True: 1.84M, False: 10.4k]
  ------------------
  123|  1.84M|        if (array[j] >= ikey) {
  ------------------
  |  Branch (123:13): [True: 318k, False: 1.52M]
  ------------------
  124|   318k|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (124:20): [True: 183k, False: 135k]
  ------------------
  125|   318k|        }
  126|  1.84M|    }
  127|  10.4k|    return -(lenarray + 1);
  128|   329k|}
roaring.c:advanceUntil:
  138|    518|                                   int32_t length, uint16_t min) {
  139|    518|    int32_t lower = pos + 1;
  140|       |
  141|    518|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (141:9): [True: 518, False: 0]
  |  Branch (141:30): [True: 0, False: 0]
  ------------------
  142|    518|        return lower;
  143|    518|    }
  144|       |
  145|      0|    int32_t spansize = 1;
  146|       |
  147|      0|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (147:12): [True: 0, False: 0]
  |  Branch (147:43): [True: 0, False: 0]
  ------------------
  148|      0|        spansize <<= 1;
  149|      0|    }
  150|      0|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (150:21): [True: 0, False: 0]
  ------------------
  151|       |
  152|      0|    if (array[upper] == min) {
  ------------------
  |  Branch (152:9): [True: 0, False: 0]
  ------------------
  153|      0|        return upper;
  154|      0|    }
  155|      0|    if (array[upper] < min) {
  ------------------
  |  Branch (155:9): [True: 0, False: 0]
  ------------------
  156|       |        // means
  157|       |        // array
  158|       |        // has no
  159|       |        // item
  160|       |        // >= min
  161|       |        // pos = array.length;
  162|      0|        return length;
  163|      0|    }
  164|       |
  165|       |    // we know that the next-smallest span was too small
  166|      0|    lower += (spansize >> 1);
  167|       |
  168|      0|    int32_t mid = 0;
  169|      0|    while (lower + 1 != upper) {
  ------------------
  |  Branch (169:12): [True: 0, False: 0]
  ------------------
  170|      0|        mid = (lower + upper) >> 1;
  171|      0|        if (array[mid] == min) {
  ------------------
  |  Branch (171:13): [True: 0, False: 0]
  ------------------
  172|      0|            return mid;
  173|      0|        } else if (array[mid] < min) {
  ------------------
  |  Branch (173:20): [True: 0, False: 0]
  ------------------
  174|      0|            lower = mid;
  175|      0|        } else {
  176|      0|            upper = mid;
  177|      0|        }
  178|      0|    }
  179|      0|    return upper;
  180|      0|}
roaring.c:count_greater:
  198|  9.90k|                                    uint16_t ikey) {
  199|  9.90k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (199:9): [True: 0, False: 9.90k]
  ------------------
  200|  9.90k|    int32_t pos = binarySearch(array, lenarray, ikey);
  201|  9.90k|    if (pos >= 0) {
  ------------------
  |  Branch (201:9): [True: 1.95k, False: 7.95k]
  ------------------
  202|  1.95k|        return lenarray - (pos + 1);
  203|  7.95k|    } else {
  204|  7.95k|        return lenarray - (-pos - 1);
  205|  7.95k|    }
  206|  9.90k|}
roaring.c:count_less:
  187|  17.1k|                                 uint16_t ikey) {
  188|  17.1k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (188:9): [True: 3.92k, False: 13.2k]
  ------------------
  189|  13.2k|    int32_t pos = binarySearch(array, lenarray, ikey);
  190|  13.2k|    return pos >= 0 ? pos : -(pos + 1);
  ------------------
  |  Branch (190:12): [True: 10.3k, False: 2.93k]
  ------------------
  191|  17.1k|}
array_util.c:advanceUntil:
  138|  17.2k|                                   int32_t length, uint16_t min) {
  139|  17.2k|    int32_t lower = pos + 1;
  140|       |
  141|  17.2k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (141:9): [True: 21, False: 17.2k]
  |  Branch (141:30): [True: 5.36k, False: 11.8k]
  ------------------
  142|  5.38k|        return lower;
  143|  5.38k|    }
  144|       |
  145|  11.8k|    int32_t spansize = 1;
  146|       |
  147|  53.4k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (147:12): [True: 52.1k, False: 1.28k]
  |  Branch (147:43): [True: 41.6k, False: 10.5k]
  ------------------
  148|  41.6k|        spansize <<= 1;
  149|  41.6k|    }
  150|  11.8k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (150:21): [True: 10.5k, False: 1.28k]
  ------------------
  151|       |
  152|  11.8k|    if (array[upper] == min) {
  ------------------
  |  Branch (152:9): [True: 2.84k, False: 8.99k]
  ------------------
  153|  2.84k|        return upper;
  154|  2.84k|    }
  155|  8.99k|    if (array[upper] < min) {
  ------------------
  |  Branch (155:9): [True: 233, False: 8.76k]
  ------------------
  156|       |        // means
  157|       |        // array
  158|       |        // has no
  159|       |        // item
  160|       |        // >= min
  161|       |        // pos = array.length;
  162|    233|        return length;
  163|    233|    }
  164|       |
  165|       |    // we know that the next-smallest span was too small
  166|  8.76k|    lower += (spansize >> 1);
  167|       |
  168|  8.76k|    int32_t mid = 0;
  169|  28.0k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (169:12): [True: 24.6k, False: 3.42k]
  ------------------
  170|  24.6k|        mid = (lower + upper) >> 1;
  171|  24.6k|        if (array[mid] == min) {
  ------------------
  |  Branch (171:13): [True: 5.33k, False: 19.3k]
  ------------------
  172|  5.33k|            return mid;
  173|  19.3k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (173:20): [True: 9.47k, False: 9.83k]
  ------------------
  174|  9.47k|            lower = mid;
  175|  9.83k|        } else {
  176|  9.83k|            upper = mid;
  177|  9.83k|        }
  178|  24.6k|    }
  179|  3.42k|    return upper;
  180|  8.76k|}
array_util.c:croaring_skewed_sizes:
  282|  71.8k|static inline bool croaring_skewed_sizes(size_t size_small, size_t size_large) {
  283|  71.8k|    return size_small * CROARING_SKEWED_MERGE_RATIO < size_large;
  ------------------
  |  |  273|  71.8k|#define CROARING_SKEWED_MERGE_RATIO 8
  ------------------
  284|  71.8k|}
mixed_intersection.c:advanceUntil:
  138|   116k|                                   int32_t length, uint16_t min) {
  139|   116k|    int32_t lower = pos + 1;
  140|       |
  141|   116k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (141:9): [True: 449, False: 116k]
  |  Branch (141:30): [True: 65.3k, False: 51.0k]
  ------------------
  142|  65.8k|        return lower;
  143|  65.8k|    }
  144|       |
  145|  51.0k|    int32_t spansize = 1;
  146|       |
  147|   127k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (147:12): [True: 126k, False: 1.18k]
  |  Branch (147:43): [True: 76.8k, False: 49.8k]
  ------------------
  148|  76.8k|        spansize <<= 1;
  149|  76.8k|    }
  150|  51.0k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (150:21): [True: 49.8k, False: 1.18k]
  ------------------
  151|       |
  152|  51.0k|    if (array[upper] == min) {
  ------------------
  |  Branch (152:9): [True: 22.9k, False: 28.0k]
  ------------------
  153|  22.9k|        return upper;
  154|  22.9k|    }
  155|  28.0k|    if (array[upper] < min) {
  ------------------
  |  Branch (155:9): [True: 494, False: 27.6k]
  ------------------
  156|       |        // means
  157|       |        // array
  158|       |        // has no
  159|       |        // item
  160|       |        // >= min
  161|       |        // pos = array.length;
  162|    494|        return length;
  163|    494|    }
  164|       |
  165|       |    // we know that the next-smallest span was too small
  166|  27.6k|    lower += (spansize >> 1);
  167|       |
  168|  27.6k|    int32_t mid = 0;
  169|  50.7k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (169:12): [True: 35.0k, False: 15.6k]
  ------------------
  170|  35.0k|        mid = (lower + upper) >> 1;
  171|  35.0k|        if (array[mid] == min) {
  ------------------
  |  Branch (171:13): [True: 11.9k, False: 23.1k]
  ------------------
  172|  11.9k|            return mid;
  173|  23.1k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (173:20): [True: 8.86k, False: 14.2k]
  ------------------
  174|  8.86k|            lower = mid;
  175|  14.2k|        } else {
  176|  14.2k|            upper = mid;
  177|  14.2k|        }
  178|  35.0k|    }
  179|  15.6k|    return upper;
  180|  27.6k|}
mixed_subset.c:advanceUntil:
  138|    398|                                   int32_t length, uint16_t min) {
  139|    398|    int32_t lower = pos + 1;
  140|       |
  141|    398|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (141:9): [True: 0, False: 398]
  |  Branch (141:30): [True: 182, False: 216]
  ------------------
  142|    182|        return lower;
  143|    182|    }
  144|       |
  145|    216|    int32_t spansize = 1;
  146|       |
  147|  1.07k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (147:12): [True: 972, False: 104]
  |  Branch (147:43): [True: 860, False: 112]
  ------------------
  148|    860|        spansize <<= 1;
  149|    860|    }
  150|    216|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (150:21): [True: 112, False: 104]
  ------------------
  151|       |
  152|    216|    if (array[upper] == min) {
  ------------------
  |  Branch (152:9): [True: 0, False: 216]
  ------------------
  153|      0|        return upper;
  154|      0|    }
  155|    216|    if (array[upper] < min) {
  ------------------
  |  Branch (155:9): [True: 6, False: 210]
  ------------------
  156|       |        // means
  157|       |        // array
  158|       |        // has no
  159|       |        // item
  160|       |        // >= min
  161|       |        // pos = array.length;
  162|      6|        return length;
  163|      6|    }
  164|       |
  165|       |    // we know that the next-smallest span was too small
  166|    210|    lower += (spansize >> 1);
  167|       |
  168|    210|    int32_t mid = 0;
  169|    738|    while (lower + 1 != upper) {
  ------------------
  |  Branch (169:12): [True: 528, False: 210]
  ------------------
  170|    528|        mid = (lower + upper) >> 1;
  171|    528|        if (array[mid] == min) {
  ------------------
  |  Branch (171:13): [True: 0, False: 528]
  ------------------
  172|      0|            return mid;
  173|    528|        } else if (array[mid] < min) {
  ------------------
  |  Branch (173:20): [True: 246, False: 282]
  ------------------
  174|    246|            lower = mid;
  175|    282|        } else {
  176|    282|            upper = mid;
  177|    282|        }
  178|    528|    }
  179|    210|    return upper;
  180|    210|}
mixed_andnot.c:advanceUntil:
  138|  86.4k|                                   int32_t length, uint16_t min) {
  139|  86.4k|    int32_t lower = pos + 1;
  140|       |
  141|  86.4k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (141:9): [True: 3.98k, False: 82.4k]
  |  Branch (141:30): [True: 70.8k, False: 11.6k]
  ------------------
  142|  74.7k|        return lower;
  143|  74.7k|    }
  144|       |
  145|  11.6k|    int32_t spansize = 1;
  146|       |
  147|  25.3k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (147:12): [True: 24.9k, False: 469]
  |  Branch (147:43): [True: 13.7k, False: 11.1k]
  ------------------
  148|  13.7k|        spansize <<= 1;
  149|  13.7k|    }
  150|  11.6k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (150:21): [True: 11.1k, False: 469]
  ------------------
  151|       |
  152|  11.6k|    if (array[upper] == min) {
  ------------------
  |  Branch (152:9): [True: 5.26k, False: 6.39k]
  ------------------
  153|  5.26k|        return upper;
  154|  5.26k|    }
  155|  6.39k|    if (array[upper] < min) {
  ------------------
  |  Branch (155:9): [True: 423, False: 5.96k]
  ------------------
  156|       |        // means
  157|       |        // array
  158|       |        // has no
  159|       |        // item
  160|       |        // >= min
  161|       |        // pos = array.length;
  162|    423|        return length;
  163|    423|    }
  164|       |
  165|       |    // we know that the next-smallest span was too small
  166|  5.96k|    lower += (spansize >> 1);
  167|       |
  168|  5.96k|    int32_t mid = 0;
  169|  9.82k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (169:12): [True: 6.15k, False: 3.66k]
  ------------------
  170|  6.15k|        mid = (lower + upper) >> 1;
  171|  6.15k|        if (array[mid] == min) {
  ------------------
  |  Branch (171:13): [True: 2.29k, False: 3.85k]
  ------------------
  172|  2.29k|            return mid;
  173|  3.85k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (173:20): [True: 1.42k, False: 2.43k]
  ------------------
  174|  1.42k|            lower = mid;
  175|  2.43k|        } else {
  176|  2.43k|            upper = mid;
  177|  2.43k|        }
  178|  6.15k|    }
  179|  3.66k|    return upper;
  180|  5.96k|}

roaring.c:bitset_lenrange_cardinality:
   63|  1.29k|                                              uint32_t lenminusone) {
   64|  1.29k|    uint32_t firstword = start / 64;
   65|  1.29k|    uint32_t endword = (start + lenminusone) / 64;
   66|  1.29k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 914, False: 380]
  ------------------
   67|    914|        return roaring_hamming(words[firstword] &
   68|    914|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|    914|                                   << (start % 64));
   70|    914|    }
   71|    380|    int answer =
   72|    380|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|   196k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 195k, False: 380]
  ------------------
   74|   195k|        answer += roaring_hamming(words[i]);
   75|   195k|    }
   76|    380|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|    380|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|    380|    return answer;
   80|  1.29k|}
roaring.c:bitset_reset_range:
  147|  1.25k|                                      uint32_t end) {
  148|  1.25k|    if (start == end) return;
  ------------------
  |  Branch (148:9): [True: 0, False: 1.25k]
  ------------------
  149|  1.25k|    uint32_t firstword = start / 64;
  150|  1.25k|    uint32_t endword = (end - 1) / 64;
  151|  1.25k|    if (firstword == endword) {
  ------------------
  |  Branch (151:9): [True: 914, False: 336]
  ------------------
  152|    914|        words[firstword] &= ~(((~UINT64_C(0)) << (start % 64)) &
  153|    914|                              ((~UINT64_C(0)) >> ((~end + 1) % 64)));
  154|    914|        return;
  155|    914|    }
  156|    336|    words[firstword] &= ~((~UINT64_C(0)) << (start % 64));
  157|   156k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (157:38): [True: 156k, False: 336]
  ------------------
  158|   156k|        words[i] = UINT64_C(0);
  159|   156k|    }
  160|       |    words[endword] &= ~((~UINT64_C(0)) >> ((~end + 1) % 64));
  161|    336|}
roaring.c:bitset_set_lenrange:
  112|  1.50k|                                       uint32_t lenminusone) {
  113|  1.50k|    uint32_t firstword = start / 64;
  114|  1.50k|    uint32_t endword = (start + lenminusone) / 64;
  115|  1.50k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 0, False: 1.50k]
  ------------------
  116|      0|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|      0|                            << (start % 64);
  118|      0|        return;
  119|      0|    }
  120|  1.50k|    uint64_t temp = words[endword];
  121|  1.50k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|   467k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 465k, False: 1.50k]
  ------------------
  123|   465k|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  1.50k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  1.50k|}
bitset.c:avx2_harley_seal_popcount256:
  377|  3.11k|                                                    const uint64_t size) {
  378|  3.11k|    __m256i total = _mm256_setzero_si256();
  379|  3.11k|    __m256i ones = _mm256_setzero_si256();
  380|  3.11k|    __m256i twos = _mm256_setzero_si256();
  381|  3.11k|    __m256i fours = _mm256_setzero_si256();
  382|  3.11k|    __m256i eights = _mm256_setzero_si256();
  383|  3.11k|    __m256i sixteens = _mm256_setzero_si256();
  384|  3.11k|    __m256i twosA, twosB, foursA, foursB, eightsA, eightsB;
  385|       |
  386|  3.11k|    const uint64_t limit = size - size % 16;
  387|  3.11k|    uint64_t i = 0;
  388|       |
  389|  52.9k|    for (; i < limit; i += 16) {
  ------------------
  |  Branch (389:12): [True: 49.8k, False: 3.11k]
  ------------------
  390|  49.8k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i),
  391|  49.8k|            _mm256_loadu_si256(data + i + 1));
  392|  49.8k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 2),
  393|  49.8k|            _mm256_loadu_si256(data + i + 3));
  394|  49.8k|        CSA(&foursA, &twos, twos, twosA, twosB);
  395|  49.8k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i + 4),
  396|  49.8k|            _mm256_loadu_si256(data + i + 5));
  397|  49.8k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 6),
  398|  49.8k|            _mm256_loadu_si256(data + i + 7));
  399|  49.8k|        CSA(&foursB, &twos, twos, twosA, twosB);
  400|  49.8k|        CSA(&eightsA, &fours, fours, foursA, foursB);
  401|  49.8k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i + 8),
  402|  49.8k|            _mm256_loadu_si256(data + i + 9));
  403|  49.8k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 10),
  404|  49.8k|            _mm256_loadu_si256(data + i + 11));
  405|  49.8k|        CSA(&foursA, &twos, twos, twosA, twosB);
  406|  49.8k|        CSA(&twosA, &ones, ones, _mm256_loadu_si256(data + i + 12),
  407|  49.8k|            _mm256_loadu_si256(data + i + 13));
  408|  49.8k|        CSA(&twosB, &ones, ones, _mm256_loadu_si256(data + i + 14),
  409|  49.8k|            _mm256_loadu_si256(data + i + 15));
  410|  49.8k|        CSA(&foursB, &twos, twos, twosA, twosB);
  411|  49.8k|        CSA(&eightsB, &fours, fours, foursA, foursB);
  412|  49.8k|        CSA(&sixteens, &eights, eights, eightsA, eightsB);
  413|       |
  414|  49.8k|        total = _mm256_add_epi64(total, popcount256(sixteens));
  415|  49.8k|    }
  416|       |
  417|  3.11k|    total = _mm256_slli_epi64(total, 4);  // * 16
  418|  3.11k|    total = _mm256_add_epi64(
  419|  3.11k|        total, _mm256_slli_epi64(popcount256(eights), 3));  // += 8 * ...
  420|  3.11k|    total = _mm256_add_epi64(
  421|  3.11k|        total, _mm256_slli_epi64(popcount256(fours), 2));  // += 4 * ...
  422|  3.11k|    total = _mm256_add_epi64(
  423|  3.11k|        total, _mm256_slli_epi64(popcount256(twos), 1));  // += 2 * ...
  424|  3.11k|    total = _mm256_add_epi64(total, popcount256(ones));
  425|  3.11k|    for (; i < size; i++)
  ------------------
  |  Branch (425:12): [True: 0, False: 3.11k]
  ------------------
  426|      0|        total =
  427|      0|            _mm256_add_epi64(total, popcount256(_mm256_loadu_si256(data + i)));
  428|       |
  429|  3.11k|    return (uint64_t)(_mm256_extract_epi64(total, 0)) +
  430|  3.11k|           (uint64_t)(_mm256_extract_epi64(total, 1)) +
  431|  3.11k|           (uint64_t)(_mm256_extract_epi64(total, 2)) +
  432|       |           (uint64_t)(_mm256_extract_epi64(total, 3));
  433|  3.11k|}
bitset.c:CSA:
  365|  1.43M|                       __m256i c) {
  366|  1.43M|    const __m256i u = _mm256_xor_si256(a, b);
  367|  1.43M|    *h = _mm256_or_si256(_mm256_and_si256(a, b), _mm256_and_si256(u, c));
  368|  1.43M|    *l = _mm256_xor_si256(u, c);
  369|  1.43M|}
bitset.c:popcount256:
  329|   119k|static inline __m256i popcount256(__m256i v) {
  330|   119k|    const __m256i lookuppos = _mm256_setr_epi8(
  331|   119k|        /* 0 */ 4 + 0, /* 1 */ 4 + 1, /* 2 */ 4 + 1, /* 3 */ 4 + 2,
  332|   119k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  333|   119k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  334|   119k|        /* c */ 4 + 2, /* d */ 4 + 3, /* e */ 4 + 3, /* f */ 4 + 4,
  335|       |
  336|       |        /* 0 */ 4 + 0, /* 1 */ 4 + 1, /* 2 */ 4 + 1, /* 3 */ 4 + 2,
  337|   119k|        /* 4 */ 4 + 1, /* 5 */ 4 + 2, /* 6 */ 4 + 2, /* 7 */ 4 + 3,
  338|   119k|        /* 8 */ 4 + 1, /* 9 */ 4 + 2, /* a */ 4 + 2, /* b */ 4 + 3,
  339|   119k|        /* c */ 4 + 2, /* d */ 4 + 3, /* e */ 4 + 3, /* f */ 4 + 4);
  340|   119k|    const __m256i lookupneg = _mm256_setr_epi8(
  341|   119k|        /* 0 */ 4 - 0, /* 1 */ 4 - 1, /* 2 */ 4 - 1, /* 3 */ 4 - 2,
  342|   119k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  343|   119k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  344|   119k|        /* c */ 4 - 2, /* d */ 4 - 3, /* e */ 4 - 3, /* f */ 4 - 4,
  345|       |
  346|       |        /* 0 */ 4 - 0, /* 1 */ 4 - 1, /* 2 */ 4 - 1, /* 3 */ 4 - 2,
  347|   119k|        /* 4 */ 4 - 1, /* 5 */ 4 - 2, /* 6 */ 4 - 2, /* 7 */ 4 - 3,
  348|   119k|        /* 8 */ 4 - 1, /* 9 */ 4 - 2, /* a */ 4 - 2, /* b */ 4 - 3,
  349|   119k|        /* c */ 4 - 2, /* d */ 4 - 3, /* e */ 4 - 3, /* f */ 4 - 4);
  350|   119k|    const __m256i low_mask = _mm256_set1_epi8(0x0f);
  351|       |
  352|   119k|    const __m256i lo = _mm256_and_si256(v, low_mask);
  353|   119k|    const __m256i hi = _mm256_and_si256(_mm256_srli_epi16(v, 4), low_mask);
  354|   119k|    const __m256i popcnt1 = _mm256_shuffle_epi8(lookuppos, lo);
  355|   119k|    const __m256i popcnt2 = _mm256_shuffle_epi8(lookupneg, hi);
  356|   119k|    return _mm256_sad_epu8(popcnt1, popcnt2);
  357|   119k|}
convert.c:bitset_set_lenrange:
  112|   112k|                                       uint32_t lenminusone) {
  113|   112k|    uint32_t firstword = start / 64;
  114|   112k|    uint32_t endword = (start + lenminusone) / 64;
  115|   112k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 44.6k, False: 67.9k]
  ------------------
  116|  44.6k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|  44.6k|                            << (start % 64);
  118|  44.6k|        return;
  119|  44.6k|    }
  120|  67.9k|    uint64_t temp = words[endword];
  121|  67.9k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  33.2M|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 33.1M, False: 67.9k]
  ------------------
  123|  33.1M|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  67.9k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  67.9k|}
mixed_intersection.c:bitset_lenrange_cardinality:
   63|   187k|                                              uint32_t lenminusone) {
   64|   187k|    uint32_t firstword = start / 64;
   65|   187k|    uint32_t endword = (start + lenminusone) / 64;
   66|   187k|    if (firstword == endword) {
  ------------------
  |  Branch (66:9): [True: 183k, False: 4.80k]
  ------------------
   67|   183k|        return roaring_hamming(words[firstword] &
   68|   183k|                               ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   69|   183k|                                   << (start % 64));
   70|   183k|    }
   71|  4.80k|    int answer =
   72|  4.80k|        roaring_hamming(words[firstword] & ((~UINT64_C(0)) << (start % 64)));
   73|  5.09k|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (73:38): [True: 292, False: 4.80k]
  ------------------
   74|    292|        answer += roaring_hamming(words[i]);
   75|    292|    }
   76|  4.80k|    answer += roaring_hamming(words[endword] &
   77|       |                              (~UINT64_C(0)) >>
   78|  4.80k|                                  (((~start + 1) - lenminusone - 1) % 64));
   79|  4.80k|    return answer;
   80|   187k|}
mixed_intersection.c:bitset_lenrange_empty:
   86|  3.85k|                                         uint32_t lenminusone) {
   87|  3.85k|    uint32_t firstword = start / 64;
   88|  3.85k|    uint32_t endword = (start + lenminusone) / 64;
   89|  3.85k|    if (firstword == endword) {
  ------------------
  |  Branch (89:9): [True: 3.56k, False: 291]
  ------------------
   90|  3.56k|        return (words[firstword] & ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
   91|  3.56k|                                       << (start % 64)) == 0;
   92|  3.56k|    }
   93|    291|    if (((words[firstword] & ((~UINT64_C(0)) << (start % 64)))) != 0) {
  ------------------
  |  Branch (93:9): [True: 76, False: 215]
  ------------------
   94|     76|        return false;
   95|     76|    }
   96|    232|    for (uint32_t i = firstword + 1; i < endword; i++) {
  ------------------
  |  Branch (96:38): [True: 25, False: 207]
  ------------------
   97|     25|        if (words[i] != 0) {
  ------------------
  |  Branch (97:13): [True: 8, False: 17]
  ------------------
   98|      8|            return false;
   99|      8|        }
  100|     25|    }
  101|    207|    if ((words[endword] &
  ------------------
  |  Branch (101:9): [True: 136, False: 71]
  ------------------
  102|    207|         (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64)) != 0) {
  103|    136|        return false;
  104|    136|    }
  105|     71|    return true;
  106|    207|}
mixed_union.c:bitset_set_lenrange:
  112|  93.9k|                                       uint32_t lenminusone) {
  113|  93.9k|    uint32_t firstword = start / 64;
  114|  93.9k|    uint32_t endword = (start + lenminusone) / 64;
  115|  93.9k|    if (firstword == endword) {
  ------------------
  |  Branch (115:9): [True: 91.5k, False: 2.40k]
  ------------------
  116|  91.5k|        words[firstword] |= ((~UINT64_C(0)) >> ((63 - lenminusone) % 64))
  117|  91.5k|                            << (start % 64);
  118|  91.5k|        return;
  119|  91.5k|    }
  120|  2.40k|    uint64_t temp = words[endword];
  121|  2.40k|    words[firstword] |= (~UINT64_C(0)) << (start % 64);
  122|  2.50k|    for (uint32_t i = firstword + 1; i < endword; i += 2)
  ------------------
  |  Branch (122:38): [True: 104, False: 2.40k]
  ------------------
  123|    104|        words[i] = words[i + 1] = ~UINT64_C(0);
  124|  2.40k|    words[endword] =
  125|       |        temp | (~UINT64_C(0)) >> (((~start + 1) - lenminusone - 1) % 64);
  126|  2.40k|}
mixed_negation.c:bitset_flip_range:
  132|  1.30k|                                     uint32_t end) {
  133|  1.30k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 1.30k]
  ------------------
  134|  1.30k|    uint32_t firstword = start / 64;
  135|  1.30k|    uint32_t endword = (end - 1) / 64;
  136|  1.30k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|  83.5k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 82.2k, False: 1.30k]
  ------------------
  138|  82.2k|        words[i] = ~words[i];
  139|  82.2k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  1.30k|}
mixed_xor.c:bitset_flip_range:
  132|  49.6k|                                     uint32_t end) {
  133|  49.6k|    if (start == end) return;
  ------------------
  |  Branch (133:9): [True: 0, False: 49.6k]
  ------------------
  134|  49.6k|    uint32_t firstword = start / 64;
  135|  49.6k|    uint32_t endword = (end - 1) / 64;
  136|  49.6k|    words[firstword] ^= ~((~UINT64_C(0)) << (start % 64));
  137|   117k|    for (uint32_t i = firstword; i < endword; i++) {
  ------------------
  |  Branch (137:34): [True: 67.7k, False: 49.6k]
  ------------------
  138|  67.7k|        words[i] = ~words[i];
  139|  67.7k|    }
  140|       |    words[endword] ^= ((~UINT64_C(0)) >> ((~end + 1) % 64));
  141|  49.6k|}

array_container_contains:
  345|  4.25k|                                     uint16_t pos) {
  346|       |    /**
  347|       |     * SIMD Quad algorithm
  348|       |     * Daniel Lemire, "You can beat the binary search," in Daniel Lemire's blog,
  349|       |     *  April 27, 2026,
  350|       |     * https://lemire.me/blog/2026/04/27/you-can-beat-the-binary-search/.
  351|       |     */
  352|  4.25k|    const int32_t gap = 16;
  353|  4.25k|    const uint16_t *carr = arr->array;
  354|  4.25k|    int32_t cardinality = arr->cardinality;
  355|  4.25k|    if (cardinality < gap) {
  ------------------
  |  Branch (355:9): [True: 1.61k, False: 2.64k]
  ------------------
  356|  1.74k|        for (int32_t j = 0; j < cardinality; j++) {
  ------------------
  |  Branch (356:29): [True: 1.71k, False: 26]
  ------------------
  357|  1.71k|            if (carr[j] >= pos) return carr[j] == pos;
  ------------------
  |  Branch (357:17): [True: 1.58k, False: 128]
  ------------------
  358|  1.71k|        }
  359|     26|        return false;
  360|  1.61k|    }
  361|  2.64k|    int32_t num_blocks = cardinality / gap;
  362|  2.64k|    int32_t base = 0;
  363|  2.64k|    int32_t n = num_blocks;
  364|  5.82k|    while (n > 3) {
  ------------------
  |  Branch (364:12): [True: 3.18k, False: 2.64k]
  ------------------
  365|  3.18k|        int32_t quarter = n >> 2;
  366|       |
  367|  3.18k|        int32_t k1 = carr[(base + quarter + 1) * gap - 1];
  368|  3.18k|        int32_t k2 = carr[(base + 2 * quarter + 1) * gap - 1];
  369|  3.18k|        int32_t k3 = carr[(base + 3 * quarter + 1) * gap - 1];
  370|       |
  371|  3.18k|        int32_t c1 = (k1 < pos);
  372|  3.18k|        int32_t c2 = (k2 < pos);
  373|  3.18k|        int32_t c3 = (k3 < pos);
  374|       |
  375|  3.18k|        base += (c1 + c2 + c3) * quarter;
  376|  3.18k|        n -= 3 * quarter;
  377|  3.18k|    }
  378|  4.60k|    while (n > 1) {
  ------------------
  |  Branch (378:12): [True: 1.95k, False: 2.64k]
  ------------------
  379|  1.95k|        int32_t half = n >> 1;
  380|  1.95k|        base = (carr[(base + half + 1) * gap - 1] < pos) ? base + half : base;
  ------------------
  |  Branch (380:16): [True: 86, False: 1.87k]
  ------------------
  381|  1.95k|        n -= half;
  382|  1.95k|    }
  383|  2.64k|    int32_t lo = (carr[(base + 1) * gap - 1] < pos) ? base + 1 : base;
  ------------------
  |  Branch (383:18): [True: 142, False: 2.50k]
  ------------------
  384|       |
  385|  2.64k|    if (lo < num_blocks) {
  ------------------
  |  Branch (385:9): [True: 2.54k, False: 99]
  ------------------
  386|  2.54k|        const uint16_t *blk = carr + lo * gap;
  387|       |#ifdef CROARING_USENEON
  388|       |        uint16x8_t needle = vdupq_n_u16(pos);
  389|       |        uint16x8_t v0 = vld1q_u16(blk);
  390|       |        uint16x8_t v1 = vld1q_u16(blk + 8);
  391|       |        uint16x8_t hit =
  392|       |            vorrq_u16(vceqq_u16(v0, needle), vceqq_u16(v1, needle));
  393|       |#ifdef __arm__
  394|       |        uint16x4_t hit8 = vmax_u16(vget_low_u16(hit), vget_high_u16(hit));
  395|       |        uint16x4_t hit4 = vpmax_u16(hit8, hit8);
  396|       |        return vget_lane_u32(hit4, 0) != 0;
  397|       |#else /* __aarch64__ */
  398|       |        return vmaxvq_u16(hit) != 0;
  399|       |#endif
  400|       |#elif defined(CROARING_IS_X64)
  401|       |        __m128i needle = _mm_set1_epi16((short)pos);
  402|  2.54k|        __m128i v0 = _mm_loadu_si128((const __m128i *)blk);
  403|  2.54k|        __m128i v1 = _mm_loadu_si128((const __m128i *)(blk + 8));
  404|  2.54k|        __m128i hit = _mm_or_si128(_mm_cmpeq_epi16(v0, needle),
  405|  2.54k|                                   _mm_cmpeq_epi16(v1, needle));
  406|  2.54k|        return _mm_movemask_epi8(hit) != 0;
  407|       |#else
  408|       |        for (int32_t j = 0; j < gap; j++) {
  409|       |            if (blk[j] >= pos) return blk[j] == pos;
  410|       |        }
  411|       |        return false;
  412|       |#endif
  413|  2.54k|    }
  414|       |
  415|    787|    for (int32_t j = num_blocks * gap; j < cardinality; j++) {
  ------------------
  |  Branch (415:40): [True: 720, False: 67]
  ------------------
  416|    720|        uint16_t v = carr[j];
  417|    720|        if (v >= pos) return (v == pos);
  ------------------
  |  Branch (417:13): [True: 32, False: 688]
  ------------------
  418|    720|    }
  419|     67|    return false;
  420|     99|}
array_container_minimum:
  454|  4.55k|inline uint16_t array_container_minimum(const array_container_t *arr) {
  455|  4.55k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (455:9): [True: 0, False: 4.55k]
  ------------------
  456|  4.55k|    return arr->array[0];
  457|  4.55k|}
array_container_maximum:
  461|  15.7k|inline uint16_t array_container_maximum(const array_container_t *arr) {
  462|  15.7k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (462:9): [True: 0, False: 15.7k]
  ------------------
  463|  15.7k|    return arr->array[arr->cardinality - 1];
  464|  15.7k|}
array_container_rank:
  467|  4.78k|inline int array_container_rank(const array_container_t *arr, uint16_t x) {
  468|  4.78k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  469|  4.78k|    const bool is_present = idx >= 0;
  470|  4.78k|    if (is_present) {
  ------------------
  |  Branch (470:9): [True: 4.12k, False: 658]
  ------------------
  471|  4.12k|        return idx + 1;
  472|  4.12k|    } else {
  473|    658|        return -idx - 1;
  474|    658|    }
  475|  4.78k|}
array_container_index_equalorlarger:
  517|  5.25k|                                               uint16_t x) {
  518|  5.25k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  519|  5.25k|    const bool is_present = idx >= 0;
  520|  5.25k|    if (is_present) {
  ------------------
  |  Branch (520:9): [True: 4.86k, False: 389]
  ------------------
  521|  4.86k|        return idx;
  522|  4.86k|    } else {
  523|    389|        int32_t candidate = -idx - 1;
  524|    389|        if (candidate < arr->cardinality) return candidate;
  ------------------
  |  Branch (524:13): [True: 389, False: 0]
  ------------------
  525|      0|        return -1;
  526|    389|    }
  527|  5.25k|}
roaring.c:array_container_add_range_nvals:
  537|    617|                                                   int32_t nvals_greater) {
  538|    617|    int32_t union_cardinality = nvals_less + (max - min + 1) + nvals_greater;
  539|    617|    if (union_cardinality > array->capacity) {
  ------------------
  |  Branch (539:9): [True: 565, False: 52]
  ------------------
  540|    565|        array_container_grow(array, union_cardinality, true);
  541|    565|    }
  542|    617|    memmove(&(array->array[union_cardinality - nvals_greater]),
  543|    617|            &(array->array[array->cardinality - nvals_greater]),
  544|    617|            nvals_greater * sizeof(uint16_t));
  545|  1.49M|    for (uint32_t i = 0; i <= max - min; i++) {
  ------------------
  |  Branch (545:26): [True: 1.49M, False: 617]
  ------------------
  546|  1.49M|        array->array[nvals_less + i] = (uint16_t)(min + i);
  547|  1.49M|    }
  548|    617|    array->cardinality = union_cardinality;
  549|    617|}
roaring.c:array_container_remove_range:
  567|  4.13k|                                                uint32_t pos, uint32_t count) {
  568|  4.13k|    if (count != 0) {
  ------------------
  |  Branch (568:9): [True: 346, False: 3.79k]
  ------------------
  569|    346|        memmove(&(array->array[pos]), &(array->array[pos + count]),
  570|    346|                (array->cardinality - pos - count) * sizeof(uint16_t));
  571|    346|        array->cardinality -= count;
  572|    346|    }
  573|  4.13k|}
roaring.c:array_container_cardinality:
   82|  90.2k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  90.2k|    return array->cardinality;
   84|  90.2k|}
roaring.c:array_container_try_add:
  294|  8.26M|                                          int32_t max_cardinality) {
  295|  8.26M|    const int32_t cardinality = arr->cardinality;
  296|       |
  297|       |    // best case, we can append.
  298|  8.26M|    if ((array_container_empty(arr) || arr->array[cardinality - 1] < value) &&
  ------------------
  |  Branch (298:10): [True: 17.4k, False: 8.24M]
  |  Branch (298:40): [True: 55.9k, False: 8.18M]
  ------------------
  299|  73.3k|        cardinality < max_cardinality) {
  ------------------
  |  Branch (299:9): [True: 73.3k, False: 0]
  ------------------
  300|  73.3k|        array_container_append(arr, value);
  301|  73.3k|        return 1;
  302|  73.3k|    }
  303|       |
  304|  8.18M|    const int32_t loc = binarySearch(arr->array, cardinality, value);
  305|       |
  306|  8.18M|    if (loc >= 0) {
  ------------------
  |  Branch (306:9): [True: 6.57M, False: 1.61M]
  ------------------
  307|  6.57M|        return 0;
  308|  6.57M|    } else if (cardinality < max_cardinality) {
  ------------------
  |  Branch (308:16): [True: 1.61M, False: 123]
  ------------------
  309|  1.61M|        if (array_container_full(arr)) {
  ------------------
  |  Branch (309:13): [True: 77.8k, False: 1.53M]
  ------------------
  310|  77.8k|            array_container_grow(arr, arr->capacity + 1, true);
  311|  77.8k|        }
  312|  1.61M|        const int32_t insert_idx = -loc - 1;
  313|  1.61M|        memmove(arr->array + insert_idx + 1, arr->array + insert_idx,
  314|  1.61M|                (cardinality - insert_idx) * sizeof(uint16_t));
  315|  1.61M|        arr->array[insert_idx] = value;
  316|  1.61M|        arr->cardinality++;
  317|  1.61M|        return 1;
  318|  1.61M|    } else {
  319|    123|        return -1;
  320|    123|    }
  321|  8.18M|}
roaring.c:array_container_empty:
  100|  8.26M|static inline bool array_container_empty(const array_container_t *array) {
  101|  8.26M|    return array->cardinality == 0;
  102|  8.26M|}
roaring.c:array_container_append:
  275|  73.3k|                                          uint16_t pos) {
  276|  73.3k|    const int32_t capacity = arr->capacity;
  277|       |
  278|  73.3k|    if (array_container_full(arr)) {
  ------------------
  |  Branch (278:9): [True: 36.6k, False: 36.6k]
  ------------------
  279|  36.6k|        array_container_grow(arr, capacity + 1, true);
  280|  36.6k|    }
  281|       |
  282|  73.3k|    arr->array[arr->cardinality++] = pos;
  283|  73.3k|}
roaring.c:array_container_full:
  106|  1.68M|static inline bool array_container_full(const array_container_t *array) {
  107|  1.68M|    return array->cardinality == array->capacity;
  108|  1.68M|}
roaring.c:array_container_remove:
  330|  7.93k|                                          uint16_t pos) {
  331|  7.93k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, pos);
  332|  7.93k|    const bool is_present = idx >= 0;
  333|  7.93k|    if (is_present) {
  ------------------
  |  Branch (333:9): [True: 3.97k, False: 3.95k]
  ------------------
  334|  3.97k|        memmove(arr->array + idx, arr->array + idx + 1,
  335|  3.97k|                (arr->cardinality - idx - 1) * sizeof(uint16_t));
  336|  3.97k|        arr->cardinality--;
  337|  3.97k|    }
  338|       |
  339|  7.93k|    return is_present;
  340|  7.93k|}
roaring.c:array_container_nonzero_cardinality:
   87|   105k|    const array_container_t *array) {
   88|   105k|    return array->cardinality > 0;
   89|   105k|}
roaring.c:array_container_equals:
  230|  11.0k|                                          const array_container_t *container2) {
  231|  11.0k|    if (container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (231:9): [True: 3.15k, False: 7.88k]
  ------------------
  232|  3.15k|        return false;
  233|  3.15k|    }
  234|  7.88k|    return memequals(container1->array, container2->array,
  235|  7.88k|                     container1->cardinality * 2);
  236|  11.0k|}
roaring.c:array_container_select:
  253|  4.41k|                                          uint32_t *element) {
  254|  4.41k|    int card = array_container_cardinality(container);
  255|  4.41k|    if (*start_rank + card <= rank) {
  ------------------
  |  Branch (255:9): [True: 0, False: 4.41k]
  ------------------
  256|      0|        *start_rank += card;
  257|      0|        return false;
  258|  4.41k|    } else {
  259|  4.41k|        *element = container->array[rank - *start_rank];
  260|       |        return true;
  261|  4.41k|    }
  262|  4.41k|}
roaring.c:array_container_contains_range:
  429|    120|                                                  uint32_t range_end) {
  430|    120|    const int32_t range_count = range_end - range_start;
  431|    120|    const uint16_t rs_included = (uint16_t)range_start;
  432|    120|    const uint16_t re_included = (uint16_t)(range_end - 1);
  433|       |
  434|       |    // Empty range is always included
  435|    120|    if (range_count <= 0) {
  ------------------
  |  Branch (435:9): [True: 0, False: 120]
  ------------------
  436|      0|        return true;
  437|      0|    }
  438|    120|    if (range_count > arr->cardinality) {
  ------------------
  |  Branch (438:9): [True: 49, False: 71]
  ------------------
  439|     49|        return false;
  440|     49|    }
  441|       |
  442|     71|    const int32_t start =
  443|     71|        binarySearch(arr->array, arr->cardinality, rs_included);
  444|       |    // If this sorted array contains all items in the range:
  445|       |    // * the start item must be found
  446|       |    // * the last item in range range_count must exist, and be the expected end
  447|       |    // value
  448|     71|    return (start >= 0) && (arr->cardinality >= start + range_count) &&
  ------------------
  |  Branch (448:12): [True: 49, False: 22]
  |  Branch (448:28): [True: 46, False: 3]
  ------------------
  449|     46|           (arr->array[start + range_count - 1] == re_included);
  ------------------
  |  Branch (449:12): [True: 12, False: 34]
  ------------------
  450|    120|}
roaring_array.c:array_container_size_in_bytes:
  221|  20.2k|    const array_container_t *container) {
  222|  20.2k|    return container->cardinality * sizeof(uint16_t);
  223|  20.2k|}
roaring_array.c:array_container_cardinality:
   82|  7.71k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  7.71k|    return array->cardinality;
   84|  7.71k|}
array.c:array_container_size_in_bytes:
  221|  15.4k|    const array_container_t *container) {
  222|  15.4k|    return container->cardinality * sizeof(uint16_t);
  223|  15.4k|}
convert.c:array_container_cardinality:
   82|  16.4k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  16.4k|    return array->cardinality;
   84|  16.4k|}
convert.c:array_container_serialized_size_in_bytes:
  173|   139k|static inline int32_t array_container_serialized_size_in_bytes(int32_t card) {
  174|   139k|    return card * sizeof(uint16_t);
  175|   139k|}
mixed_intersection.c:array_container_empty:
  100|     34|static inline bool array_container_empty(const array_container_t *array) {
  101|     34|    return array->cardinality == 0;
  102|     34|}
mixed_andnot.c:array_container_cardinality:
   82|    327|static inline int array_container_cardinality(const array_container_t *array) {
   83|    327|    return array->cardinality;
   84|    327|}

bitset_container_get:
  199|   467k|                                 uint16_t pos) {
  200|   467k|    const uint64_t word = bitset->words[pos >> 6];
  201|   467k|    return (word >> (pos & 63)) & 1;
  202|   467k|}
bitset_container_contains:
  239|   345k|                                      uint16_t pos) {
  240|   345k|    return bitset_container_get(bitset, pos);
  241|   345k|}
roaring.c:bitset_container_cardinality:
  255|  10.7k|    const bitset_container_t *bitset) {
  256|  10.7k|    return bitset->cardinality;
  257|  10.7k|}
roaring.c:bitset_container_set:
  152|   311k|                                        uint16_t pos) {
  153|   311k|    const uint64_t old_word = bitset->words[pos >> 6];
  154|   311k|    const int index = pos & 63;
  155|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  156|   311k|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  157|   311k|    bitset->words[pos >> 6] = new_word;
  158|   311k|}
roaring.c:bitset_container_add:
  173|    123|                                        uint16_t pos) {
  174|    123|    const uint64_t old_word = bitset->words[pos >> 6];
  175|    123|    const int index = pos & 63;
  176|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  177|    123|    const uint64_t increment = (old_word ^ new_word) >> index;
  178|    123|    bitset->cardinality += (uint32_t)increment;
  179|    123|    bitset->words[pos >> 6] = new_word;
  180|    123|    return increment > 0;
  181|    123|}
roaring.c:bitset_container_remove:
  186|  2.26k|                                           uint16_t pos) {
  187|  2.26k|    const uint64_t old_word = bitset->words[pos >> 6];
  188|  2.26k|    const int index = pos & 63;
  189|       |    const uint64_t new_word = old_word & (~(UINT64_C(1) << index));
  190|  2.26k|    const uint64_t increment = (old_word ^ new_word) >> index;
  191|  2.26k|    bitset->cardinality -= (uint32_t)increment;
  192|  2.26k|    bitset->words[pos >> 6] = new_word;
  193|  2.26k|    return increment > 0;
  194|  2.26k|}
roaring.c:bitset_container_const_nonzero_cardinality:
  288|  6.33k|    const bitset_container_t *bitset) {
  289|  6.33k|    return !bitset_container_empty(bitset);
  290|  6.33k|}
roaring.c:bitset_container_empty:
  275|  6.33k|static inline bool bitset_container_empty(const bitset_container_t *bitset) {
  276|  6.33k|    if (bitset->cardinality == BITSET_UNKNOWN_CARDINALITY) {
  ------------------
  |  Branch (276:9): [True: 0, False: 6.33k]
  ------------------
  277|      0|        for (int i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; i++) {
  ------------------
  |  Branch (277:25): [True: 0, False: 0]
  ------------------
  278|      0|            if ((bitset->words[i]) != 0) return false;
  ------------------
  |  Branch (278:17): [True: 0, False: 0]
  ------------------
  279|      0|        }
  280|      0|        return true;
  281|      0|    }
  282|  6.33k|    return bitset->cardinality == 0;
  283|  6.33k|}
roaring.c:bitset_container_get_range:
  213|    247|                                              uint32_t pos_end) {
  214|    247|    const uint32_t start = pos_start >> 6;
  215|    247|    const uint32_t end = pos_end >> 6;
  216|       |
  217|    247|    const uint64_t first = ~((1ULL << (pos_start & 0x3F)) - 1);
  218|    247|    const uint64_t last = (1ULL << (pos_end & 0x3F)) - 1;
  219|       |
  220|    247|    if (start == end)
  ------------------
  |  Branch (220:9): [True: 61, False: 186]
  ------------------
  221|     61|        return ((bitset->words[end] & first & last) == (first & last));
  222|    186|    if ((bitset->words[start] & first) != first) return false;
  ------------------
  |  Branch (222:9): [True: 65, False: 121]
  ------------------
  223|       |
  224|    121|    if ((end < BITSET_CONTAINER_SIZE_IN_WORDS) &&
  ------------------
  |  Branch (224:9): [True: 107, False: 14]
  ------------------
  225|    107|        ((bitset->words[end] & last) != last)) {
  ------------------
  |  Branch (225:9): [True: 89, False: 18]
  ------------------
  226|     89|        return false;
  227|     89|    }
  228|       |
  229|     32|    for (uint32_t i = start + 1;
  230|  10.5k|         (i < BITSET_CONTAINER_SIZE_IN_WORDS) && (i < end); ++i) {
  ------------------
  |  Branch (230:10): [True: 10.5k, False: 12]
  |  Branch (230:50): [True: 10.5k, False: 15]
  ------------------
  231|  10.5k|        if (bitset->words[i] != UINT64_C(0xFFFFFFFFFFFFFFFF)) return false;
  ------------------
  |  Branch (231:13): [True: 5, False: 10.5k]
  ------------------
  232|  10.5k|    }
  233|       |
  234|     27|    return true;
  235|     32|}
roaring_array.c:bitset_container_size_in_bytes:
  475|   133k|    const bitset_container_t *container) {
  476|   133k|    (void)container;
  477|   133k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  478|   133k|}
roaring_array.c:bitset_container_cardinality:
  255|  66.6k|    const bitset_container_t *bitset) {
  256|  66.6k|    return bitset->cardinality;
  257|  66.6k|}
bitset.c:bitset_container_size_in_bytes:
  475|   133k|    const bitset_container_t *container) {
  476|   133k|    (void)container;
  477|   133k|    return BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  478|   133k|}
convert.c:bitset_container_set:
  152|  2.37M|                                        uint16_t pos) {
  153|  2.37M|    const uint64_t old_word = bitset->words[pos >> 6];
  154|  2.37M|    const int index = pos & 63;
  155|       |    const uint64_t new_word = old_word | (UINT64_C(1) << index);
  156|  2.37M|    bitset->cardinality += (uint32_t)((old_word ^ new_word) >> index);
  157|  2.37M|    bitset->words[pos >> 6] = new_word;
  158|  2.37M|}
convert.c:bitset_container_serialized_size_in_bytes:
  434|   125k|static inline int32_t bitset_container_serialized_size_in_bytes(void) {
  435|   125k|    return BITSET_CONTAINER_SIZE_IN_WORDS * 8;
  436|   125k|}

container_iterator_next:
 2509|   330k|                                    uint16_t *value) {
 2510|   330k|    switch (typecode) {
 2511|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2511:9): [True: 0, False: 330k]
  ------------------
 2512|      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)
  |  |  ------------------
  ------------------
 2513|      0|            it->index++;
 2514|       |
 2515|      0|            uint32_t wordindex = it->index / 64;
 2516|      0|            if (wordindex >= BITSET_CONTAINER_SIZE_IN_WORDS) {
  ------------------
  |  Branch (2516:17): [True: 0, False: 0]
  ------------------
 2517|      0|                return false;
 2518|      0|            }
 2519|       |
 2520|      0|            uint64_t word =
 2521|      0|                bc->words[wordindex] & (UINT64_MAX << (it->index % 64));
 2522|       |            // next part could be optimized/simplified
 2523|      0|            while (word == 0 &&
  ------------------
  |  Branch (2523:20): [True: 0, False: 0]
  ------------------
 2524|      0|                   (wordindex + 1 < BITSET_CONTAINER_SIZE_IN_WORDS)) {
  ------------------
  |  Branch (2524:20): [True: 0, False: 0]
  ------------------
 2525|      0|                wordindex++;
 2526|      0|                word = bc->words[wordindex];
 2527|      0|            }
 2528|      0|            if (word != 0) {
  ------------------
  |  Branch (2528:17): [True: 0, False: 0]
  ------------------
 2529|      0|                it->index = wordindex * 64 + roaring_trailing_zeroes(word);
 2530|      0|                *value = it->index;
 2531|      0|                return true;
 2532|      0|            }
 2533|      0|            return false;
 2534|      0|        }
 2535|   292k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|   292k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2535:9): [True: 292k, False: 38.0k]
  ------------------
 2536|   292k|            const array_container_t *ac = const_CAST_array(c);
  ------------------
  |  |   55|   292k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   292k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2537|   292k|            it->index++;
 2538|   292k|            if (it->index < ac->cardinality) {
  ------------------
  |  Branch (2538:17): [True: 285k, False: 6.45k]
  ------------------
 2539|   285k|                *value = ac->array[it->index];
 2540|   285k|                return true;
 2541|   285k|            }
 2542|  6.45k|            return false;
 2543|   292k|        }
 2544|  38.0k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  38.0k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2544:9): [True: 38.0k, False: 292k]
  ------------------
 2545|  38.0k|            if (*value == UINT16_MAX) {  // Avoid overflow to zero
  ------------------
  |  Branch (2545:17): [True: 0, False: 38.0k]
  ------------------
 2546|      0|                return false;
 2547|      0|            }
 2548|       |
 2549|  38.0k|            const run_container_t *rc = const_CAST_run(c);
  ------------------
  |  |   78|  38.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  38.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2550|  38.0k|            uint32_t limit =
 2551|  38.0k|                rc->runs[it->index].value + rc->runs[it->index].length;
 2552|  38.0k|            if (*value < limit) {
  ------------------
  |  Branch (2552:17): [True: 24.9k, False: 13.0k]
  ------------------
 2553|  24.9k|                (*value)++;
 2554|  24.9k|                return true;
 2555|  24.9k|            }
 2556|       |
 2557|  13.0k|            it->index++;
 2558|  13.0k|            if (it->index < rc->n_runs) {
  ------------------
  |  Branch (2558:17): [True: 12.6k, False: 441]
  ------------------
 2559|  12.6k|                *value = rc->runs[it->index].value;
 2560|  12.6k|                return true;
 2561|  12.6k|            }
 2562|    441|            return false;
 2563|  13.0k|        }
 2564|      0|        default:
  ------------------
  |  Branch (2564:9): [True: 0, False: 330k]
  ------------------
 2565|      0|            assert(false);
 2566|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2567|      0|            return false;
 2568|   330k|    }
 2569|   330k|}
roaring.c:container_from_range:
  323|  65.6k|                                                uint32_t max, uint16_t step) {
  324|  65.6k|    if (step == 0) return NULL;  // being paranoid
  ------------------
  |  Branch (324:9): [True: 0, False: 65.6k]
  ------------------
  325|  65.6k|    if (step == 1) {
  ------------------
  |  Branch (325:9): [True: 65.6k, False: 0]
  ------------------
  326|  65.6k|        return container_range_of_ones(min, max, type);
  327|       |        // Note: the result is not always a run (need to check the cardinality)
  328|       |        //*type = RUN_CONTAINER_TYPE;
  329|       |        // return run_container_create_range(min, max);
  330|  65.6k|    }
  331|      0|    int size = (max - min + step - 1) / step;
  332|      0|    if (size <= DEFAULT_MAX_SIZE) {  // array container
  ------------------
  |  Branch (332:9): [True: 0, False: 0]
  ------------------
  333|      0|        *type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  334|      0|        array_container_t *array = array_container_create_given_capacity(size);
  335|      0|        array_container_add_from_range(array, min, max, step);
  336|      0|        assert(array->cardinality == size);
  337|      0|        return array;
  338|      0|    } else {  // bitset container
  339|      0|        *type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  340|      0|        bitset_container_t *bitset = bitset_container_create();
  341|      0|        bitset_container_add_from_range(bitset, min, max, step);
  342|       |        assert(bitset->cardinality == size);
  343|      0|        return bitset;
  344|      0|    }
  345|      0|}
roaring.c:container_add_range:
 2334|  3.13k|                                               uint8_t *result_type) {
 2335|       |    // NB: when selecting new container type, we perform only inexpensive checks
 2336|  3.13k|    switch (type) {
 2337|      0|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2337:9): [True: 0, False: 3.13k]
  ------------------
 2338|      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)
  |  |  ------------------
  ------------------
 2339|       |
 2340|      0|            int32_t union_cardinality = 0;
 2341|      0|            union_cardinality += bitset->cardinality;
 2342|      0|            union_cardinality += max - min + 1;
 2343|      0|            union_cardinality -=
 2344|      0|                bitset_lenrange_cardinality(bitset->words, min, max - min);
 2345|       |
 2346|      0|            if (union_cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (2346:17): [True: 0, False: 0]
  ------------------
 2347|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 2348|      0|                return run_container_create_range(0, INT32_C(0x10000));
 2349|      0|            } else {
 2350|      0|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2351|      0|                bitset_set_lenrange(bitset->words, min, max - min);
 2352|      0|                bitset->cardinality = union_cardinality;
 2353|      0|                return bitset;
 2354|      0|            }
 2355|      0|        }
 2356|  2.72k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  2.72k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2356:9): [True: 2.72k, False: 411]
  ------------------
 2357|  2.72k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  2.72k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.72k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2358|       |
 2359|  2.72k|            int32_t nvals_greater =
 2360|  2.72k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2361|  2.72k|            int32_t nvals_less =
 2362|  2.72k|                count_less(array->array, array->cardinality - nvals_greater,
 2363|  2.72k|                           (uint16_t)min);
 2364|  2.72k|            int32_t union_cardinality =
 2365|  2.72k|                nvals_less + (max - min + 1) + nvals_greater;
 2366|       |
 2367|  2.72k|            if (union_cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (2367:17): [True: 606, False: 2.12k]
  ------------------
 2368|    606|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    606|#define RUN_CONTAINER_TYPE 3
  ------------------
 2369|    606|                return run_container_create_range(0, INT32_C(0x10000));
 2370|  2.12k|            } else if (union_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2370:24): [True: 617, False: 1.50k]
  ------------------
 2371|    617|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    617|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2372|    617|                array_container_add_range_nvals(array, min, max, nvals_less,
 2373|    617|                                                nvals_greater);
 2374|    617|                return array;
 2375|  1.50k|            } else {
 2376|  1.50k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.50k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2377|  1.50k|                bitset_container_t *bitset = bitset_container_from_array(array);
 2378|  1.50k|                bitset_set_lenrange(bitset->words, min, max - min);
 2379|  1.50k|                bitset->cardinality = union_cardinality;
 2380|  1.50k|                return bitset;
 2381|  1.50k|            }
 2382|  2.72k|        }
 2383|    411|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|    411|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2383:9): [True: 411, False: 2.72k]
  ------------------
 2384|    411|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|    411|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    411|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2385|       |
 2386|    411|            int32_t nruns_greater =
 2387|    411|                rle16_count_greater(run->runs, run->n_runs, (uint16_t)max);
 2388|    411|            int32_t nruns_less = rle16_count_less(
 2389|    411|                run->runs, run->n_runs - nruns_greater, (uint16_t)min);
 2390|       |
 2391|    411|            int32_t run_size_bytes =
 2392|    411|                (nruns_less + 1 + nruns_greater) * sizeof(rle16_t);
 2393|    411|            int32_t bitset_size_bytes =
 2394|    411|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
 2395|       |
 2396|    411|            if (run_size_bytes <= bitset_size_bytes) {
  ------------------
  |  Branch (2396:17): [True: 411, False: 0]
  ------------------
 2397|    411|                run_container_add_range_nruns(run, min, max, nruns_less,
 2398|    411|                                              nruns_greater);
 2399|    411|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    411|#define RUN_CONTAINER_TYPE 3
  ------------------
 2400|    411|                return run;
 2401|    411|            } else {
 2402|      0|                return container_from_run_range(run, min, max, result_type);
 2403|      0|            }
 2404|    411|        }
 2405|      0|        default:
  ------------------
  |  Branch (2405:9): [True: 0, False: 3.13k]
  ------------------
 2406|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2407|  3.13k|    }
 2408|  3.13k|}
roaring.c:container_remove_range:
 2423|  20.5k|                                                  uint8_t *result_type) {
 2424|  20.5k|    switch (type) {
 2425|  1.29k|        case BITSET_CONTAINER_TYPE: {
  ------------------
  |  |   48|  1.29k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2425:9): [True: 1.29k, False: 19.2k]
  ------------------
 2426|  1.29k|            bitset_container_t *bitset = CAST_bitset(c);
  ------------------
  |  |   52|  1.29k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.29k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2427|       |
 2428|  1.29k|            int32_t result_cardinality =
 2429|  1.29k|                bitset->cardinality -
 2430|  1.29k|                bitset_lenrange_cardinality(bitset->words, min, max - min);
 2431|       |
 2432|  1.29k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2432:17): [True: 44, False: 1.25k]
  ------------------
 2433|     44|                return NULL;
 2434|  1.25k|            } else if (result_cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (2434:24): [True: 138, False: 1.11k]
  ------------------
 2435|    138|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    138|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2436|    138|                bitset_reset_range(bitset->words, min, max + 1);
 2437|    138|                bitset->cardinality = result_cardinality;
 2438|    138|                return array_container_from_bitset(bitset);
 2439|  1.11k|            } else {
 2440|  1.11k|                *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  1.11k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2441|  1.11k|                bitset_reset_range(bitset->words, min, max + 1);
 2442|  1.11k|                bitset->cardinality = result_cardinality;
 2443|  1.11k|                return bitset;
 2444|  1.11k|            }
 2445|  1.29k|        }
 2446|  4.44k|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  4.44k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2446:9): [True: 4.44k, False: 16.1k]
  ------------------
 2447|  4.44k|            array_container_t *array = CAST_array(c);
  ------------------
  |  |   54|  4.44k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2448|       |
 2449|  4.44k|            int32_t nvals_greater =
 2450|  4.44k|                count_greater(array->array, array->cardinality, (uint16_t)max);
 2451|  4.44k|            int32_t nvals_less =
 2452|  4.44k|                count_less(array->array, array->cardinality - nvals_greater,
 2453|  4.44k|                           (uint16_t)min);
 2454|  4.44k|            int32_t result_cardinality = nvals_less + nvals_greater;
 2455|       |
 2456|  4.44k|            if (result_cardinality == 0) {
  ------------------
  |  Branch (2456:17): [True: 304, False: 4.13k]
  ------------------
 2457|    304|                return NULL;
 2458|  4.13k|            } else {
 2459|  4.13k|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.13k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2460|  4.13k|                array_container_remove_range(
 2461|  4.13k|                    array, nvals_less, array->cardinality - result_cardinality);
 2462|  4.13k|                return array;
 2463|  4.13k|            }
 2464|  4.44k|        }
 2465|  14.8k|        case RUN_CONTAINER_TYPE: {
  ------------------
  |  |   50|  14.8k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2465:9): [True: 14.8k, False: 5.73k]
  ------------------
 2466|  14.8k|            run_container_t *run = CAST_run(c);
  ------------------
  |  |   77|  14.8k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  14.8k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2467|       |
 2468|  14.8k|            if (run->n_runs == 0) {
  ------------------
  |  Branch (2468:17): [True: 0, False: 14.8k]
  ------------------
 2469|      0|                return NULL;
 2470|      0|            }
 2471|  14.8k|            if (min <= run_container_minimum(run) &&
  ------------------
  |  Branch (2471:17): [True: 14.4k, False: 366]
  ------------------
 2472|  14.4k|                max >= run_container_maximum(run)) {
  ------------------
  |  Branch (2472:17): [True: 13.1k, False: 1.32k]
  ------------------
 2473|  13.1k|                return NULL;
 2474|  13.1k|            }
 2475|       |
 2476|  1.69k|            run_container_remove_range(run, min, max);
 2477|  1.69k|            return convert_run_to_efficient_container(run, result_type);
 2478|  14.8k|        }
 2479|      0|        default:
  ------------------
  |  Branch (2479:9): [True: 0, False: 20.5k]
  ------------------
 2480|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2481|  20.5k|    }
 2482|  20.5k|}
roaring.c:container_get_cardinality:
  244|   378k|                                            uint8_t typecode) {
  245|   378k|    c = container_unwrap_shared(c, &typecode);
  246|   378k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 378k, False: 0]
  ------------------
  247|  9.38k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  9.38k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 9.38k, False: 369k]
  ------------------
  248|  9.38k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  9.38k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  9.38k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  81.0k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  81.0k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 81.0k, False: 297k]
  ------------------
  250|  81.0k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  81.0k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  81.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  251|   288k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   288k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (251:9): [True: 288k, False: 90.4k]
  ------------------
  252|   288k|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|   288k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   288k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|   378k|    }
  254|   378k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|   378k|}
roaring.c:get_container_type:
  129|  74.3k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|  74.3k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  74.3k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 74.3k]
  ------------------
  131|      0|        return const_CAST_shared(c)->typecode;
  ------------------
  |  |   80|      0|#define const_CAST_shared(c) CAST(const shared_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  132|  74.3k|    } else {
  133|  74.3k|        return type;
  134|  74.3k|    }
  135|  74.3k|}
roaring.c:get_writable_copy_if_shared:
  146|  9.17M|                                                       uint8_t *type) {
  147|  9.17M|    if (*type == SHARED_CONTAINER_TYPE) {  // shared, return enclosed container
  ------------------
  |  |   51|  9.17M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (147:9): [True: 0, False: 9.17M]
  ------------------
  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|  9.17M|    } else {
  150|  9.17M|        return c;  // not shared, so return as-is
  151|  9.17M|    }
  152|  9.17M|}
roaring.c:container_add:
  498|  8.94M|    uint8_t *new_typecode) {
  499|  8.94M|    c = get_writable_copy_if_shared(c, &typecode);
  500|  8.94M|    switch (typecode) {
  501|   311k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   311k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (501:9): [True: 311k, False: 8.63M]
  ------------------
  502|   311k|            bitset_container_set(CAST_bitset(c), val);
  ------------------
  |  |   52|   311k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   311k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  503|   311k|            *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|   311k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  504|   311k|            return c;
  505|  8.26M|        case ARRAY_CONTAINER_TYPE: {
  ------------------
  |  |   49|  8.26M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (505:9): [True: 8.26M, False: 682k]
  ------------------
  506|  8.26M|            array_container_t *ac = CAST_array(c);
  ------------------
  |  |   54|  8.26M|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  8.26M|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  507|  8.26M|            if (array_container_try_add(ac, val, DEFAULT_MAX_SIZE) != -1) {
  ------------------
  |  Branch (507:17): [True: 8.26M, False: 123]
  ------------------
  508|  8.26M|                *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  8.26M|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  509|  8.26M|                return ac;
  510|  8.26M|            } else {
  511|    123|                bitset_container_t *bitset = bitset_container_from_array(ac);
  512|    123|                bitset_container_add(bitset, val);
  513|    123|                *new_typecode = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    123|#define BITSET_CONTAINER_TYPE 1
  ------------------
  514|    123|                return bitset;
  515|    123|            }
  516|  8.26M|        } break;
  517|   371k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|   371k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (517:9): [True: 371k, False: 8.57M]
  ------------------
  518|       |            // per Java, no container type adjustments are done (revisit?)
  519|   371k|            run_container_add(CAST_run(c), val);
  ------------------
  |  |   77|   371k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|   371k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  520|   371k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|   371k|#define RUN_CONTAINER_TYPE 3
  ------------------
  521|   371k|            return c;
  522|      0|        default:
  ------------------
  |  Branch (522:9): [True: 0, False: 8.94M]
  ------------------
  523|      0|            assert(false);
  524|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  525|      0|            return NULL;
  526|  8.94M|    }
  527|  8.94M|}
roaring.c:container_remove:
  539|  13.0k|    uint8_t *new_typecode) {
  540|  13.0k|    c = get_writable_copy_if_shared(c, &typecode);
  541|  13.0k|    switch (typecode) {
  542|  2.26k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.26k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (542:9): [True: 2.26k, False: 10.7k]
  ------------------
  543|  2.26k|            if (bitset_container_remove(CAST_bitset(c), val)) {
  ------------------
  |  |   52|  2.26k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.26k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (543:17): [True: 1.38k, False: 884]
  ------------------
  544|  1.38k|                int card = bitset_container_cardinality(CAST_bitset(c));
  ------------------
  |  |   52|  1.38k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.38k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  545|  1.38k|                if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (545:21): [True: 15, False: 1.36k]
  ------------------
  546|     15|                    *new_typecode = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     15|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  547|     15|                    return array_container_from_bitset(CAST_bitset(c));
  ------------------
  |  |   52|     15|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     15|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  548|     15|                }
  549|  1.38k|            }
  550|  2.25k|            *new_typecode = typecode;
  551|  2.25k|            return c;
  552|  7.93k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.93k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (552:9): [True: 7.93k, False: 5.12k]
  ------------------
  553|  7.93k|            *new_typecode = typecode;
  554|  7.93k|            array_container_remove(CAST_array(c), val);
  ------------------
  |  |   54|  7.93k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  7.93k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  555|  7.93k|            return c;
  556|  2.86k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.86k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (556:9): [True: 2.86k, False: 10.2k]
  ------------------
  557|       |            // per Java, no container type adjustments are done (revisit?)
  558|  2.86k|            run_container_remove(CAST_run(c), val);
  ------------------
  |  |   77|  2.86k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.86k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  559|  2.86k|            *new_typecode = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  2.86k|#define RUN_CONTAINER_TYPE 3
  ------------------
  560|  2.86k|            return c;
  561|      0|        default:
  ------------------
  |  Branch (561:9): [True: 0, False: 13.0k]
  ------------------
  562|      0|            assert(false);
  563|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  564|      0|            return NULL;
  565|  13.0k|    }
  566|  13.0k|}
roaring.c:container_nonzero_cardinality:
  443|   171k|                                                 uint8_t typecode) {
  444|   171k|    c = container_unwrap_shared(c, &typecode);
  445|   171k|    switch (typecode) {
  ------------------
  |  Branch (445:13): [True: 171k, False: 0]
  ------------------
  446|  6.33k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  6.33k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (446:9): [True: 6.33k, False: 164k]
  ------------------
  447|  6.33k|            return bitset_container_const_nonzero_cardinality(
  448|  6.33k|                const_CAST_bitset(c));
  ------------------
  |  |   53|  6.33k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.33k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  449|   105k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|   105k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (449:9): [True: 105k, False: 65.8k]
  ------------------
  450|   105k|            return array_container_nonzero_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|   105k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|   105k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  451|  59.5k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  59.5k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (451:9): [True: 59.5k, False: 111k]
  ------------------
  452|  59.5k|            return run_container_nonzero_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|  59.5k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  59.5k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  453|   171k|    }
  454|   171k|    assert(false);
  455|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  456|      0|    return 0;  // unreached
  457|   171k|}
roaring.c:container_and:
  734|  7.01k|                                         uint8_t *result_type) {
  735|  7.01k|    c1 = container_unwrap_shared(c1, &type1);
  736|  7.01k|    c2 = container_unwrap_shared(c2, &type2);
  737|  7.01k|    container_t *result = NULL;
  738|  7.01k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  7.01k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  739|      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 (739:9): [True: 0, False: 7.01k]
  ------------------
  740|      0|            *result_type =
  741|      0|                bitset_bitset_container_intersection(
  ------------------
  |  Branch (741:17): [True: 0, False: 0]
  ------------------
  742|      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)
  |  |  ------------------
  ------------------
  743|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  744|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  745|      0|            return result;
  746|       |
  747|  3.40k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.40k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (747:9): [True: 3.40k, False: 3.61k]
  ------------------
  748|  3.40k|            result = array_container_create();
  749|  3.40k|            array_container_intersection(
  750|  3.40k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  3.40k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  751|  3.40k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  752|  3.40k|            return result;
  753|       |
  754|    624|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    624|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (754:9): [True: 624, False: 6.39k]
  ------------------
  755|    624|            result = run_container_create();
  756|    624|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  757|    624|                                       CAST_run(result));
  ------------------
  |  |   77|    624|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  758|    624|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|    624|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  759|    624|                                                               result_type);
  760|       |
  761|      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 (761:9): [True: 0, False: 7.01k]
  ------------------
  762|      0|            result = array_container_create();
  763|      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)
  |  |  ------------------
  ------------------
  764|      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)
  |  |  ------------------
  ------------------
  765|      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)
  |  |  ------------------
  ------------------
  766|      0|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  767|      0|            return result;
  768|       |
  769|    572|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    572|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    572|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (769:9): [True: 572, False: 6.44k]
  ------------------
  770|    572|            result = array_container_create();
  771|    572|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  772|    572|            array_bitset_container_intersection(const_CAST_array(c1),
  ------------------
  |  |   55|    572|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  773|    572|                                                const_CAST_bitset(c2),
  ------------------
  |  |   53|    572|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  774|    572|                                                CAST_array(result));
  ------------------
  |  |   54|    572|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  775|    572|            return result;
  776|       |
  777|      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 (777:9): [True: 0, False: 7.01k]
  ------------------
  778|      0|            *result_type =
  779|      0|                run_bitset_container_intersection(
  ------------------
  |  Branch (779:17): [True: 0, False: 0]
  ------------------
  780|      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)
  |  |  ------------------
  ------------------
  781|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  782|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  783|      0|            return result;
  784|       |
  785|    590|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    590|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    590|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (785:9): [True: 590, False: 6.42k]
  ------------------
  786|    590|            *result_type =
  787|    590|                run_bitset_container_intersection(
  ------------------
  |  Branch (787:17): [True: 0, False: 590]
  ------------------
  788|    590|                    const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                  const_CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    590|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  789|    590|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  790|    590|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.18k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  791|    590|            return result;
  792|       |
  793|    717|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    717|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    717|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    717|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (793:9): [True: 717, False: 6.29k]
  ------------------
  794|    717|            result = array_container_create();
  795|    717|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    717|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  796|    717|            array_run_container_intersection(
  797|    717|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    717|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    717|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    717|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  798|    717|            return result;
  799|       |
  800|  1.11k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.11k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.11k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (800:9): [True: 1.11k, False: 5.90k]
  ------------------
  801|  1.11k|            result = array_container_create();
  802|  1.11k|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|  1.11k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  803|  1.11k|            array_run_container_intersection(
  804|  1.11k|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|  1.11k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|  1.11k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|  1.11k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  805|  1.11k|            return result;
  806|       |
  807|      0|        default:
  ------------------
  |  Branch (807:9): [True: 0, False: 7.01k]
  ------------------
  808|      0|            assert(false);
  809|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  810|      0|            return NULL;
  811|  7.01k|    }
  812|  7.01k|}
roaring.c:container_iand:
  929|  62.3k|                                          uint8_t *result_type) {
  930|  62.3k|    c1 = get_writable_copy_if_shared(c1, &type1);
  931|  62.3k|    c2 = container_unwrap_shared(c2, &type2);
  932|  62.3k|    container_t *result = NULL;
  933|  62.3k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  62.3k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  934|  1.42k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.42k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.42k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.42k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (934:9): [True: 1.42k, False: 60.9k]
  ------------------
  935|  1.42k|            *result_type = bitset_bitset_container_intersection_inplace(
  ------------------
  |  Branch (935:28): [True: 1.42k, False: 0]
  ------------------
  936|  1.42k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.42k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.42k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  937|  1.42k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.42k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  938|  1.42k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.42k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  939|  1.42k|            return result;
  940|       |
  941|  5.75k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.75k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.75k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.75k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (941:9): [True: 5.75k, False: 56.6k]
  ------------------
  942|  5.75k|            array_container_intersection_inplace(CAST_array(c1),
  ------------------
  |  |   54|  5.75k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  5.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  943|  5.75k|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|  5.75k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.75k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  944|  5.75k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  5.75k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  945|  5.75k|            return c1;
  946|       |
  947|  54.0k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  54.0k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  54.0k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  54.0k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (947:9): [True: 54.0k, False: 8.29k]
  ------------------
  948|  54.0k|            result = run_container_create();
  949|  54.0k|            run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  54.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  54.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_intersection(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|  54.0k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  54.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  950|  54.0k|                                       CAST_run(result));
  ------------------
  |  |   77|  54.0k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  54.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  951|       |            // as of January 2016, Java code used non-in-place intersection for
  952|       |            // two runcontainers
  953|  54.0k|            return convert_run_to_efficient_container_and_free(CAST_run(result),
  ------------------
  |  |   77|  54.0k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  54.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  954|  54.0k|                                                               result_type);
  955|       |
  956|     44|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|     44|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     44|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     44|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (956:9): [True: 44, False: 62.3k]
  ------------------
  957|       |            // c1 is a bitmap so no inplace possible
  958|     44|            result = array_container_create();
  959|     44|            array_bitset_container_intersection(const_CAST_array(c2),
  ------------------
  |  |   55|     44|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     44|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  960|     44|                                                const_CAST_bitset(c1),
  ------------------
  |  |   53|     44|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     44|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  961|     44|                                                CAST_array(result));
  ------------------
  |  |   54|     44|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     44|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  962|     44|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|     44|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  963|     44|            return result;
  964|       |
  965|      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 (965:9): [True: 0, False: 62.3k]
  ------------------
  966|      0|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  967|      0|            array_bitset_container_intersection(
  968|      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)
  |  |  ------------------
  ------------------
  969|      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)
  |  |  ------------------
  ------------------
  970|      0|            return c1;
  971|       |
  972|      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 (972:9): [True: 0, False: 62.3k]
  ------------------
  973|       |            // will attempt in-place computation
  974|      0|            *result_type = run_bitset_container_intersection(
  ------------------
  |  Branch (974:28): [True: 0, False: 0]
  ------------------
  975|      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)
  |  |  ------------------
  ------------------
  976|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  977|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  978|      0|            return c1;
  979|       |
  980|      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 (980:9): [True: 0, False: 62.3k]
  ------------------
  981|      0|            *result_type =
  982|      0|                run_bitset_container_intersection(
  ------------------
  |  Branch (982:17): [True: 0, False: 0]
  ------------------
  983|      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)
  |  |  ------------------
  ------------------
  984|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  985|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  986|      0|            return result;
  987|       |
  988|    160|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    160|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    160|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    160|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (988:9): [True: 160, False: 62.2k]
  ------------------
  989|    160|            result = array_container_create();
  990|    160|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    160|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  991|    160|            array_run_container_intersection(
  992|    160|                const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   55|    160|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    160|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   78|    160|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    160|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), CAST_array(result));
  ------------------
  |  |   54|    160|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    160|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  993|    160|            return result;
  994|       |
  995|    902|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    902|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    902|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    902|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (995:9): [True: 902, False: 61.4k]
  ------------------
  996|    902|            result = array_container_create();
  997|    902|            *result_type = ARRAY_CONTAINER_TYPE;  // never bitset
  ------------------
  |  |   49|    902|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  998|    902|            array_run_container_intersection(
  999|    902|                const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   55|    902|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    902|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   78|    902|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    902|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), CAST_array(result));
  ------------------
  |  |   54|    902|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    902|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1000|    902|            return result;
 1001|       |
 1002|      0|        default:
  ------------------
  |  Branch (1002:9): [True: 0, False: 62.3k]
  ------------------
 1003|      0|            assert(false);
 1004|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1005|      0|            return NULL;
 1006|  62.3k|    }
 1007|  62.3k|}
roaring.c:container_or:
 1016|  7.01k|                                        uint8_t *result_type) {
 1017|  7.01k|    c1 = container_unwrap_shared(c1, &type1);
 1018|  7.01k|    c2 = container_unwrap_shared(c2, &type2);
 1019|  7.01k|    container_t *result = NULL;
 1020|  7.01k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  7.01k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1021|      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 (1021:9): [True: 0, False: 7.01k]
  ------------------
 1022|      0|            result = bitset_container_create();
 1023|      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)
  |  |  ------------------
  ------------------
 1024|      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)
  |  |  ------------------
  ------------------
 1025|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1026|      0|            return result;
 1027|       |
 1028|  3.40k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.40k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1028:9): [True: 3.40k, False: 3.61k]
  ------------------
 1029|  3.40k|            *result_type =
 1030|  3.40k|                array_array_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1030:17): [True: 44, False: 3.35k]
  ------------------
 1031|  3.40k|                                            const_CAST_array(c2), &result)
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1032|  3.40k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     44|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1033|  3.40k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  6.75k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1034|  3.40k|            return result;
 1035|       |
 1036|    624|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    624|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1036:9): [True: 624, False: 6.39k]
  ------------------
 1037|    624|            result = run_container_create();
 1038|    624|            run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union(const_CAST_run(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1039|    624|                                CAST_run(result));
  ------------------
  |  |   77|    624|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1040|    624|            *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  ------------------
 1041|       |            // todo: could be optimized since will never convert to array
 1042|    624|            result = convert_run_to_efficient_container_and_free(
 1043|    624|                CAST_run(result), result_type);
  ------------------
  |  |   77|    624|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1044|    624|            return result;
 1045|       |
 1046|      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 (1046:9): [True: 0, False: 7.01k]
  ------------------
 1047|      0|            result = bitset_container_create();
 1048|      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)
  |  |  ------------------
  ------------------
 1049|      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)
  |  |  ------------------
  ------------------
 1050|      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)
  |  |  ------------------
  ------------------
 1051|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1052|      0|            return result;
 1053|       |
 1054|    572|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    572|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    572|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1054:9): [True: 572, False: 6.44k]
  ------------------
 1055|    572|            result = bitset_container_create();
 1056|    572|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    572|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1057|    572|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    572|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1058|    572|                                         CAST_bitset(result));
  ------------------
  |  |   52|    572|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1059|    572|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    572|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1060|    572|            return result;
 1061|       |
 1062|      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 (1062:9): [True: 0, False: 7.01k]
  ------------------
 1063|      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 (1063:17): [True: 0, False: 0]
  ------------------
 1064|      0|                result = run_container_create();
 1065|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1066|      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)
  |  |  ------------------
  ------------------
 1067|      0|                return result;
 1068|      0|            }
 1069|      0|            result = bitset_container_create();
 1070|      0|            run_bitset_container_union(
 1071|      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)
  |  |  ------------------
  ------------------
 1072|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1073|      0|            return result;
 1074|       |
 1075|    590|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    590|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    590|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1075:9): [True: 590, False: 6.42k]
  ------------------
 1076|    590|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1076:17): [True: 0, False: 590]
  ------------------
 1077|      0|                result = run_container_create();
 1078|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1079|      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)
  |  |  ------------------
  ------------------
 1080|      0|                return result;
 1081|      0|            }
 1082|    590|            result = bitset_container_create();
 1083|    590|            run_bitset_container_union(
 1084|    590|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    590|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    590|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1085|    590|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1086|    590|            return result;
 1087|       |
 1088|    717|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    717|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    717|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    717|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1088:9): [True: 717, False: 6.29k]
  ------------------
 1089|    717|            result = run_container_create();
 1090|    717|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    717|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    717|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1091|    717|                                      CAST_run(result));
  ------------------
  |  |   77|    717|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1092|    717|            result = convert_run_to_efficient_container_and_free(
 1093|    717|                CAST_run(result), result_type);
  ------------------
  |  |   77|    717|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1094|    717|            return result;
 1095|       |
 1096|  1.11k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.11k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.11k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1096:9): [True: 1.11k, False: 5.90k]
  ------------------
 1097|  1.11k|            result = run_container_create();
 1098|  1.11k|            array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   55|  1.11k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c2), const_CAST_run(c1),
  ------------------
  |  |   78|  1.11k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1099|  1.11k|                                      CAST_run(result));
  ------------------
  |  |   77|  1.11k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1100|  1.11k|            result = convert_run_to_efficient_container_and_free(
 1101|  1.11k|                CAST_run(result), result_type);
  ------------------
  |  |   77|  1.11k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1102|  1.11k|            return result;
 1103|       |
 1104|      0|        default:
  ------------------
  |  Branch (1104:9): [True: 0, False: 7.01k]
  ------------------
 1105|      0|            assert(false);
 1106|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1107|      0|            return NULL;  // unreached
 1108|  7.01k|    }
 1109|  7.01k|}
roaring.c:container_is_full:
  262|  7.83k|static inline bool container_is_full(const container_t *c, uint8_t typecode) {
  263|  7.83k|    c = container_unwrap_shared(c, &typecode);
  264|  7.83k|    switch (typecode) {
  ------------------
  |  Branch (264:13): [True: 7.83k, False: 0]
  ------------------
  265|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (265:9): [True: 0, False: 7.83k]
  ------------------
  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|  4.78k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.78k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (268:9): [True: 4.78k, False: 3.05k]
  ------------------
  269|  4.78k|            return array_container_cardinality(const_CAST_array(c)) ==
  ------------------
  |  |   55|  4.78k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.78k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  270|  4.78k|                   (1 << 16);
  271|  3.05k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  3.05k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (271:9): [True: 3.05k, False: 4.78k]
  ------------------
  272|  3.05k|            return run_container_is_full(const_CAST_run(c));
  ------------------
  |  |   78|  3.05k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.05k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  273|  7.83k|    }
  274|  7.83k|    assert(false);
  275|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  276|      0|    return 0;  // unreached
  277|  7.83k|}
roaring.c:container_ior:
 1234|  7.12k|                                         uint8_t *result_type) {
 1235|  7.12k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1236|  7.12k|    c2 = container_unwrap_shared(c2, &type2);
 1237|  7.12k|    container_t *result = NULL;
 1238|  7.12k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  7.12k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1239|      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 (1239:9): [True: 0, False: 7.12k]
  ------------------
 1240|      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)
  |  |  ------------------
  ------------------
 1241|      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)
  |  |  ------------------
  ------------------
 1242|      0|#if CROARING_OR_BITSET_CONVERSION_TO_FULL
 1243|      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 (1243:17): [True: 0, False: 0]
  ------------------
 1244|      0|                result = run_container_create_range(0, (1 << 16));
 1245|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1246|      0|                return result;
 1247|      0|            }
 1248|      0|#endif
 1249|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1250|      0|            return c1;
 1251|       |
 1252|  3.56k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.56k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.56k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.56k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1252:9): [True: 3.56k, False: 3.56k]
  ------------------
 1253|  3.56k|            *result_type = array_array_container_inplace_union(
  ------------------
  |  Branch (1253:28): [True: 0, False: 3.56k]
  ------------------
 1254|  3.56k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  3.56k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  3.56k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.56k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1255|  3.56k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1256|  3.56k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.13k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1257|  3.56k|            if ((result == NULL) && (*result_type == ARRAY_CONTAINER_TYPE)) {
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1257:17): [True: 0, False: 3.56k]
  |  Branch (1257:37): [True: 0, False: 0]
  ------------------
 1258|      0|                return c1;  // the computation was done in-place!
 1259|      0|            }
 1260|  3.56k|            return result;
 1261|       |
 1262|  1.50k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  1.50k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.50k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.50k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1262:9): [True: 1.50k, False: 5.62k]
  ------------------
 1263|  1.50k|            run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   77|  1.50k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          run_container_union_inplace(CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  1.50k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1264|  1.50k|            return convert_run_to_efficient_container(CAST_run(c1),
  ------------------
  |  |   77|  1.50k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.50k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1265|  1.50k|                                                      result_type);
 1266|       |
 1267|      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 (1267:9): [True: 0, False: 7.12k]
  ------------------
 1268|      0|            array_bitset_container_union(
 1269|      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)
  |  |  ------------------
  ------------------
 1270|      0|            *result_type = BITSET_CONTAINER_TYPE;  // never array
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1271|      0|            return c1;
 1272|       |
 1273|    616|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    616|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    616|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    616|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1273:9): [True: 616, False: 6.51k]
  ------------------
 1274|       |            // c1 is an array, so no in-place possible
 1275|    616|            result = bitset_container_create();
 1276|    616|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    616|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1277|    616|            array_bitset_container_union(const_CAST_array(c1),
  ------------------
  |  |   55|    616|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    616|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1278|    616|                                         const_CAST_bitset(c2),
  ------------------
  |  |   53|    616|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    616|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1279|    616|                                         CAST_bitset(result));
  ------------------
  |  |   52|    616|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    616|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1280|    616|            return result;
 1281|       |
 1282|      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 (1282:9): [True: 0, False: 7.12k]
  ------------------
 1283|      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 (1283:17): [True: 0, False: 0]
  ------------------
 1284|      0|                result = run_container_create();
 1285|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1286|      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)
  |  |  ------------------
  ------------------
 1287|      0|                return result;
 1288|      0|            }
 1289|      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)
  |  |  ------------------
  ------------------
 1290|      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)
  |  |  ------------------
  ------------------
 1291|      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)
  |  |  ------------------
  ------------------
 1292|      0|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1293|      0|            return c1;
 1294|       |
 1295|    590|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    590|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    590|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1295:9): [True: 590, False: 6.53k]
  ------------------
 1296|    590|            if (run_container_is_full(const_CAST_run(c1))) {
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1296:17): [True: 0, False: 590]
  ------------------
 1297|      0|                *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
 1298|      0|                return c1;
 1299|      0|            }
 1300|    590|            result = bitset_container_create();
 1301|    590|            run_bitset_container_union(
 1302|    590|                const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   53|    590|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2), CAST_bitset(result));
  ------------------
  |  |   52|    590|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1303|    590|            *result_type = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1304|    590|            return result;
 1305|       |
 1306|    599|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    599|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    599|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    599|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1306:9): [True: 599, False: 6.52k]
  ------------------
 1307|    599|            result = run_container_create();
 1308|    599|            array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    599|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    599|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_union(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    599|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    599|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1309|    599|                                      CAST_run(result));
  ------------------
  |  |   77|    599|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    599|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1310|    599|            result = convert_run_to_efficient_container_and_free(
 1311|    599|                CAST_run(result), result_type);
  ------------------
  |  |   77|    599|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    599|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1312|    599|            return result;
 1313|       |
 1314|    251|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    251|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    251|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    251|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1314:9): [True: 251, False: 6.87k]
  ------------------
 1315|    251|            array_run_container_inplace_union(const_CAST_array(c2),
  ------------------
  |  |   55|    251|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    251|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1316|    251|                                              CAST_run(c1));
  ------------------
  |  |   77|    251|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    251|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1317|    251|            c1 = convert_run_to_efficient_container(CAST_run(c1), result_type);
  ------------------
  |  |   77|    251|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    251|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1318|    251|            return c1;
 1319|       |
 1320|      0|        default:
  ------------------
  |  Branch (1320:9): [True: 0, False: 7.12k]
  ------------------
 1321|      0|            assert(false);
 1322|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1323|      0|            return NULL;
 1324|  7.12k|    }
 1325|  7.12k|}
roaring.c:container_xor:
 1457|  7.01k|                                         uint8_t *result_type) {
 1458|  7.01k|    c1 = container_unwrap_shared(c1, &type1);
 1459|  7.01k|    c2 = container_unwrap_shared(c2, &type2);
 1460|  7.01k|    container_t *result = NULL;
 1461|  7.01k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  7.01k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1462|      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 (1462:9): [True: 0, False: 7.01k]
  ------------------
 1463|      0|            *result_type =
 1464|      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 (1464:17): [True: 0, False: 0]
  ------------------
 1465|      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)
  |  |  ------------------
  ------------------
 1466|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1467|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1468|      0|            return result;
 1469|       |
 1470|  3.40k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.40k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1470:9): [True: 3.40k, False: 3.61k]
  ------------------
 1471|  3.40k|            *result_type =
 1472|  3.40k|                array_array_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1472:17): [True: 17, False: 3.38k]
  ------------------
 1473|  3.40k|                                          const_CAST_array(c2), &result)
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1474|  3.40k|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     17|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1475|  3.40k|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  6.78k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1476|  3.40k|            return result;
 1477|       |
 1478|    624|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    624|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1478:9): [True: 624, False: 6.39k]
  ------------------
 1479|    624|            *result_type = (uint8_t)run_run_container_xor(
 1480|    624|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1481|    624|            return result;
 1482|       |
 1483|      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 (1483:9): [True: 0, False: 7.01k]
  ------------------
 1484|      0|            *result_type =
 1485|      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 (1485:17): [True: 0, False: 0]
  ------------------
 1486|      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)
  |  |  ------------------
  ------------------
 1487|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1488|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1489|      0|            return result;
 1490|       |
 1491|    572|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    572|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    572|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1491:9): [True: 572, False: 6.44k]
  ------------------
 1492|    572|            *result_type =
 1493|    572|                array_bitset_container_xor(const_CAST_array(c1),
  ------------------
  |  |   55|    572|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1493:17): [True: 524, False: 48]
  ------------------
 1494|    572|                                           const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    572|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1495|    572|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    524|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1496|    572|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    620|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1497|    572|            return result;
 1498|       |
 1499|      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 (1499:9): [True: 0, False: 7.01k]
  ------------------
 1500|      0|            *result_type =
 1501|      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 (1501:17): [True: 0, False: 0]
  ------------------
 1502|      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)
  |  |  ------------------
  ------------------
 1503|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1504|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1505|      0|            return result;
 1506|       |
 1507|    590|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    590|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    590|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1507:9): [True: 590, False: 6.42k]
  ------------------
 1508|    590|            *result_type =
 1509|    590|                run_bitset_container_xor(const_CAST_run(c1),
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1509:17): [True: 545, False: 45]
  ------------------
 1510|    590|                                         const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    590|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1511|    590|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    545|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1512|    590|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    635|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1513|    590|            return result;
 1514|       |
 1515|    717|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    717|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    717|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    717|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1515:9): [True: 717, False: 6.29k]
  ------------------
 1516|    717|            *result_type = (uint8_t)array_run_container_xor(
 1517|    717|                const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   55|    717|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    717|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1518|    717|            return result;
 1519|       |
 1520|  1.11k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.11k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.11k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1520:9): [True: 1.11k, False: 5.90k]
  ------------------
 1521|  1.11k|            *result_type = (uint8_t)array_run_container_xor(
 1522|  1.11k|                const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   55|  1.11k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1), &result);
  ------------------
  |  |   78|  1.11k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1523|  1.11k|            return result;
 1524|       |
 1525|      0|        default:
  ------------------
  |  Branch (1525:9): [True: 0, False: 7.01k]
  ------------------
 1526|      0|            assert(false);
 1527|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1528|      0|            return NULL;  // unreached
 1529|  7.01k|    }
 1530|  7.01k|}
roaring.c:container_ixor:
 1673|  60.4k|                                          uint8_t *result_type) {
 1674|  60.4k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1675|  60.4k|    c2 = container_unwrap_shared(c2, &type2);
 1676|  60.4k|    container_t *result = NULL;
 1677|  60.4k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  60.4k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1678|  1.41k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  1.41k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.41k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.41k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1678:9): [True: 1.41k, False: 59.0k]
  ------------------
 1679|  1.41k|            *result_type = bitset_bitset_container_ixor(
  ------------------
  |  Branch (1679:28): [True: 0, False: 1.41k]
  ------------------
 1680|  1.41k|                               CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   52|  1.41k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|  1.41k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1681|  1.41k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1682|  1.41k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  2.83k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1683|  1.41k|            return result;
 1684|       |
 1685|  5.41k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  5.41k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.41k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  5.41k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1685:9): [True: 5.41k, False: 55.0k]
  ------------------
 1686|  5.41k|            *result_type = array_array_container_ixor(
  ------------------
  |  Branch (1686:28): [True: 0, False: 5.41k]
  ------------------
 1687|  5.41k|                               CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   54|  5.41k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  5.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  5.41k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1688|  5.41k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1689|  5.41k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  10.8k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1690|  5.41k|            return result;
 1691|       |
 1692|  53.1k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  53.1k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  53.1k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  53.1k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1692:9): [True: 53.1k, False: 7.34k]
  ------------------
 1693|  53.1k|            *result_type = (uint8_t)run_run_container_ixor(
 1694|  53.1k|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|  53.1k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  53.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|  53.1k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  53.1k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1695|  53.1k|            return result;
 1696|       |
 1697|      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 (1697:9): [True: 0, False: 60.4k]
  ------------------
 1698|      0|            *result_type = bitset_array_container_ixor(
  ------------------
  |  Branch (1698:28): [True: 0, False: 0]
  ------------------
 1699|      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)
  |  |  ------------------
  ------------------
 1700|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1701|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1702|      0|            return result;
 1703|       |
 1704|    132|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    132|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    132|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    132|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1704:9): [True: 132, False: 60.3k]
  ------------------
 1705|    132|            *result_type = array_bitset_container_ixor(
  ------------------
  |  Branch (1705:28): [True: 0, False: 132]
  ------------------
 1706|    132|                               CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   54|    132|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    132|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_array(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    132|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    132|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1707|    132|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1708|    132|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    264|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1709|    132|            return result;
 1710|       |
 1711|     68|        case CONTAINER_PAIR(BITSET, RUN):
  ------------------
  |  |   65|     68|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     68|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     68|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1711:9): [True: 68, False: 60.4k]
  ------------------
 1712|     68|            *result_type = bitset_run_container_ixor(
  ------------------
  |  Branch (1712:28): [True: 0, False: 68]
  ------------------
 1713|     68|                               CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   52|     68|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     68|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_run(c2), &result)
  ------------------
  |  |   78|     68|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     68|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1714|     68|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1715|     68|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    136|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1716|       |
 1717|     68|            return result;
 1718|       |
 1719|     16|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|     16|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     16|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|     16|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1719:9): [True: 16, False: 60.4k]
  ------------------
 1720|     16|            *result_type = run_bitset_container_ixor(
  ------------------
  |  Branch (1720:28): [True: 0, False: 16]
  ------------------
 1721|     16|                               CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   77|     16|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     16|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_run(c1), const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|     16|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     16|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1722|     16|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1723|     16|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     32|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1724|     16|            return result;
 1725|       |
 1726|    257|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    257|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    257|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    257|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1726:9): [True: 257, False: 60.2k]
  ------------------
 1727|    257|            *result_type = (uint8_t)array_run_container_ixor(
 1728|    257|                CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   54|    257|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    257|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_array(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    257|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    257|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1729|    257|            return result;
 1730|       |
 1731|     47|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|     47|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     47|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     47|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1731:9): [True: 47, False: 60.4k]
  ------------------
 1732|     47|            *result_type = (uint8_t)run_array_container_ixor(
 1733|     47|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|     47|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     47|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|     47|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     47|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1734|     47|            return result;
 1735|       |
 1736|      0|        default:
  ------------------
  |  Branch (1736:9): [True: 0, False: 60.4k]
  ------------------
 1737|      0|            assert(false);
 1738|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1739|      0|            return NULL;
 1740|  60.4k|    }
 1741|  60.4k|}
roaring.c:container_andnot:
 1793|  7.01k|                                            uint8_t *result_type) {
 1794|  7.01k|    c1 = container_unwrap_shared(c1, &type1);
 1795|  7.01k|    c2 = container_unwrap_shared(c2, &type2);
 1796|  7.01k|    container_t *result = NULL;
 1797|  7.01k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  7.01k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1798|      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 (1798:9): [True: 0, False: 7.01k]
  ------------------
 1799|      0|            *result_type =
 1800|      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 (1800:17): [True: 0, False: 0]
  ------------------
 1801|      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)
  |  |  ------------------
  ------------------
 1802|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1803|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1804|      0|            return result;
 1805|       |
 1806|  3.40k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.40k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1806:9): [True: 3.40k, False: 3.61k]
  ------------------
 1807|  3.40k|            result = array_container_create();
 1808|  3.40k|            array_array_container_andnot(
 1809|  3.40k|                const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2), CAST_array(result));
  ------------------
  |  |   54|  3.40k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1810|  3.40k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1811|  3.40k|            return result;
 1812|       |
 1813|    624|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    624|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1813:9): [True: 624, False: 6.39k]
  ------------------
 1814|    624|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1814:17): [True: 2, False: 622]
  ------------------
 1815|      2|                result = array_container_create();
 1816|      2|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      2|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1817|      2|                return result;
 1818|      2|            }
 1819|    622|            *result_type = (uint8_t)run_run_container_andnot(
 1820|    622|                const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    622|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    622|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    622|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    622|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1821|    622|            return result;
 1822|       |
 1823|      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 (1823:9): [True: 0, False: 7.01k]
  ------------------
 1824|      0|            *result_type =
 1825|      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 (1825:17): [True: 0, False: 0]
  ------------------
 1826|      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)
  |  |  ------------------
  ------------------
 1827|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1828|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1829|      0|            return result;
 1830|       |
 1831|    572|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    572|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    572|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1831:9): [True: 572, False: 6.44k]
  ------------------
 1832|    572|            result = array_container_create();
 1833|    572|            array_bitset_container_andnot(const_CAST_array(c1),
  ------------------
  |  |   55|    572|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1834|    572|                                          const_CAST_bitset(c2),
  ------------------
  |  |   53|    572|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1835|    572|                                          CAST_array(result));
  ------------------
  |  |   54|    572|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1836|    572|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1837|    572|            return result;
 1838|       |
 1839|      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 (1839:9): [True: 0, False: 7.01k]
  ------------------
 1840|      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 (1840:17): [True: 0, False: 0]
  ------------------
 1841|      0|                result = array_container_create();
 1842|      0|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1843|      0|                return result;
 1844|      0|            }
 1845|      0|            *result_type =
 1846|      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 (1846:17): [True: 0, False: 0]
  ------------------
 1847|      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)
  |  |  ------------------
  ------------------
 1848|      0|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1849|      0|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1850|      0|            return result;
 1851|       |
 1852|    590|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    590|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    590|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (1852:9): [True: 590, False: 6.42k]
  ------------------
 1853|    590|            *result_type =
 1854|    590|                run_bitset_container_andnot(const_CAST_run(c1),
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1854:17): [True: 0, False: 590]
  ------------------
 1855|    590|                                            const_CAST_bitset(c2), &result)
  ------------------
  |  |   53|    590|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1856|    590|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1857|    590|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.18k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1858|    590|            return result;
 1859|       |
 1860|    717|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    717|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    717|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    717|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1860:9): [True: 717, False: 6.29k]
  ------------------
 1861|    717|            if (run_container_is_full(const_CAST_run(c2))) {
  ------------------
  |  |   78|    717|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (1861:17): [True: 34, False: 683]
  ------------------
 1862|     34|                result = array_container_create();
 1863|     34|                *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     34|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1864|     34|                return result;
 1865|     34|            }
 1866|    683|            result = array_container_create();
 1867|    683|            array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   55|    683|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    683|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_andnot(const_CAST_array(c1), const_CAST_run(c2),
  ------------------
  |  |   78|    683|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    683|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1868|    683|                                       CAST_array(result));
  ------------------
  |  |   54|    683|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    683|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1869|    683|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    683|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1870|    683|            return result;
 1871|       |
 1872|  1.11k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.11k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.11k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1872:9): [True: 1.11k, False: 5.90k]
  ------------------
 1873|  1.11k|            *result_type = (uint8_t)run_array_container_andnot(
 1874|  1.11k|                const_CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   78|  1.11k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(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)
  |  |  ------------------
  ------------------
 1875|  1.11k|            return result;
 1876|       |
 1877|      0|        default:
  ------------------
  |  Branch (1877:9): [True: 0, False: 7.01k]
  ------------------
 1878|      0|            assert(false);
 1879|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1880|      0|            return NULL;  // unreached
 1881|  7.01k|    }
 1882|  7.01k|}
roaring.c:container_iandnot:
 1897|  6.70k|                                             uint8_t *result_type) {
 1898|  6.70k|    c1 = get_writable_copy_if_shared(c1, &type1);
 1899|  6.70k|    c2 = container_unwrap_shared(c2, &type2);
 1900|  6.70k|    container_t *result = NULL;
 1901|  6.70k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  6.70k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
 1902|      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 (1902:9): [True: 0, False: 6.70k]
  ------------------
 1903|      0|            *result_type = bitset_bitset_container_iandnot(
  ------------------
  |  Branch (1903:28): [True: 0, False: 0]
  ------------------
 1904|      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)
  |  |  ------------------
  ------------------
 1905|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1906|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1907|      0|            return result;
 1908|       |
 1909|  4.42k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  4.42k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.42k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.42k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1909:9): [True: 4.42k, False: 2.28k]
  ------------------
 1910|  4.42k|            array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   54|  4.42k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_array_container_iandnot(CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  4.42k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1911|  4.42k|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.42k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1912|  4.42k|            return c1;
 1913|       |
 1914|    401|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    401|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    401|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    401|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1914:9): [True: 401, False: 6.30k]
  ------------------
 1915|    401|            *result_type = (uint8_t)run_run_container_iandnot(
 1916|    401|                CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   77|    401|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    401|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_run(c2), &result);
  ------------------
  |  |   78|    401|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    401|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1917|    401|            return result;
 1918|       |
 1919|  1.13k|        case CONTAINER_PAIR(BITSET, ARRAY):
  ------------------
  |  |   65|  1.13k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  1.13k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.13k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1919:9): [True: 1.13k, False: 5.57k]
  ------------------
 1920|  1.13k|            *result_type = bitset_array_container_iandnot(
  ------------------
  |  Branch (1920:28): [True: 926, False: 204]
  ------------------
 1921|  1.13k|                               CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   52|  1.13k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.13k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                                             CAST_bitset(c1), const_CAST_array(c2), &result)
  ------------------
  |  |   55|  1.13k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.13k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1922|  1.13k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|    926|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1923|  1.13k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.33k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1924|  1.13k|            return result;
 1925|       |
 1926|      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 (1926:9): [True: 0, False: 6.70k]
  ------------------
 1927|      0|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1928|      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)
  |  |  ------------------
  ------------------
 1929|      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)
  |  |  ------------------
  ------------------
 1930|      0|            return c1;
 1931|       |
 1932|      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 (1932:9): [True: 0, False: 6.70k]
  ------------------
 1933|      0|            *result_type = bitset_run_container_iandnot(
  ------------------
  |  Branch (1933:28): [True: 0, False: 0]
  ------------------
 1934|      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)
  |  |  ------------------
  ------------------
 1935|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1936|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1937|      0|            return result;
 1938|       |
 1939|      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 (1939:9): [True: 0, False: 6.70k]
  ------------------
 1940|      0|            *result_type = run_bitset_container_iandnot(
  ------------------
  |  Branch (1940:28): [True: 0, False: 0]
  ------------------
 1941|      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)
  |  |  ------------------
  ------------------
 1942|      0|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
 1943|      0|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|      0|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1944|      0|            return result;
 1945|       |
 1946|     42|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|     42|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|     42|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|     42|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (1946:9): [True: 42, False: 6.66k]
  ------------------
 1947|     42|            *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     42|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 1948|     42|            array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   54|     42|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     42|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          array_run_container_iandnot(CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|     42|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|     42|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1949|     42|            return c1;
 1950|       |
 1951|    710|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    710|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    710|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    710|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (1951:9): [True: 710, False: 5.99k]
  ------------------
 1952|    710|            *result_type = (uint8_t)run_array_container_iandnot(
 1953|    710|                CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   77|    710|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    710|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              CAST_run(c1), const_CAST_array(c2), &result);
  ------------------
  |  |   55|    710|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    710|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1954|    710|            return result;
 1955|       |
 1956|      0|        default:
  ------------------
  |  Branch (1956:9): [True: 0, False: 6.70k]
  ------------------
 1957|      0|            assert(false);
 1958|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1959|      0|            return NULL;
 1960|  6.70k|    }
 1961|  6.70k|}
roaring.c:container_shrink_to_fit:
  279|  7.12k|static inline int container_shrink_to_fit(container_t *c, uint8_t type) {
  280|       |    // Other bitmaps, maybe on other threads, read a shared container's array:
  281|       |    // only its sole holder may move it.
  282|  7.12k|    if (type == SHARED_CONTAINER_TYPE &&
  ------------------
  |  |   51|  14.2k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (282:9): [True: 0, False: 7.12k]
  ------------------
  283|      0|        !croaring_refcount_is_unique(&CAST_shared(c)->counter)) {
  ------------------
  |  |   79|      0|#define CAST_shared(c) CAST(shared_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (283:9): [True: 0, False: 0]
  ------------------
  284|      0|        return 0;
  285|      0|    }
  286|  7.12k|    c = container_mutable_unwrap_shared(c, &type);
  287|  7.12k|    switch (type) {
  ------------------
  |  Branch (287:13): [True: 7.12k, False: 0]
  ------------------
  288|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (288:9): [True: 0, False: 7.12k]
  ------------------
  289|      0|            return 0;  // no shrinking possible
  290|  4.78k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.78k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (290:9): [True: 4.78k, False: 2.34k]
  ------------------
  291|  4.78k|            return array_container_shrink_to_fit(CAST_array(c));
  ------------------
  |  |   54|  4.78k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.78k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  292|  2.34k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.34k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (292:9): [True: 2.34k, False: 4.78k]
  ------------------
  293|  2.34k|            return run_container_shrink_to_fit(CAST_run(c));
  ------------------
  |  |   77|  2.34k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  2.34k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  294|  7.12k|    }
  295|  7.12k|    assert(false);
  296|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  297|      0|    return 0;  // unreached
  298|  7.12k|}
roaring.c:container_iterate:
 1970|  62.4k|                                     void *ptr) {
 1971|  62.4k|    c = container_unwrap_shared(c, &type);
 1972|  62.4k|    switch (type) {
 1973|  1.56k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.56k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (1973:9): [True: 1.56k, False: 60.9k]
  ------------------
 1974|  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)
  |  |  ------------------
  ------------------
 1975|  1.56k|                                            iterator, ptr);
 1976|  7.27k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.27k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (1976:9): [True: 7.27k, False: 55.1k]
  ------------------
 1977|  7.27k|            return array_container_iterate(const_CAST_array(c), base, iterator,
  ------------------
  |  |   55|  7.27k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.27k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1978|  7.27k|                                           ptr);
 1979|  53.6k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  53.6k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1979:9): [True: 53.6k, False: 8.84k]
  ------------------
 1980|  53.6k|            return run_container_iterate(const_CAST_run(c), base, iterator,
  ------------------
  |  |   78|  53.6k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  53.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1981|  53.6k|                                         ptr);
 1982|      0|        default:
  ------------------
  |  Branch (1982:9): [True: 0, False: 62.4k]
  ------------------
 1983|      0|            assert(false);
 1984|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1985|  62.4k|    }
 1986|  62.4k|    assert(false);
 1987|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 1988|      0|    return false;
 1989|  62.4k|}
roaring.c:container_maximum:
 2171|  14.1k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  14.1k|    c = container_unwrap_shared(c, &type);
 2173|  14.1k|    switch (type) {
 2174|  2.37k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  2.37k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 2.37k, False: 11.7k]
  ------------------
 2175|  2.37k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  2.37k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.37k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  10.4k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  10.4k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 10.4k, False: 3.70k]
  ------------------
 2177|  10.4k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  10.4k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  10.4k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2178|  1.32k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.32k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2178:9): [True: 1.32k, False: 12.8k]
  ------------------
 2179|  1.32k|            return run_container_maximum(const_CAST_run(c));
  ------------------
  |  |   78|  1.32k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.32k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2180|      0|        default:
  ------------------
  |  Branch (2180:9): [True: 0, False: 14.1k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  14.1k|    }
 2184|  14.1k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  14.1k|}
roaring.c:container_equals:
  626|  79.0k|                                    const container_t *c2, uint8_t type2) {
  627|  79.0k|    c1 = container_unwrap_shared(c1, &type1);
  628|  79.0k|    c2 = container_unwrap_shared(c2, &type2);
  629|  79.0k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  79.0k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  630|  66.6k|        case CONTAINER_PAIR(BITSET, BITSET):
  ------------------
  |  |   65|  66.6k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  66.6k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  66.6k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (630:9): [True: 66.6k, False: 12.3k]
  ------------------
  631|  66.6k|            return bitset_container_equals(const_CAST_bitset(c1),
  ------------------
  |  |   53|  66.6k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  632|  66.6k|                                           const_CAST_bitset(c2));
  ------------------
  |  |   53|  66.6k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  633|       |
  634|      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 (634:9): [True: 0, False: 79.0k]
  ------------------
  635|      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)
  |  |  ------------------
  ------------------
  636|      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)
  |  |  ------------------
  ------------------
  637|       |
  638|      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 (638:9): [True: 0, False: 79.0k]
  ------------------
  639|      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)
  |  |  ------------------
  ------------------
  640|      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)
  |  |  ------------------
  ------------------
  641|       |
  642|      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 (642:9): [True: 0, False: 79.0k]
  ------------------
  643|       |            // java would always return false?
  644|      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)
  |  |  ------------------
  ------------------
  645|      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)
  |  |  ------------------
  ------------------
  646|       |
  647|    371|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    371|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    371|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    371|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (647:9): [True: 371, False: 78.6k]
  ------------------
  648|       |            // java would always return false?
  649|    371|            return array_container_equal_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|    371|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    371|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  650|    371|                                                const_CAST_bitset(c2));
  ------------------
  |  |   53|    371|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    371|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  651|       |
  652|    581|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    581|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    581|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    581|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (652:9): [True: 581, False: 78.4k]
  ------------------
  653|    581|            return run_container_equals_array(const_CAST_run(c2),
  ------------------
  |  |   78|    581|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    581|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  654|    581|                                              const_CAST_array(c1));
  ------------------
  |  |   55|    581|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    581|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  655|       |
  656|    236|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    236|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    236|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    236|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (656:9): [True: 236, False: 78.8k]
  ------------------
  657|    236|            return run_container_equals_array(const_CAST_run(c1),
  ------------------
  |  |   78|    236|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    236|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  658|    236|                                              const_CAST_array(c2));
  ------------------
  |  |   55|    236|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    236|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  659|       |
  660|  11.0k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  11.0k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  11.0k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  11.0k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (660:9): [True: 11.0k, False: 67.9k]
  ------------------
  661|  11.0k|            return array_container_equals(const_CAST_array(c1),
  ------------------
  |  |   55|  11.0k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  11.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  662|  11.0k|                                          const_CAST_array(c2));
  ------------------
  |  |   55|  11.0k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  11.0k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  663|       |
  664|    134|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    134|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    134|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    134|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (664:9): [True: 134, False: 78.9k]
  ------------------
  665|    134|            return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    134|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    134|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                          return run_container_equals(const_CAST_run(c1), const_CAST_run(c2));
  ------------------
  |  |   78|    134|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    134|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  666|       |
  667|      0|        default:
  ------------------
  |  Branch (667:9): [True: 0, False: 79.0k]
  ------------------
  668|      0|            assert(false);
  669|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  670|      0|            return false;
  671|  79.0k|    }
  672|  79.0k|}
roaring.c:container_is_subset:
  679|  11.9k|                                       const container_t *c2, uint8_t type2) {
  680|  11.9k|    c1 = container_unwrap_shared(c1, &type1);
  681|  11.9k|    c2 = container_unwrap_shared(c2, &type2);
  682|  11.9k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  11.9k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  683|      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 (683:9): [True: 0, False: 11.9k]
  ------------------
  684|      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)
  |  |  ------------------
  ------------------
  685|      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)
  |  |  ------------------
  ------------------
  686|       |
  687|      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 (687:9): [True: 0, False: 11.9k]
  ------------------
  688|      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)
  |  |  ------------------
  ------------------
  689|      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)
  |  |  ------------------
  ------------------
  690|       |
  691|      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 (691:9): [True: 0, False: 11.9k]
  ------------------
  692|      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)
  |  |  ------------------
  ------------------
  693|      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)
  |  |  ------------------
  ------------------
  694|       |
  695|      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 (695:9): [True: 0, False: 11.9k]
  ------------------
  696|      0|            return false;  // by construction, size(c1) > size(c2)
  697|       |
  698|  2.26k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.26k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.26k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.26k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (698:9): [True: 2.26k, False: 9.72k]
  ------------------
  699|  2.26k|            return array_container_is_subset_bitset(const_CAST_array(c1),
  ------------------
  |  |   55|  2.26k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.26k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  700|  2.26k|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.26k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.26k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  701|       |
  702|  2.02k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  2.02k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.02k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.02k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (702:9): [True: 2.02k, False: 9.96k]
  ------------------
  703|  2.02k|            return array_container_is_subset_run(const_CAST_array(c1),
  ------------------
  |  |   55|  2.02k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.02k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  704|  2.02k|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|  2.02k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.02k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  705|       |
  706|    353|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|    353|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    353|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    353|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (706:9): [True: 353, False: 11.6k]
  ------------------
  707|    353|            return run_container_is_subset_array(const_CAST_run(c1),
  ------------------
  |  |   78|    353|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    353|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  708|    353|                                                 const_CAST_array(c2));
  ------------------
  |  |   55|    353|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    353|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  709|       |
  710|  7.12k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  7.12k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  7.12k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  7.12k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (710:9): [True: 7.12k, False: 4.86k]
  ------------------
  711|  7.12k|            return array_container_is_subset(const_CAST_array(c1),
  ------------------
  |  |   55|  7.12k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.12k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  712|  7.12k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  7.12k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.12k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  713|       |
  714|    227|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    227|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    227|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    227|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (714:9): [True: 227, False: 11.7k]
  ------------------
  715|    227|            return run_container_is_subset(const_CAST_run(c1),
  ------------------
  |  |   78|    227|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    227|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  716|    227|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    227|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    227|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  717|       |
  718|      0|        default:
  ------------------
  |  Branch (718:9): [True: 0, False: 11.9k]
  ------------------
  719|      0|            assert(false);
  720|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  721|      0|            return false;
  722|  11.9k|    }
  723|  11.9k|}
roaring.c:container_range_of_ones:
  308|  83.7k|                                                   uint8_t *result_type) {
  309|  83.7k|    assert(range_end >= range_start);
  310|  83.7k|    uint64_t cardinality = range_end - range_start + 1;
  311|  83.7k|    if (cardinality <= 2) {
  ------------------
  |  Branch (311:9): [True: 133, False: 83.6k]
  ------------------
  312|    133|        *result_type = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|    133|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  313|    133|        return array_container_create_range(range_start, range_end);
  314|  83.6k|    } else {
  315|  83.6k|        *result_type = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  83.6k|#define RUN_CONTAINER_TYPE 3
  ------------------
  316|  83.6k|        return run_container_create_range(range_start, range_end);
  317|  83.6k|    }
  318|  83.7k|}
roaring.c:container_inot_range:
 2111|  7.40k|                                                uint8_t *result_type) {
 2112|  7.40k|    c = get_writable_copy_if_shared(c, &type);
 2113|  7.40k|    container_t *result = NULL;
 2114|  7.40k|    switch (type) {
 2115|  1.22k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.22k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2115:9): [True: 1.22k, False: 6.17k]
  ------------------
 2116|  1.22k|            *result_type = bitset_container_negation_range_inplace(
  ------------------
  |  Branch (2116:28): [True: 1.20k, False: 19]
  ------------------
 2117|  1.22k|                               CAST_bitset(c), range_start, range_end, &result)
  ------------------
  |  |   52|  1.22k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.22k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2118|  1.22k|                               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|  1.20k|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2119|  1.22k|                               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.24k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2120|  1.22k|            return result;
 2121|  4.49k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.49k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2121:9): [True: 4.49k, False: 2.90k]
  ------------------
 2122|  4.49k|            *result_type = (uint8_t)array_container_negation_range_to_any(
 2123|  4.49k|                CAST_array(c), range_start, range_end, &result);
  ------------------
  |  |   54|  4.49k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2124|  4.49k|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|  4.49k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  4.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2125|  4.49k|            return result;
 2126|  1.68k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.68k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2126:9): [True: 1.68k, False: 5.71k]
  ------------------
 2127|  1.68k|            *result_type = (uint8_t)run_container_negation_range_inplace(
 2128|  1.68k|                CAST_run(c), range_start, range_end, &result);
  ------------------
  |  |   77|  1.68k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.68k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2129|  1.68k|            return result;
 2130|       |
 2131|      0|        default:
  ------------------
  |  Branch (2131:9): [True: 0, False: 7.40k]
  ------------------
 2132|      0|            assert(false);
 2133|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2134|  7.40k|    }
 2135|  7.40k|    assert(false);
 2136|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2137|      0|    return NULL;
 2138|  7.40k|}
roaring.c:container_inot:
 2078|  6.60k|                                          uint8_t *result_type) {
 2079|  6.60k|    c = get_writable_copy_if_shared(c, &type);
 2080|  6.60k|    container_t *result = NULL;
 2081|  6.60k|    switch (type) {
 2082|     36|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|     36|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2082:9): [True: 36, False: 6.57k]
  ------------------
 2083|     36|            *result_type =
 2084|     36|                bitset_container_negation_inplace(CAST_bitset(c), &result)
  ------------------
  |  |   52|     36|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     36|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  |  Branch (2084:17): [True: 20, False: 16]
  ------------------
 2085|     36|                    ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     20|#define BITSET_CONTAINER_TYPE 1
  ------------------
 2086|     36|                    : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|     52|#define ARRAY_CONTAINER_TYPE 2
  ------------------
 2087|     36|            return result;
 2088|    179|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|    179|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2088:9): [True: 179, False: 6.42k]
  ------------------
 2089|       |            // will never be inplace
 2090|    179|            *result_type = (uint8_t)array_container_negation_range_to_any(
 2091|    179|                CAST_array(c), 0, 1 << 16, &result);
  ------------------
  |  |   54|    179|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    179|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2092|    179|            array_container_free(CAST_array(c));
  ------------------
  |  |   54|    179|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    179|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2093|    179|            return result;
 2094|  6.39k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  6.39k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2094:9): [True: 6.39k, False: 215]
  ------------------
 2095|  6.39k|            *result_type =
 2096|  6.39k|                (uint8_t)run_container_negation_inplace(CAST_run(c), &result);
  ------------------
  |  |   77|  6.39k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  6.39k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2097|  6.39k|            return result;
 2098|       |
 2099|      0|        default:
  ------------------
  |  Branch (2099:9): [True: 0, False: 6.60k]
  ------------------
 2100|      0|            assert(false);
 2101|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2102|  6.60k|    }
 2103|  6.60k|    assert(false);
 2104|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2105|      0|    return NULL;
 2106|  6.60k|}
roaring.c:container_unwrap_shared:
  106|  1.12M|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  1.12M|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  1.12M|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 1.12M]
  ------------------
  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.12M|    } else {
  112|  1.12M|        return candidate_shared_container;
  113|  1.12M|    }
  114|  1.12M|}
roaring.c:container_mutable_unwrap_shared:
  118|  7.12k|                                                           uint8_t *type) {
  119|  7.12k|    if (*type == SHARED_CONTAINER_TYPE) {  // the passed in container is shared
  ------------------
  |  |   51|  7.12k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (119:9): [True: 0, False: 7.12k]
  ------------------
  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|  7.12k|    } else {
  124|  7.12k|        return c;  // wasn't shared, so return as-is
  125|  7.12k|    }
  126|  7.12k|}
roaring.c:container_rank:
 2209|  7.12k|                                 uint16_t x) {
 2210|  7.12k|    c = container_unwrap_shared(c, &type);
 2211|  7.12k|    switch (type) {
 2212|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2212:9): [True: 0, False: 7.12k]
  ------------------
 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|  4.78k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.78k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2214:9): [True: 4.78k, False: 2.34k]
  ------------------
 2215|  4.78k|            return array_container_rank(const_CAST_array(c), x);
  ------------------
  |  |   55|  4.78k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.78k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2216|  2.34k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.34k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2216:9): [True: 2.34k, False: 4.78k]
  ------------------
 2217|  2.34k|            return run_container_rank(const_CAST_run(c), x);
  ------------------
  |  |   78|  2.34k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.34k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2218|      0|        default:
  ------------------
  |  Branch (2218:9): [True: 0, False: 7.12k]
  ------------------
 2219|      0|            assert(false);
 2220|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2221|  7.12k|    }
 2222|  7.12k|    assert(false);
 2223|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2224|      0|    return false;
 2225|  7.12k|}
roaring.c:container_minimum:
 2189|  7.08k|static inline uint16_t container_minimum(const container_t *c, uint8_t type) {
 2190|  7.08k|    c = container_unwrap_shared(c, &type);
 2191|  7.08k|    switch (type) {
 2192|  1.17k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.17k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2192:9): [True: 1.17k, False: 5.91k]
  ------------------
 2193|  1.17k|            return bitset_container_minimum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.17k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.17k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2194|  4.55k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.55k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2194:9): [True: 4.55k, False: 2.53k]
  ------------------
 2195|  4.55k|            return array_container_minimum(const_CAST_array(c));
  ------------------
  |  |   55|  4.55k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.55k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2196|  1.36k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  1.36k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2196:9): [True: 1.36k, False: 5.72k]
  ------------------
 2197|  1.36k|            return run_container_minimum(const_CAST_run(c));
  ------------------
  |  |   78|  1.36k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.36k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2198|      0|        default:
  ------------------
  |  Branch (2198:9): [True: 0, False: 7.08k]
  ------------------
 2199|      0|            assert(false);
 2200|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2201|  7.08k|    }
 2202|  7.08k|    assert(false);
 2203|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2204|      0|    return false;
 2205|  7.08k|}
roaring.c:container_select:
 2150|  6.70k|                                    uint32_t *element) {
 2151|  6.70k|    c = container_unwrap_shared(c, &type);
 2152|  6.70k|    switch (type) {
 2153|      0|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2153:9): [True: 0, False: 6.70k]
  ------------------
 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|  4.41k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  4.41k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2156:9): [True: 4.41k, False: 2.28k]
  ------------------
 2157|  4.41k|            return array_container_select(const_CAST_array(c), start_rank, rank,
  ------------------
  |  |   55|  4.41k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.41k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2158|  4.41k|                                          element);
 2159|  2.28k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.28k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (2159:9): [True: 2.28k, False: 4.41k]
  ------------------
 2160|  2.28k|            return run_container_select(const_CAST_run(c), start_rank, rank,
  ------------------
  |  |   78|  2.28k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.28k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2161|  2.28k|                                        element);
 2162|      0|        default:
  ------------------
  |  Branch (2162:9): [True: 0, False: 6.70k]
  ------------------
 2163|      0|            assert(false);
 2164|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2165|  6.70k|    }
 2166|  6.70k|    assert(false);
 2167|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2168|      0|    return false;
 2169|  6.70k|}
roaring.c:container_intersect:
  871|  7.01k|                                       const container_t *c2, uint8_t type2) {
  872|  7.01k|    c1 = container_unwrap_shared(c1, &type1);
  873|  7.01k|    c2 = container_unwrap_shared(c2, &type2);
  874|  7.01k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  7.01k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  875|      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 (875:9): [True: 0, False: 7.01k]
  ------------------
  876|      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)
  |  |  ------------------
  ------------------
  877|      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)
  |  |  ------------------
  ------------------
  878|       |
  879|  3.40k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  3.40k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  3.40k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (879:9): [True: 3.40k, False: 3.61k]
  ------------------
  880|  3.40k|            return array_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  881|  3.40k|                                             const_CAST_array(c2));
  ------------------
  |  |   55|  3.40k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  3.40k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  882|       |
  883|    624|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|    624|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    624|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (883:9): [True: 624, False: 6.39k]
  ------------------
  884|    624|            return run_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  885|    624|                                           const_CAST_run(c2));
  ------------------
  |  |   78|    624|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    624|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  886|       |
  887|      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 (887:9): [True: 0, False: 7.01k]
  ------------------
  888|      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)
  |  |  ------------------
  ------------------
  889|      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)
  |  |  ------------------
  ------------------
  890|       |
  891|    572|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|    572|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    572|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    572|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (891:9): [True: 572, False: 6.44k]
  ------------------
  892|    572|            return array_bitset_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    572|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  893|    572|                                                    const_CAST_bitset(c2));
  ------------------
  |  |   53|    572|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    572|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  894|       |
  895|      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 (895:9): [True: 0, False: 7.01k]
  ------------------
  896|      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)
  |  |  ------------------
  ------------------
  897|      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)
  |  |  ------------------
  ------------------
  898|       |
  899|    590|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|    590|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    590|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|    590|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (899:9): [True: 590, False: 6.42k]
  ------------------
  900|    590|            return run_bitset_container_intersect(const_CAST_run(c1),
  ------------------
  |  |   78|    590|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  901|    590|                                                  const_CAST_bitset(c2));
  ------------------
  |  |   53|    590|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    590|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  902|       |
  903|    717|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|    717|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|    717|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|    717|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (903:9): [True: 717, False: 6.29k]
  ------------------
  904|    717|            return array_run_container_intersect(const_CAST_array(c1),
  ------------------
  |  |   55|    717|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  905|    717|                                                 const_CAST_run(c2));
  ------------------
  |  |   78|    717|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    717|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  906|       |
  907|  1.11k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  1.11k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  1.11k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  1.11k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (907:9): [True: 1.11k, False: 5.90k]
  ------------------
  908|  1.11k|            return array_run_container_intersect(const_CAST_array(c2),
  ------------------
  |  |   55|  1.11k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  909|  1.11k|                                                 const_CAST_run(c1));
  ------------------
  |  |   78|  1.11k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.11k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  910|       |
  911|      0|        default:
  ------------------
  |  Branch (911:9): [True: 0, False: 7.01k]
  ------------------
  912|      0|            assert(false);
  913|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  914|      0|            return 0;
  915|  7.01k|    }
  916|  7.01k|}
roaring.c:container_and_cardinality:
  820|  28.0k|                                            uint8_t type2) {
  821|  28.0k|    c1 = container_unwrap_shared(c1, &type1);
  822|  28.0k|    c2 = container_unwrap_shared(c2, &type2);
  823|  28.0k|    switch (PAIR_CONTAINER_TYPES(type1, type2)) {
  ------------------
  |  |   62|  28.0k|#define PAIR_CONTAINER_TYPES(type1, type2) (4 * (type1) + (type2))
  ------------------
  824|      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 (824:9): [True: 0, False: 28.0k]
  ------------------
  825|      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)
  |  |  ------------------
  ------------------
  826|      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)
  |  |  ------------------
  ------------------
  827|       |
  828|  13.6k|        case CONTAINER_PAIR(ARRAY, ARRAY):
  ------------------
  |  |   65|  13.6k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  13.6k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  13.6k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (828:9): [True: 13.6k, False: 14.4k]
  ------------------
  829|  13.6k|            return array_container_intersection_cardinality(
  830|  13.6k|                const_CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  13.6k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  13.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_array(c2));
  ------------------
  |  |   55|  13.6k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  13.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  831|       |
  832|  2.49k|        case CONTAINER_PAIR(RUN, RUN):
  ------------------
  |  |   65|  2.49k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.49k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.49k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (832:9): [True: 2.49k, False: 25.5k]
  ------------------
  833|  2.49k|            return run_container_intersection_cardinality(const_CAST_run(c1),
  ------------------
  |  |   78|  2.49k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  834|  2.49k|                                                          const_CAST_run(c2));
  ------------------
  |  |   78|  2.49k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.49k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  835|       |
  836|      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 (836:9): [True: 0, False: 28.0k]
  ------------------
  837|      0|            return array_bitset_container_intersection_cardinality(
  838|      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)
  |  |  ------------------
  ------------------
  839|       |
  840|  2.28k|        case CONTAINER_PAIR(ARRAY, BITSET):
  ------------------
  |  |   65|  2.28k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.28k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.28k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (840:9): [True: 2.28k, False: 25.7k]
  ------------------
  841|  2.28k|            return array_bitset_container_intersection_cardinality(
  842|  2.28k|                const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   55|  2.28k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.28k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.28k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.28k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  843|       |
  844|      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 (844:9): [True: 0, False: 28.0k]
  ------------------
  845|      0|            return run_bitset_container_intersection_cardinality(
  846|      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)
  |  |  ------------------
  ------------------
  847|       |
  848|  2.36k|        case CONTAINER_PAIR(RUN, BITSET):
  ------------------
  |  |   65|  2.36k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.36k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   48|  2.36k|#define BITSET_CONTAINER_TYPE 1
  |  |  ------------------
  ------------------
  |  Branch (848:9): [True: 2.36k, False: 25.6k]
  ------------------
  849|  2.36k|            return run_bitset_container_intersection_cardinality(
  850|  2.36k|                const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   78|  2.36k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.36k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_run(c1), const_CAST_bitset(c2));
  ------------------
  |  |   53|  2.36k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.36k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  851|       |
  852|  2.86k|        case CONTAINER_PAIR(ARRAY, RUN):
  ------------------
  |  |   65|  2.86k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  2.86k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  2.86k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  ------------------
  |  Branch (852:9): [True: 2.86k, False: 25.1k]
  ------------------
  853|  2.86k|            return array_run_container_intersection_cardinality(
  854|  2.86k|                const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   55|  2.86k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.86k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c1), const_CAST_run(c2));
  ------------------
  |  |   78|  2.86k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.86k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  855|       |
  856|  4.44k|        case CONTAINER_PAIR(RUN, ARRAY):
  ------------------
  |  |   65|  4.44k|    (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   50|  4.44k|#define RUN_CONTAINER_TYPE 3
  |  |  ------------------
  |  |                   (4 * (name1##_CONTAINER_TYPE) + (name2##_CONTAINER_TYPE))
  |  |  ------------------
  |  |  |  |   49|  4.44k|#define ARRAY_CONTAINER_TYPE 2
  |  |  ------------------
  ------------------
  |  Branch (856:9): [True: 4.44k, False: 23.6k]
  ------------------
  857|  4.44k|            return array_run_container_intersection_cardinality(
  858|  4.44k|                const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   55|  4.44k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
                              const_CAST_array(c2), const_CAST_run(c1));
  ------------------
  |  |   78|  4.44k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  4.44k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  859|       |
  860|      0|        default:
  ------------------
  |  Branch (860:9): [True: 0, False: 28.0k]
  ------------------
  861|      0|            assert(false);
  862|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  863|      0|            return 0;
  864|  28.0k|    }
  865|  28.0k|}
roaring.c:container_contains_range:
  602|    540|) {
  603|    540|    c = container_unwrap_shared(c, &typecode);
  604|    540|    switch (typecode) {
  605|    247|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|    247|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (605:9): [True: 247, False: 293]
  ------------------
  606|    247|            return bitset_container_get_range(const_CAST_bitset(c), range_start,
  ------------------
  |  |   53|    247|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    247|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  607|    247|                                              range_end);
  608|    120|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|    120|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (608:9): [True: 120, False: 420]
  ------------------
  609|    120|            return array_container_contains_range(const_CAST_array(c),
  ------------------
  |  |   55|    120|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    120|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  610|    120|                                                  range_start, range_end);
  611|    173|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|    173|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (611:9): [True: 173, False: 367]
  ------------------
  612|    173|            return run_container_contains_range(const_CAST_run(c), range_start,
  ------------------
  |  |   78|    173|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|    173|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  613|    173|                                                range_end);
  614|      0|        default:
  ------------------
  |  Branch (614:9): [True: 0, False: 540]
  ------------------
  615|      0|            assert(false);
  616|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  617|      0|            return false;
  618|    540|    }
  619|    540|}
roaring_array.c:container_to_uint32_array:
  471|  62.3k|                                            uint8_t typecode, uint32_t base) {
  472|  62.3k|    c = container_unwrap_shared(c, &typecode);
  473|  62.3k|    switch (typecode) {
  ------------------
  |  Branch (473:13): [True: 62.3k, False: 0]
  ------------------
  474|  1.42k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.42k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (474:9): [True: 1.42k, False: 60.9k]
  ------------------
  475|  1.42k|            return bitset_container_to_uint32_array(output,
  476|  1.42k|                                                    const_CAST_bitset(c), base);
  ------------------
  |  |   53|  1.42k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  477|  6.70k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  6.70k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (477:9): [True: 6.70k, False: 55.6k]
  ------------------
  478|  6.70k|            return array_container_to_uint32_array(output, const_CAST_array(c),
  ------------------
  |  |   55|  6.70k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  6.70k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  479|  6.70k|                                                   base);
  480|  54.2k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  54.2k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (480:9): [True: 54.2k, False: 8.13k]
  ------------------
  481|  54.2k|            return run_container_to_uint32_array(output, const_CAST_run(c),
  ------------------
  |  |   78|  54.2k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  54.2k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  482|  54.2k|                                                 base);
  483|  62.3k|    }
  484|  62.3k|    assert(false);
  485|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  486|      0|    return 0;  // unreached
  487|  62.3k|}
roaring_array.c:container_unwrap_shared:
  106|   367k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|   367k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   367k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 367k]
  ------------------
  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|   367k|    } else {
  112|   367k|        return candidate_shared_container;
  113|   367k|    }
  114|   367k|}
roaring_array.c:get_container_type:
  129|   155k|static inline uint8_t get_container_type(const container_t *c, uint8_t type) {
  130|   155k|    if (type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|   155k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (130:9): [True: 0, False: 155k]
  ------------------
  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|   155k|    } else {
  133|   155k|        return type;
  134|   155k|    }
  135|   155k|}
roaring_array.c:container_size_in_bytes:
  409|   155k|                                              uint8_t typecode) {
  410|   155k|    c = container_unwrap_shared(c, &typecode);
  411|   155k|    switch (typecode) {
  ------------------
  |  Branch (411:13): [True: 155k, False: 0]
  ------------------
  412|   133k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|   133k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (412:9): [True: 133k, False: 22.5k]
  ------------------
  413|   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)
  |  |  ------------------
  ------------------
  414|  20.2k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  20.2k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (414:9): [True: 20.2k, False: 135k]
  ------------------
  415|  20.2k|            return array_container_size_in_bytes(const_CAST_array(c));
  ------------------
  |  |   55|  20.2k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  20.2k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  416|  2.34k|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|  2.34k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (416:9): [True: 2.34k, False: 153k]
  ------------------
  417|  2.34k|            return run_container_size_in_bytes(const_CAST_run(c));
  ------------------
  |  |   78|  2.34k|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  2.34k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  418|   155k|    }
  419|   155k|    assert(false);
  420|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  421|      0|    return 0;  // unreached
  422|   155k|}
roaring_array.c:container_get_cardinality:
  244|  74.3k|                                            uint8_t typecode) {
  245|  74.3k|    c = container_unwrap_shared(c, &typecode);
  246|  74.3k|    switch (typecode) {
  ------------------
  |  Branch (246:13): [True: 74.3k, False: 0]
  ------------------
  247|  66.6k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  66.6k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (247:9): [True: 66.6k, False: 7.71k]
  ------------------
  248|  66.6k|            return bitset_container_cardinality(const_CAST_bitset(c));
  ------------------
  |  |   53|  66.6k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  249|  7.71k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.71k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (249:9): [True: 7.71k, False: 66.6k]
  ------------------
  250|  7.71k|            return array_container_cardinality(const_CAST_array(c));
  ------------------
  |  |   55|  7.71k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.71k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  251|      0|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (251:9): [True: 0, False: 74.3k]
  ------------------
  252|      0|            return run_container_cardinality(const_CAST_run(c));
  ------------------
  |  |   78|      0|#define const_CAST_run(c) CAST(const run_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  253|  74.3k|    }
  254|  74.3k|    assert(false);
  255|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  256|      0|    return 0;  // unreached
  257|  74.3k|}
roaring_array.c:container_write:
  388|  74.3k|                                      char *buf) {
  389|  74.3k|    c = container_unwrap_shared(c, &typecode);
  390|  74.3k|    switch (typecode) {
  ------------------
  |  Branch (390:13): [True: 74.3k, False: 0]
  ------------------
  391|  66.6k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  66.6k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (391:9): [True: 66.6k, False: 7.71k]
  ------------------
  392|  66.6k|            return bitset_container_write(const_CAST_bitset(c), buf);
  ------------------
  |  |   53|  66.6k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  66.6k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  393|  7.71k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  7.71k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (393:9): [True: 7.71k, False: 66.6k]
  ------------------
  394|  7.71k|            return array_container_write(const_CAST_array(c), buf);
  ------------------
  |  |   55|  7.71k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  7.71k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  395|      0|        case RUN_CONTAINER_TYPE:
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (395:9): [True: 0, False: 74.3k]
  ------------------
  396|      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)
  |  |  ------------------
  ------------------
  397|  74.3k|    }
  398|  74.3k|    assert(false);
  399|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  400|      0|    return 0;  // unreached
  401|  74.3k|}
containers.c:container_unwrap_shared:
  106|  7.31k|    const container_t *candidate_shared_container, uint8_t *type) {
  107|  7.31k|    if (*type == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  7.31k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (107:9): [True: 0, False: 7.31k]
  ------------------
  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|  7.31k|    } else {
  112|  7.31k|        return candidate_shared_container;
  113|  7.31k|    }
  114|  7.31k|}
containers.c:container_maximum:
 2171|  7.07k|static inline uint16_t container_maximum(const container_t *c, uint8_t type) {
 2172|  7.07k|    c = container_unwrap_shared(c, &type);
 2173|  7.07k|    switch (type) {
 2174|  1.81k|        case BITSET_CONTAINER_TYPE:
  ------------------
  |  |   48|  1.81k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  |  Branch (2174:9): [True: 1.81k, False: 5.25k]
  ------------------
 2175|  1.81k|            return bitset_container_maximum(const_CAST_bitset(c));
  ------------------
  |  |   53|  1.81k|#define const_CAST_bitset(c) CAST(const bitset_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  1.81k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 2176|  5.25k|        case ARRAY_CONTAINER_TYPE:
  ------------------
  |  |   49|  5.25k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (2176:9): [True: 5.25k, False: 1.81k]
  ------------------
 2177|  5.25k|            return array_container_maximum(const_CAST_array(c));
  ------------------
  |  |   55|  5.25k|#define const_CAST_array(c) CAST(const array_container_t *, c)
  |  |  ------------------
  |  |  |  |   86|  5.25k|#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: 7.07k]
  ------------------
 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: 7.07k]
  ------------------
 2181|      0|            assert(false);
 2182|      0|            roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2183|  7.07k|    }
 2184|  7.07k|    assert(false);
 2185|      0|    roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
 2186|      0|    return false;
 2187|  7.07k|}

run_container_contains:
  262|  9.08k|inline bool run_container_contains(const run_container_t *run, uint16_t pos) {
  263|  9.08k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  264|  9.08k|    if (index >= 0) return true;
  ------------------
  |  Branch (264:9): [True: 6.69k, False: 2.39k]
  ------------------
  265|  2.39k|    index = -index - 2;  // points to preceding value, possibly -1
  266|  2.39k|    if (index != -1) {   // possible match
  ------------------
  |  Branch (266:9): [True: 859, False: 1.53k]
  ------------------
  267|    859|        int32_t offset = pos - run->runs[index].value;
  268|    859|        int32_t le = run->runs[index].length;
  269|    859|        if (offset <= le) return true;
  ------------------
  |  Branch (269:13): [True: 555, False: 304]
  ------------------
  270|    859|    }
  271|  1.83k|    return false;
  272|  2.39k|}
interleavedBinarySearch:
  113|   383k|                                       uint16_t ikey) {
  114|   383k|    int32_t low = 0;
  115|   383k|    int32_t high = lenarray - 1;
  116|  1.74M|    while (low <= high) {
  ------------------
  |  Branch (116:12): [True: 1.54M, False: 198k]
  ------------------
  117|  1.54M|        int32_t middleIndex = (low + high) >> 1;
  118|  1.54M|        uint16_t middleValue = array[middleIndex].value;
  119|  1.54M|        if (middleValue < ikey) {
  ------------------
  |  Branch (119:13): [True: 569k, False: 979k]
  ------------------
  120|   569k|            low = middleIndex + 1;
  121|   979k|        } else if (middleValue > ikey) {
  ------------------
  |  Branch (121:20): [True: 794k, False: 185k]
  ------------------
  122|   794k|            high = middleIndex - 1;
  123|   794k|        } else {
  124|   185k|            return middleIndex;
  125|   185k|        }
  126|  1.54M|    }
  127|   198k|    return -(low + 1);
  128|   383k|}
run_container_minimum:
  606|  16.1k|inline uint16_t run_container_minimum(const run_container_t *run) {
  607|  16.1k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (607:9): [True: 0, False: 16.1k]
  ------------------
  608|  16.1k|    return run->runs[0].value;
  609|  16.1k|}
run_container_maximum:
  613|  15.7k|inline uint16_t run_container_maximum(const run_container_t *run) {
  614|  15.7k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (614:9): [True: 0, False: 15.7k]
  ------------------
  615|  15.7k|    return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length;
  616|  15.7k|}
roaring.c:run_container_create_range:
  575|  84.2k|                                                          uint32_t stop) {
  576|  84.2k|    run_container_t *rc = run_container_create_given_capacity(1);
  577|  84.2k|    if (rc) {
  ------------------
  |  Branch (577:9): [True: 84.2k, False: 0]
  ------------------
  578|  84.2k|        rle16_t r;
  579|  84.2k|        r.value = (uint16_t)start;
  580|  84.2k|        r.length = (uint16_t)(stop - start - 1);
  581|  84.2k|        run_container_append_first(rc, r);
  582|  84.2k|    }
  583|  84.2k|    return rc;
  584|  84.2k|}
roaring.c:run_container_append_first:
  354|  84.2k|                                                 rle16_t vl) {
  355|  84.2k|    run->runs[run->n_runs] = vl;
  356|  84.2k|    run->n_runs++;
  357|  84.2k|    return vl;
  358|  84.2k|}
roaring.c:rle16_count_greater:
  179|    411|                                          int32_t lenarray, uint16_t key) {
  180|    411|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (180:9): [True: 0, False: 411]
  ------------------
  181|    411|    int32_t low = 0;
  182|    411|    int32_t high = lenarray - 1;
  183|  3.10k|    while (low <= high) {
  ------------------
  |  Branch (183:12): [True: 2.72k, False: 387]
  ------------------
  184|  2.72k|        int32_t middleIndex = (low + high) >> 1;
  185|  2.72k|        uint16_t min_value = array[middleIndex].value;
  186|  2.72k|        uint16_t max_value =
  187|  2.72k|            array[middleIndex].value + array[middleIndex].length;
  188|  2.72k|        if (max_value < key) {
  ------------------
  |  Branch (188:13): [True: 2.52k, False: 200]
  ------------------
  189|  2.52k|            low = middleIndex + 1;
  190|  2.52k|        } else if (key + UINT32_C(1) < min_value) {  // uint32 arithmetic
  ------------------
  |  Branch (190:20): [True: 176, False: 24]
  ------------------
  191|    176|            high = middleIndex - 1;
  192|    176|        } else {
  193|     24|            return lenarray - (middleIndex + 1);
  194|     24|        }
  195|  2.72k|    }
  196|    387|    return lenarray - low;
  197|    411|}
roaring.c:rle16_count_less:
  158|    411|                                       uint16_t key) {
  159|    411|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (159:9): [True: 1, False: 410]
  ------------------
  160|    410|    int32_t low = 0;
  161|    410|    int32_t high = lenarray - 1;
  162|  2.62k|    while (low <= high) {
  ------------------
  |  Branch (162:12): [True: 2.44k, False: 178]
  ------------------
  163|  2.44k|        int32_t middleIndex = (low + high) >> 1;
  164|  2.44k|        uint16_t min_value = array[middleIndex].value;
  165|  2.44k|        uint16_t max_value =
  166|  2.44k|            array[middleIndex].value + array[middleIndex].length;
  167|  2.44k|        if (max_value + UINT32_C(1) < key) {  // uint32 arithmetic
  ------------------
  |  Branch (167:13): [True: 1.10k, False: 1.34k]
  ------------------
  168|  1.10k|            low = middleIndex + 1;
  169|  1.34k|        } else if (key < min_value) {
  ------------------
  |  Branch (169:20): [True: 1.11k, False: 232]
  ------------------
  170|  1.11k|            high = middleIndex - 1;
  171|  1.11k|        } else {
  172|    232|            return middleIndex;
  173|    232|        }
  174|  2.44k|    }
  175|    178|    return low;
  176|    410|}
roaring.c:run_container_add_range_nruns:
  654|    411|                                                 int32_t nruns_greater) {
  655|    411|    int32_t nruns_common = run->n_runs - nruns_less - nruns_greater;
  656|    411|    if (nruns_common == 0) {
  ------------------
  |  Branch (656:9): [True: 110, False: 301]
  ------------------
  657|    110|        makeRoomAtIndex(run, (uint16_t)nruns_less);
  658|    110|        run->runs[nruns_less].value = (uint16_t)min;
  659|    110|        run->runs[nruns_less].length = (uint16_t)(max - min);
  660|    301|    } else {
  661|    301|        uint32_t common_min = run->runs[nruns_less].value;
  662|    301|        uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value +
  663|    301|                              run->runs[nruns_less + nruns_common - 1].length;
  664|    301|        uint32_t result_min = (common_min < min) ? common_min : min;
  ------------------
  |  Branch (664:31): [True: 70, False: 231]
  ------------------
  665|    301|        uint32_t result_max = (common_max > max) ? common_max : max;
  ------------------
  |  Branch (665:31): [True: 19, False: 282]
  ------------------
  666|       |
  667|    301|        run->runs[nruns_less].value = (uint16_t)result_min;
  668|    301|        run->runs[nruns_less].length = (uint16_t)(result_max - result_min);
  669|       |
  670|    301|        memmove(&(run->runs[nruns_less + 1]),
  671|    301|                &(run->runs[run->n_runs - nruns_greater]),
  672|    301|                nruns_greater * sizeof(rle16_t));
  673|    301|        run->n_runs = nruns_less + 1 + nruns_greater;
  674|    301|    }
  675|    411|}
roaring.c:makeRoomAtIndex:
  209|    750|static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) {
  210|       |    /* This function calls realloc + memmove sequentially to move by one index.
  211|       |     * Potentially copying twice the array.
  212|       |     */
  213|    750|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (213:9): [True: 619, False: 131]
  ------------------
  214|    619|        run_container_grow(run, run->n_runs + 1, true);
  215|    750|    memmove(run->runs + 1 + index, run->runs + index,
  216|    750|            (run->n_runs - index) * sizeof(rle16_t));
  217|    750|    run->n_runs++;
  218|    750|}
roaring.c:run_container_remove_range:
  713|  1.69k|                                              uint32_t min, uint32_t max) {
  714|  1.69k|    int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min);
  715|  1.69k|    int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max);
  716|       |
  717|  1.69k|    if (first >= 0 && min > run->runs[first].value &&
  ------------------
  |  Branch (717:9): [True: 614, False: 1.08k]
  |  Branch (717:23): [True: 272, False: 342]
  ------------------
  718|    272|        max < ((uint32_t)run->runs[first].value +
  ------------------
  |  Branch (718:9): [True: 25, False: 247]
  ------------------
  719|    272|               (uint32_t)run->runs[first].length)) {
  720|       |        // split this run into two adjacent runs
  721|       |
  722|       |        // right subinterval
  723|     25|        makeRoomAtIndex(run, (uint16_t)(first + 1));
  724|     25|        run->runs[first + 1].value = (uint16_t)(max + 1);
  725|     25|        run->runs[first + 1].length =
  726|     25|            (uint16_t)((run->runs[first].value + run->runs[first].length) -
  727|     25|                       (max + 1));
  728|       |
  729|       |        // left subinterval
  730|     25|        run->runs[first].length =
  731|     25|            (uint16_t)((min - 1) - run->runs[first].value);
  732|       |
  733|     25|        return;
  734|     25|    }
  735|       |
  736|       |    // update left-most partial run
  737|  1.66k|    if (first >= 0) {
  ------------------
  |  Branch (737:9): [True: 589, False: 1.08k]
  ------------------
  738|    589|        if (min > run->runs[first].value) {
  ------------------
  |  Branch (738:13): [True: 247, False: 342]
  ------------------
  739|    247|            run->runs[first].length =
  740|    247|                (uint16_t)((min - 1) - run->runs[first].value);
  741|    247|            first++;
  742|    247|        }
  743|  1.08k|    } else {
  744|  1.08k|        first = -first - 1;
  745|  1.08k|    }
  746|       |
  747|       |    // update right-most run
  748|  1.66k|    if (last >= 0) {
  ------------------
  |  Branch (748:9): [True: 557, False: 1.11k]
  ------------------
  749|    557|        uint16_t run_max = run->runs[last].value + run->runs[last].length;
  750|    557|        if (run_max > max) {
  ------------------
  |  Branch (750:13): [True: 336, False: 221]
  ------------------
  751|    336|            run->runs[last].value = (uint16_t)(max + 1);
  752|    336|            run->runs[last].length = (uint16_t)(run_max - (max + 1));
  753|    336|            last--;
  754|    336|        }
  755|  1.11k|    } else {
  756|  1.11k|        last = (-last - 1) - 1;
  757|  1.11k|    }
  758|       |
  759|       |    // remove intermediate runs
  760|  1.66k|    if (first <= last) {
  ------------------
  |  Branch (760:9): [True: 155, False: 1.51k]
  ------------------
  761|    155|        run_container_shift_tail(run, run->n_runs - (last + 1),
  762|    155|                                 -(last - first + 1));
  763|    155|    }
  764|  1.66k|}
roaring.c:rle16_find_run:
  134|  3.38k|                                     uint16_t ikey) {
  135|  3.38k|    int32_t low = 0;
  136|  3.38k|    int32_t high = lenarray - 1;
  137|  14.1k|    while (low <= high) {
  ------------------
  |  Branch (137:12): [True: 11.9k, False: 2.19k]
  ------------------
  138|  11.9k|        int32_t middleIndex = (low + high) >> 1;
  139|  11.9k|        uint16_t min = array[middleIndex].value;
  140|  11.9k|        uint16_t max = array[middleIndex].value + array[middleIndex].length;
  141|  11.9k|        if (ikey > max) {
  ------------------
  |  Branch (141:13): [True: 1.63k, False: 10.3k]
  ------------------
  142|  1.63k|            low = middleIndex + 1;
  143|  10.3k|        } else if (ikey < min) {
  ------------------
  |  Branch (143:20): [True: 9.12k, False: 1.19k]
  ------------------
  144|  9.12k|            high = middleIndex - 1;
  145|  9.12k|        } else {
  146|  1.19k|            return middleIndex;
  147|  1.19k|        }
  148|  11.9k|    }
  149|  2.19k|    return -(low + 1);
  150|  3.38k|}
roaring.c:run_container_shift_tail:
  694|    155|                                            int32_t distance) {
  695|    155|    assert(count >= 0 && count <= run->n_runs);   // the tail exists
  696|    155|    assert(run->n_runs - count + distance >= 0);  // left shift stays in bounds
  697|    155|    if (distance > 0) {
  ------------------
  |  Branch (697:9): [True: 0, False: 155]
  ------------------
  698|      0|        if (run->capacity < run->n_runs + distance) {
  ------------------
  |  Branch (698:13): [True: 0, False: 0]
  ------------------
  699|       |            run_container_grow(run, run->n_runs + distance, true);
  700|      0|        }
  701|      0|    }
  702|    155|    int32_t srcpos = run->n_runs - count;
  703|    155|    int32_t dstpos = srcpos + distance;
  704|    155|    memmove(&(run->runs[dstpos]), &(run->runs[srcpos]),
  705|    155|            sizeof(rle16_t) * count);
  706|    155|    run->n_runs += distance;
  707|    155|}
roaring.c:run_container_remove:
  224|  2.86k|static inline bool run_container_remove(run_container_t *run, uint16_t pos) {
  225|  2.86k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  226|  2.86k|    if (index >= 0) {
  ------------------
  |  Branch (226:9): [True: 1.11k, False: 1.74k]
  ------------------
  227|  1.11k|        int32_t le = run->runs[index].length;
  228|  1.11k|        if (le == 0) {
  ------------------
  |  Branch (228:13): [True: 229, False: 886]
  ------------------
  229|    229|            recoverRoomAtIndex(run, (uint16_t)index);
  230|    886|        } else {
  231|    886|            run->runs[index].value++;
  232|    886|            run->runs[index].length--;
  233|    886|        }
  234|  1.11k|        return true;
  235|  1.11k|    }
  236|  1.74k|    index = -index - 2;  // points to preceding value, possibly -1
  237|  1.74k|    if (index >= 0) {    // possible match
  ------------------
  |  Branch (237:9): [True: 815, False: 930]
  ------------------
  238|    815|        int32_t offset = pos - run->runs[index].value;
  239|    815|        int32_t le = run->runs[index].length;
  240|    815|        if (offset < le) {
  ------------------
  |  Branch (240:13): [True: 615, False: 200]
  ------------------
  241|       |            // need to break in two
  242|    615|            run->runs[index].length = (uint16_t)(offset - 1);
  243|       |            // need to insert
  244|    615|            uint16_t newvalue = pos + 1;
  245|    615|            int32_t newlength = le - offset - 1;
  246|    615|            makeRoomAtIndex(run, (uint16_t)(index + 1));
  247|    615|            run->runs[index + 1].value = newvalue;
  248|    615|            run->runs[index + 1].length = (uint16_t)newlength;
  249|    615|            return true;
  250|       |
  251|    615|        } else if (offset == le) {
  ------------------
  |  Branch (251:20): [True: 26, False: 174]
  ------------------
  252|     26|            run->runs[index].length--;
  253|     26|            return true;
  254|     26|        }
  255|    815|    }
  256|       |    // no match
  257|  1.10k|    return false;
  258|  1.74k|}
roaring.c:recoverRoomAtIndex:
  102|    229|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|    229|    memmove(run->runs + index, run->runs + (1 + index),
  104|    229|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|    229|    run->n_runs--;
  106|    229|}
roaring.c:run_container_nonzero_cardinality:
  312|  59.5k|    const run_container_t *run) {
  313|  59.5k|    return run->n_runs > 0;  // runs never empty
  314|  59.5k|}
roaring.c:run_container_is_full:
  398|  5.57k|static inline bool run_container_is_full(const run_container_t *run) {
  399|  5.57k|    rle16_t vl = run->runs[0];
  400|  5.57k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (400:12): [True: 1.07k, False: 4.49k]
  |  Branch (400:34): [True: 842, False: 235]
  |  Branch (400:53): [True: 717, False: 125]
  ------------------
  401|  5.57k|}
roaring.c:run_container_equals:
  506|    134|                                        const run_container_t *container2) {
  507|    134|    if (container1->n_runs != container2->n_runs) {
  ------------------
  |  Branch (507:9): [True: 105, False: 29]
  ------------------
  508|    105|        return false;
  509|    105|    }
  510|     29|    return memequals(container1->runs, container2->runs,
  511|     29|                     container1->n_runs * sizeof(rle16_t));
  512|    134|}
roaring.c:run_container_contains_range:
  281|    173|                                                uint32_t pos_end) {
  282|    173|    uint32_t count = 0;
  283|    173|    int32_t index =
  284|    173|        interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start);
  285|    173|    if (index < 0) {
  ------------------
  |  Branch (285:9): [True: 96, False: 77]
  ------------------
  286|     96|        index = -index - 2;
  287|     96|        if ((index == -1) ||
  ------------------
  |  Branch (287:13): [True: 12, False: 84]
  ------------------
  288|     84|            ((pos_start - run->runs[index].value) > run->runs[index].length)) {
  ------------------
  |  Branch (288:13): [True: 24, False: 60]
  ------------------
  289|     36|            return false;
  290|     36|        }
  291|     96|    }
  292|  2.02k|    for (int32_t i = index; i < run->n_runs; ++i) {
  ------------------
  |  Branch (292:29): [True: 1.95k, False: 65]
  ------------------
  293|  1.95k|        const uint32_t stop = run->runs[i].value + run->runs[i].length;
  294|  1.95k|        if (run->runs[i].value >= pos_end) break;
  ------------------
  |  Branch (294:13): [True: 13, False: 1.94k]
  ------------------
  295|  1.94k|        if (stop >= pos_end) {
  ------------------
  |  Branch (295:13): [True: 59, False: 1.88k]
  ------------------
  296|     59|            count += (((pos_end - run->runs[i].value) > 0)
  ------------------
  |  Branch (296:23): [True: 59, False: 0]
  ------------------
  297|     59|                          ? (pos_end - run->runs[i].value)
  298|     59|                          : 0);
  299|     59|            break;
  300|     59|        }
  301|  1.88k|        const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0;
  ------------------
  |  Branch (301:30): [True: 1.87k, False: 11]
  ------------------
  302|  1.88k|        count += (min < run->runs[i].length) ? min : run->runs[i].length;
  ------------------
  |  Branch (302:18): [True: 41, False: 1.84k]
  ------------------
  303|  1.88k|    }
  304|    137|    return count >= (pos_end - pos_start - 1);
  305|    173|}
roaring_array.c:run_container_size_in_bytes:
  497|  2.34k|    const run_container_t *container) {
  498|  2.34k|    return run_container_serialized_size_in_bytes(container->n_runs);
  499|  2.34k|}
roaring_array.c:run_container_serialized_size_in_bytes:
  460|  2.34k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  461|  2.34k|    return sizeof(uint16_t) +
  462|  2.34k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  463|  2.34k|}
convert.c:run_container_serialized_size_in_bytes:
  460|   139k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  461|   139k|    return sizeof(uint16_t) +
  462|   139k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  463|   139k|}
mixed_intersection.c:run_container_is_full:
  398|  15.5k|static inline bool run_container_is_full(const run_container_t *run) {
  399|  15.5k|    rle16_t vl = run->runs[0];
  400|  15.5k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (400:12): [True: 1.46k, False: 14.1k]
  |  Branch (400:34): [True: 694, False: 771]
  |  Branch (400:53): [True: 204, False: 490]
  ------------------
  401|  15.5k|}
mixed_union.c:run_container_is_full:
  398|  2.67k|static inline bool run_container_is_full(const run_container_t *run) {
  399|  2.67k|    rle16_t vl = run->runs[0];
  400|  2.67k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (400:12): [True: 374, False: 2.30k]
  |  Branch (400:34): [True: 240, False: 134]
  |  Branch (400:53): [True: 105, False: 135]
  ------------------
  401|  2.67k|}
mixed_union.c:run_container_append_first:
  354|  1.98k|                                                 rle16_t vl) {
  355|  1.98k|    run->runs[run->n_runs] = vl;
  356|  1.98k|    run->n_runs++;
  357|  1.98k|    return vl;
  358|  1.98k|}
mixed_union.c:run_container_append_value_first:
  388|    587|                                                       uint16_t val) {
  389|    587|    rle16_t newrle = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|    587|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  390|    587|    run->runs[run->n_runs] = newrle;
  391|    587|    run->n_runs++;
  392|    587|    return newrle;
  393|    587|}
mixed_union.c:run_container_append:
  335|   150k|                                        rle16_t *previousrl) {
  336|   150k|    const uint32_t previousend = previousrl->value + previousrl->length;
  337|   150k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (337:9): [True: 139k, False: 10.9k]
  ------------------
  338|   139k|        run->runs[run->n_runs] = vl;
  339|   139k|        run->n_runs++;
  340|   139k|        *previousrl = vl;
  341|   139k|    } else {
  342|  10.9k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  343|  10.9k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (343:13): [True: 10.9k, False: 0]
  ------------------
  344|  10.9k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  345|  10.9k|            run->runs[run->n_runs - 1] = *previousrl;
  346|  10.9k|        }
  347|  10.9k|    }
  348|   150k|}
mixed_union.c:run_container_append_value:
  371|   473k|                                              rle16_t *previousrl) {
  372|   473k|    const uint32_t previousend = previousrl->value + previousrl->length;
  373|   473k|    if (val > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (373:9): [True: 48.9k, False: 424k]
  ------------------
  374|  48.9k|        *previousrl = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|  48.9k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  375|  48.9k|        run->runs[run->n_runs] = *previousrl;
  376|  48.9k|        run->n_runs++;
  377|   424k|    } else if (val == previousend + 1) {  // we merge
  ------------------
  |  Branch (377:16): [True: 169k, False: 255k]
  ------------------
  378|   169k|        previousrl->length++;
  379|   169k|        run->runs[run->n_runs - 1] = *previousrl;
  380|   169k|    }
  381|   473k|}
mixed_negation.c:run_container_serialized_size_in_bytes:
  460|    362|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  461|    362|    return sizeof(uint16_t) +
  462|    362|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  463|    362|}
run.c:run_container_is_full:
  398|   119k|static inline bool run_container_is_full(const run_container_t *run) {
  399|   119k|    rle16_t vl = run->runs[0];
  400|   119k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (400:12): [True: 106k, False: 13.2k]
  |  Branch (400:34): [True: 104k, False: 1.68k]
  |  Branch (400:53): [True: 102k, False: 2.13k]
  ------------------
  401|   119k|}
run.c:run_container_serialized_size_in_bytes:
  460|     49|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  461|     49|    return sizeof(uint16_t) +
  462|     49|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  463|     49|}
run.c:recoverRoomAtIndex:
  102|  5.84k|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|  5.84k|    memmove(run->runs + index, run->runs + (1 + index),
  104|  5.84k|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|  5.84k|    run->n_runs--;
  106|  5.84k|}
run.c:makeRoomAtIndex:
  209|  38.6k|static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) {
  210|       |    /* This function calls realloc + memmove sequentially to move by one index.
  211|       |     * Potentially copying twice the array.
  212|       |     */
  213|  38.6k|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (213:9): [True: 2.27k, False: 36.3k]
  ------------------
  214|  2.27k|        run_container_grow(run, run->n_runs + 1, true);
  215|  38.6k|    memmove(run->runs + 1 + index, run->runs + index,
  216|  38.6k|            (run->n_runs - index) * sizeof(rle16_t));
  217|  38.6k|    run->n_runs++;
  218|  38.6k|}
run.c:run_container_append_first:
  354|  2.11k|                                                 rle16_t vl) {
  355|  2.11k|    run->runs[run->n_runs] = vl;
  356|  2.11k|    run->n_runs++;
  357|  2.11k|    return vl;
  358|  2.11k|}
run.c:run_container_append:
  335|   256k|                                        rle16_t *previousrl) {
  336|   256k|    const uint32_t previousend = previousrl->value + previousrl->length;
  337|   256k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (337:9): [True: 132k, False: 124k]
  ------------------
  338|   132k|        run->runs[run->n_runs] = vl;
  339|   132k|        run->n_runs++;
  340|   132k|        *previousrl = vl;
  341|   132k|    } else {
  342|   124k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  343|   124k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (343:13): [True: 96.1k, False: 27.9k]
  ------------------
  344|  96.1k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  345|  96.1k|            run->runs[run->n_runs - 1] = *previousrl;
  346|  96.1k|        }
  347|   124k|    }
  348|   256k|}
run.c:run_append_exclusive:
  526|   354k|                                           uint16_t start, uint16_t length) {
  527|   354k|    rle16_t *last_run = n_runs ? runs + (n_runs - 1) : NULL;
  ------------------
  |  Branch (527:25): [True: 288k, False: 66.4k]
  ------------------
  528|   354k|    const int old_end = n_runs ? last_run->value + last_run->length + 1 : -1;
  ------------------
  |  Branch (528:25): [True: 288k, False: 66.4k]
  ------------------
  529|   354k|    if (start > old_end) {
  ------------------
  |  Branch (529:9): [True: 225k, False: 129k]
  ------------------
  530|   225k|        runs[n_runs] = CROARING_MAKE_RLE16(start, length);
  ------------------
  |  |   60|   225k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  531|   225k|        return n_runs + 1;
  532|   225k|    }
  533|   129k|    if (start == old_end) {  // we merge
  ------------------
  |  Branch (533:9): [True: 3.22k, False: 125k]
  ------------------
  534|  3.22k|        last_run->length += length + 1;
  535|  3.22k|        return n_runs;
  536|  3.22k|    }
  537|   125k|    const int new_end = start + length + 1;
  538|   125k|    if (start == last_run->value) {  // wipe out previous
  ------------------
  |  Branch (538:9): [True: 99.6k, False: 26.1k]
  ------------------
  539|  99.6k|        if (new_end < old_end) {
  ------------------
  |  Branch (539:13): [True: 6.32k, False: 93.3k]
  ------------------
  540|  6.32k|            *last_run = CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  6.32k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  541|  93.3k|        } else if (new_end > old_end) {
  ------------------
  |  Branch (541:20): [True: 2.14k, False: 91.1k]
  ------------------
  542|  2.14k|            *last_run = CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|  2.14k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  543|  91.1k|        } else {
  544|  91.1k|            return n_runs - 1;
  545|  91.1k|        }
  546|  8.46k|        return n_runs;
  547|  99.6k|    }
  548|  26.1k|    last_run->length = start - last_run->value - 1;
  549|  26.1k|    if (new_end < old_end) {
  ------------------
  |  Branch (549:9): [True: 20.4k, False: 5.69k]
  ------------------
  550|  20.4k|        runs[n_runs] = CROARING_MAKE_RLE16(new_end, old_end - new_end - 1);
  ------------------
  |  |   60|  20.4k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  551|  20.4k|        return n_runs + 1;
  552|  20.4k|    } else if (new_end > old_end) {
  ------------------
  |  Branch (552:16): [True: 952, False: 4.74k]
  ------------------
  553|    952|        runs[n_runs] = CROARING_MAKE_RLE16(old_end, new_end - old_end - 1);
  ------------------
  |  |   60|    952|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  554|    952|        return n_runs + 1;
  555|    952|    }
  556|  4.74k|    return n_runs;
  557|  26.1k|}
run.c:run_container_empty:
  317|      2|static inline bool run_container_empty(const run_container_t *run) {
  318|      2|    return run->n_runs == 0;  // runs never empty
  319|      2|}
run.c:run_container_size_in_bytes:
  497|     49|    const run_container_t *container) {
  498|     49|    return run_container_serialized_size_in_bytes(container->n_runs);
  499|     49|}

array.c:croaring_realloc_shrink:
   51|  4.23k|                                            bool* shrunk) {
   52|  4.23k|    if (size == 0) {
  ------------------
  |  Branch (52:9): [True: 0, False: 4.23k]
  ------------------
   53|      0|        roaring_free(p);
   54|      0|        *shrunk = true;
   55|      0|        return NULL;
   56|      0|    }
   57|  4.23k|    void* q = roaring_realloc(p, size);
   58|  4.23k|    *shrunk = q != NULL;
   59|  4.23k|    return q != NULL ? q : p;
  ------------------
  |  Branch (59:12): [True: 4.23k, False: 0]
  ------------------
   60|  4.23k|}

roaring_trailing_zeroes:
  248|  69.7M|inline int roaring_trailing_zeroes(unsigned long long input_num) {
  249|  69.7M|    return __builtin_ctzll(input_num);
  250|  69.7M|}
roaring_leading_zeroes:
  252|  4.19k|inline int roaring_leading_zeroes(unsigned long long input_num) {
  253|  4.19k|    return __builtin_clzll(input_num);
  254|  4.19k|}
roaring.c:roaring_hamming:
  313|   197k|static inline int roaring_hamming(uint64_t x) {
  314|       |#if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  315|       |    CROARING_REGULAR_VISUAL_STUDIO
  316|       |#ifdef CROARING_USENEON
  317|       |    return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
  318|       |#elif defined(_M_ARM64)
  319|       |    return roaring_hamming_backup(x);
  320|       |    // (int) _CountOneBits64(x); is unavailable
  321|       |#else   // _M_ARM64
  322|       |    return (int)__popcnt64(x);
  323|       |#endif  // _M_ARM64
  324|       |#elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  325|       |    CROARING_REGULAR_VISUAL_STUDIO
  326|       |#ifdef _M_ARM
  327|       |    return roaring_hamming_backup(x);
  328|       |    // _CountOneBits is unavailable
  329|       |#else   // _M_ARM
  330|       |    return (int)__popcnt((unsigned int)x) +
  331|       |           (int)__popcnt((unsigned int)(x >> 32));
  332|       |#endif  // _M_ARM
  333|       |#else
  334|   197k|    return __builtin_popcountll(x);
  335|   197k|#endif
  336|   197k|}
mixed_intersection.c:roaring_hamming:
  313|   192k|static inline int roaring_hamming(uint64_t x) {
  314|       |#if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  315|       |    CROARING_REGULAR_VISUAL_STUDIO
  316|       |#ifdef CROARING_USENEON
  317|       |    return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
  318|       |#elif defined(_M_ARM64)
  319|       |    return roaring_hamming_backup(x);
  320|       |    // (int) _CountOneBits64(x); is unavailable
  321|       |#else   // _M_ARM64
  322|       |    return (int)__popcnt64(x);
  323|       |#endif  // _M_ARM64
  324|       |#elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  325|       |    CROARING_REGULAR_VISUAL_STUDIO
  326|       |#ifdef _M_ARM
  327|       |    return roaring_hamming_backup(x);
  328|       |    // _CountOneBits is unavailable
  329|       |#else   // _M_ARM
  330|       |    return (int)__popcnt((unsigned int)x) +
  331|       |           (int)__popcnt((unsigned int)(x >> 32));
  332|       |#endif  // _M_ARM
  333|       |#else
  334|   192k|    return __builtin_popcountll(x);
  335|   192k|#endif
  336|   192k|}

roaring_bitmap_init_cleared:
   72|  35.6k|inline void roaring_bitmap_init_cleared(roaring_bitmap_t *r) {
   73|  35.6k|    roaring_bitmap_init_with_capacity(r, 0);
   74|  35.6k|}
roaring_bitmap_add_range:
  437|  7.12k|                                     uint64_t max) {
  438|  7.12k|    if (max > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (438:9): [True: 0, False: 7.12k]
  ------------------
  439|      0|        max = (uint64_t)UINT32_MAX + 1;
  440|      0|    }
  441|  7.12k|    if (max <= min) {
  ------------------
  |  Branch (441:9): [True: 4.39k, False: 2.73k]
  ------------------
  442|  4.39k|        return;
  443|  4.39k|    }
  444|  2.73k|    roaring_bitmap_add_range_closed(r, (uint32_t)min, (uint32_t)(max - 1));
  445|  2.73k|}
roaring_bitmap_remove_range:
  463|  7.12k|                                        uint64_t max) {
  464|  7.12k|    if (max > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (464:9): [True: 0, False: 7.12k]
  ------------------
  465|      0|        max = (uint64_t)UINT32_MAX + 1;
  466|      0|    }
  467|  7.12k|    if (max <= min) {
  ------------------
  |  Branch (467:9): [True: 6.20k, False: 928]
  ------------------
  468|  6.20k|        return;
  469|  6.20k|    }
  470|    928|    roaring_bitmap_remove_range_closed(r, (uint32_t)min, (uint32_t)(max - 1));
  471|    928|}
roaring_bitmap_contains:
  488|  7.18k|inline bool roaring_bitmap_contains(const roaring_bitmap_t *r, uint32_t val) {
  489|       |    // For performance reasons, this function is inline and uses internal
  490|       |    // functions directly.
  491|  7.18k|#ifdef __cplusplus
  492|  7.18k|    using namespace ::roaring::internal;
  493|  7.18k|#endif
  494|  7.18k|    const uint16_t hb = val >> 16;
  495|       |    /*
  496|       |     * the next function call involves a binary search and lots of branching.
  497|       |     */
  498|  7.18k|    int32_t i = ra_get_index(&r->high_low_container, hb);
  499|  7.18k|    if (i < 0) return false;
  ------------------
  |  Branch (499:9): [True: 625, False: 6.56k]
  ------------------
  500|       |
  501|  6.56k|    uint8_t typecode;
  502|       |    // next call ought to be cheap
  503|  6.56k|    container_t *container = ra_get_container_at_index(&r->high_low_container,
  504|  6.56k|                                                       (uint16_t)i, &typecode);
  505|       |    // rest might be a tad expensive, possibly involving another round of binary
  506|       |    // search
  507|  6.56k|    return container_contains(container, val & 0xFFFF, typecode);
  508|  7.18k|}
roaring_bitmap_set_copy_on_write:
  117|  49.9k|inline void roaring_bitmap_set_copy_on_write(roaring_bitmap_t *r, bool cow) {
  118|  49.9k|    if (cow) {
  ------------------
  |  Branch (118:9): [True: 0, False: 49.9k]
  ------------------
  119|      0|        r->high_low_container.flags |= ROARING_FLAG_COW;
  ------------------
  |  |   46|      0|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  120|  49.9k|    } else {
  121|  49.9k|        if (roaring_bitmap_get_copy_on_write(r)) {
  ------------------
  |  Branch (121:13): [True: 0, False: 49.9k]
  ------------------
  122|      0|            roaring_unshare_all(r);
  123|      0|        }
  124|       |        r->high_low_container.flags &= ~ROARING_FLAG_COW;
  ------------------
  |  |   46|  49.9k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  125|  49.9k|    }
  126|  49.9k|}
roaring_bitmap_get_copy_on_write:
  114|  64.1k|inline bool roaring_bitmap_get_copy_on_write(const roaring_bitmap_t *r) {
  115|       |    return r->high_low_container.flags & ROARING_FLAG_COW;
  ------------------
  |  |   46|  64.1k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  116|  64.1k|}

ra_get_index:
   93|  97.4k|inline int32_t ra_get_index(const roaring_array_t *ra, uint16_t x) {
   94|  97.4k|    if ((ra->size == 0) || ra->keys[ra->size - 1] == x) return ra->size - 1;
  ------------------
  |  Branch (94:9): [True: 14.3k, False: 83.1k]
  |  Branch (94:28): [True: 39.2k, False: 43.8k]
  ------------------
   95|  43.8k|    return binarySearch(ra->keys, (int32_t)ra->size, x);
   96|  97.4k|}
ra_get_container_at_index:
  102|   466k|                                              uint16_t i, uint8_t *typecode) {
  103|   466k|    *typecode = ra->typecodes[i];
  104|   466k|    return ra->containers[i];
  105|   466k|}
ra_get_key_at_index:
  110|   318k|inline uint16_t ra_get_key_at_index(const roaring_array_t *ra, uint16_t i) {
  111|   318k|    return ra->keys[i];
  112|   318k|}
ra_set_container_at_index:
  175|   113k|                                      container_t *c, uint8_t typecode) {
  176|       |    assert(i < ra->size);
  177|   113k|    ra->containers[i] = c;
  178|   113k|    ra->typecodes[i] = typecode;
  179|   113k|}
ra_get_size:
  191|  15.0k|inline int32_t ra_get_size(const roaring_array_t *ra) { return ra->size; }
ra_replace_key_and_container_at_index:
  205|   143k|                                                  uint8_t typecode) {
  206|   143k|    assert(i < ra->size);
  207|       |
  208|   143k|    ra->keys[i] = key;
  209|   143k|    ra->containers[i] = c;
  210|   143k|    ra->typecodes[i] = typecode;
  211|   143k|}
roaring.c:ra_advance_until:
  194|    518|                                       int32_t pos) {
  195|    518|    return advanceUntil(ra->keys, pos, ra->size, x);
  196|    518|}
roaring.c:ra_unshare_container_at_index:
  275|  69.2k|                                                 uint16_t i) {
  276|       |    assert(i < ra->size);
  277|  69.2k|    ra->containers[i] =
  278|  69.2k|        get_writable_copy_if_shared(ra->containers[i], &ra->typecodes[i]);
  279|  69.2k|}

intersect_vector16:
  387|  2.91k|                           size_t s_b, uint16_t *C) {
  388|  2.91k|    size_t count = 0;
  389|  2.91k|    size_t i_a = 0, i_b = 0;
  390|  2.91k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  391|  2.91k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  392|  2.91k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  393|  2.91k|    __m128i v_a, v_b;
  394|  2.91k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (394:9): [True: 2.53k, False: 374]
  |  Branch (394:25): [True: 2.04k, False: 490]
  ------------------
  395|  2.04k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  396|  2.04k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  397|  5.43k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (397:16): [True: 3.41k, False: 2.02k]
  |  Branch (397:33): [True: 184, False: 1.83k]
  ------------------
  398|  3.59k|            const __m128i res_v = _mm_cmpestrm(
  399|  3.59k|                v_b, vectorlength, v_a, vectorlength,
  400|  3.59k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  401|  3.59k|            const int r = _mm_extract_epi32(res_v, 0);
  402|  3.59k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  403|  3.59k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  404|  3.59k|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  405|  3.59k|            count += _mm_popcnt_u32(r);
  406|  3.59k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  407|  3.59k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  408|  3.59k|            if (a_max <= b_max) {
  ------------------
  |  Branch (408:17): [True: 2.04k, False: 1.55k]
  ------------------
  409|  2.04k|                i_a += vectorlength;
  410|  2.04k|                if (i_a == st_a) break;
  ------------------
  |  Branch (410:21): [True: 162, False: 1.88k]
  ------------------
  411|  1.88k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  412|  1.88k|            }
  413|  3.43k|            if (b_max <= a_max) {
  ------------------
  |  Branch (413:17): [True: 1.67k, False: 1.75k]
  ------------------
  414|  1.67k|                i_b += vectorlength;
  415|  1.67k|                if (i_b == st_b) break;
  ------------------
  |  Branch (415:21): [True: 49, False: 1.62k]
  ------------------
  416|  1.62k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  417|  1.62k|            }
  418|  3.43k|        }
  419|  2.04k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (419:13): [True: 1.88k, False: 162]
  |  Branch (419:29): [True: 1.83k, False: 49]
  ------------------
  420|  49.2k|            while (true) {
  ------------------
  |  Branch (420:20): [True: 49.2k, Folded]
  ------------------
  421|  49.2k|                const __m128i res_v = _mm_cmpistrm(
  422|  49.2k|                    v_b, v_a,
  423|  49.2k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  424|  49.2k|                const int r = _mm_extract_epi32(res_v, 0);
  425|  49.2k|                __m128i sm16 =
  426|  49.2k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  427|  49.2k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  428|  49.2k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  429|  49.2k|                count += _mm_popcnt_u32(r);
  430|  49.2k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  431|  49.2k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  432|  49.2k|                if (a_max <= b_max) {
  ------------------
  |  Branch (432:21): [True: 21.3k, False: 27.9k]
  ------------------
  433|  21.3k|                    i_a += vectorlength;
  434|  21.3k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (434:25): [True: 952, False: 20.3k]
  ------------------
  435|  20.3k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  436|  20.3k|                }
  437|  48.3k|                if (b_max <= a_max) {
  ------------------
  |  Branch (437:21): [True: 29.5k, False: 18.8k]
  ------------------
  438|  29.5k|                    i_b += vectorlength;
  439|  29.5k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (439:25): [True: 884, False: 28.6k]
  ------------------
  440|  28.6k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  441|  28.6k|                }
  442|  48.3k|            }
  443|  2.04k|    }
  444|       |    // intersect the tail using scalar intersection
  445|  59.1k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (445:12): [True: 57.0k, False: 2.10k]
  |  Branch (445:25): [True: 56.2k, False: 807]
  ------------------
  446|  56.2k|        uint16_t a = A[i_a];
  447|  56.2k|        uint16_t b = B[i_b];
  448|  56.2k|        if (a < b) {
  ------------------
  |  Branch (448:13): [True: 27.7k, False: 28.5k]
  ------------------
  449|  27.7k|            i_a++;
  450|  28.5k|        } else if (b < a) {
  ------------------
  |  Branch (450:20): [True: 19.3k, False: 9.19k]
  ------------------
  451|  19.3k|            i_b++;
  452|  19.3k|        } else {
  453|  9.19k|            C[count] = a;  //==b;
  454|  9.19k|            count++;
  455|  9.19k|            i_a++;
  456|  9.19k|            i_b++;
  457|  9.19k|        }
  458|  56.2k|    }
  459|  2.91k|    return (int32_t)count;
  460|  2.91k|}
array_container_to_uint32_array_vector16:
  465|  6.70k|                                             uint32_t base) {
  466|  6.70k|    int outpos = 0;
  467|  6.70k|    uint32_t *out = (uint32_t *)vout;
  468|  6.70k|    size_t i = 0;
  469|   203k|    for (; i + sizeof(__m128i) / sizeof(uint16_t) <= cardinality;
  ------------------
  |  Branch (469:12): [True: 196k, False: 6.70k]
  ------------------
  470|   196k|         i += sizeof(__m128i) / sizeof(uint16_t)) {
  471|   196k|        __m128i vinput = _mm_loadu_si128((const __m128i *)(array + i));
  472|   196k|        __m256i voutput = _mm256_add_epi32(_mm256_cvtepu16_epi32(vinput),
  473|   196k|                                           _mm256_set1_epi32(base));
  474|   196k|        _mm256_storeu_si256((__m256i *)(out + outpos), voutput);
  475|   196k|        outpos += sizeof(__m256i) / sizeof(uint32_t);
  476|   196k|    }
  477|  24.9k|    for (; i < cardinality; ++i) {
  ------------------
  |  Branch (477:12): [True: 18.2k, False: 6.70k]
  ------------------
  478|  18.2k|        const uint32_t val = base + array[i];
  479|  18.2k|        memcpy(out + outpos, &val,
  480|  18.2k|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  481|  18.2k|        outpos++;
  482|  18.2k|    }
  483|  6.70k|    return outpos;
  484|  6.70k|}
intersect_vector16_inplace:
  488|  5.57k|                                   size_t s_b) {
  489|  5.57k|    size_t count = 0;
  490|  5.57k|    size_t i_a = 0, i_b = 0;
  491|  5.57k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  492|  5.57k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  493|  5.57k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  494|  5.57k|    __m128i v_a, v_b;
  495|  5.57k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (495:9): [True: 3.35k, False: 2.22k]
  |  Branch (495:25): [True: 2.82k, False: 532]
  ------------------
  496|  2.82k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  497|  2.82k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  498|  2.82k|        __m128i tmp[2] = {_mm_setzero_si128()};
  499|  2.82k|        size_t tmp_count = 0;
  500|  5.47k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (500:16): [True: 2.50k, False: 2.96k]
  |  Branch (500:33): [True: 311, False: 2.65k]
  ------------------
  501|  2.81k|            const __m128i res_v = _mm_cmpestrm(
  502|  2.81k|                v_b, vectorlength, v_a, vectorlength,
  503|  2.81k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  504|  2.81k|            const int r = _mm_extract_epi32(res_v, 0);
  505|  2.81k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  506|  2.81k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  507|  2.81k|            _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  508|  2.81k|            tmp_count += _mm_popcnt_u32(r);
  509|  2.81k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  510|  2.81k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  511|  2.81k|            if (a_max <= b_max) {
  ------------------
  |  Branch (511:17): [True: 2.63k, False: 179]
  ------------------
  512|  2.63k|                _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  513|  2.63k|                _mm_storeu_si128(tmp, _mm_setzero_si128());
  514|  2.63k|                count += tmp_count;
  515|  2.63k|                tmp_count = 0;
  516|  2.63k|                i_a += vectorlength;
  517|  2.63k|                if (i_a == st_a) break;
  ------------------
  |  Branch (517:21): [True: 148, False: 2.48k]
  ------------------
  518|  2.48k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  519|  2.48k|            }
  520|  2.66k|            if (b_max <= a_max) {
  ------------------
  |  Branch (520:17): [True: 406, False: 2.26k]
  ------------------
  521|    406|                i_b += vectorlength;
  522|    406|                if (i_b == st_b) break;
  ------------------
  |  Branch (522:21): [True: 15, False: 391]
  ------------------
  523|    391|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  524|    391|            }
  525|  2.66k|        }
  526|  2.82k|        if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (526:13): [True: 2.67k, False: 148]
  |  Branch (526:29): [True: 2.65k, False: 15]
  ------------------
  527|   257k|            while (true) {
  ------------------
  |  Branch (527:20): [True: 257k, Folded]
  ------------------
  528|   257k|                const __m128i res_v = _mm_cmpistrm(
  529|   257k|                    v_b, v_a,
  530|   257k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  531|   257k|                const int r = _mm_extract_epi32(res_v, 0);
  532|   257k|                __m128i sm16 =
  533|   257k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  534|   257k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  535|   257k|                _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  536|   257k|                tmp_count += _mm_popcnt_u32(r);
  537|   257k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  538|   257k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  539|   257k|                if (a_max <= b_max) {
  ------------------
  |  Branch (539:21): [True: 151k, False: 105k]
  ------------------
  540|   151k|                    _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  541|   151k|                    _mm_storeu_si128(tmp, _mm_setzero_si128());
  542|   151k|                    count += tmp_count;
  543|   151k|                    tmp_count = 0;
  544|   151k|                    i_a += vectorlength;
  545|   151k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (545:25): [True: 1.31k, False: 150k]
  ------------------
  546|   150k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  547|   150k|                }
  548|   256k|                if (b_max <= a_max) {
  ------------------
  |  Branch (548:21): [True: 144k, False: 111k]
  ------------------
  549|   144k|                    i_b += vectorlength;
  550|   144k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (550:25): [True: 1.34k, False: 143k]
  ------------------
  551|   143k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  552|   143k|                }
  553|   256k|            }
  554|  2.65k|        }
  555|       |        // tmp_count <= 8, so this does not affect efficiency so much
  556|  6.23k|        for (size_t i = 0; i < tmp_count; i++) {
  ------------------
  |  Branch (556:28): [True: 3.41k, False: 2.82k]
  ------------------
  557|  3.41k|            A[count] = ((uint16_t *)tmp)[i];
  558|  3.41k|            count++;
  559|  3.41k|        }
  560|  2.82k|        i_a += tmp_count;  // We can at least jump pass $tmp_count elements in A
  561|  2.82k|    }
  562|       |    // intersect the tail using scalar intersection
  563|  56.3k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (563:12): [True: 51.6k, False: 4.70k]
  |  Branch (563:25): [True: 50.8k, False: 865]
  ------------------
  564|  50.8k|        uint16_t a = A[i_a];
  565|  50.8k|        uint16_t b = B[i_b];
  566|  50.8k|        if (a < b) {
  ------------------
  |  Branch (566:13): [True: 25.3k, False: 25.4k]
  ------------------
  567|  25.3k|            i_a++;
  568|  25.4k|        } else if (b < a) {
  ------------------
  |  Branch (568:20): [True: 8.81k, False: 16.6k]
  ------------------
  569|  8.81k|            i_b++;
  570|  16.6k|        } else {
  571|  16.6k|            A[count] = a;  //==b;
  572|  16.6k|            count++;
  573|  16.6k|            i_a++;
  574|  16.6k|            i_b++;
  575|  16.6k|        }
  576|  50.8k|    }
  577|  5.57k|    return (int32_t)count;
  578|  5.57k|}
intersect_vector16_cardinality:
  584|  11.6k|                                       const uint16_t *B, size_t s_b) {
  585|  11.6k|    size_t count = 0;
  586|  11.6k|    size_t i_a = 0, i_b = 0;
  587|  11.6k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  588|  11.6k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  589|  11.6k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  590|  11.6k|    __m128i v_a, v_b;
  591|  11.6k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (591:9): [True: 10.1k, False: 1.49k]
  |  Branch (591:25): [True: 8.18k, False: 1.96k]
  ------------------
  592|  8.18k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  593|  8.18k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  594|  21.7k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (594:16): [True: 13.6k, False: 8.08k]
  |  Branch (594:33): [True: 736, False: 7.34k]
  ------------------
  595|  14.3k|            const __m128i res_v = _mm_cmpestrm(
  596|  14.3k|                v_b, vectorlength, v_a, vectorlength,
  597|  14.3k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  598|  14.3k|            const int r = _mm_extract_epi32(res_v, 0);
  599|  14.3k|            count += _mm_popcnt_u32(r);
  600|  14.3k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  601|  14.3k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  602|  14.3k|            if (a_max <= b_max) {
  ------------------
  |  Branch (602:17): [True: 8.17k, False: 6.20k]
  ------------------
  603|  8.17k|                i_a += vectorlength;
  604|  8.17k|                if (i_a == st_a) break;
  ------------------
  |  Branch (604:21): [True: 648, False: 7.52k]
  ------------------
  605|  7.52k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  606|  7.52k|            }
  607|  13.7k|            if (b_max <= a_max) {
  ------------------
  |  Branch (607:17): [True: 6.70k, False: 7.02k]
  ------------------
  608|  6.70k|                i_b += vectorlength;
  609|  6.70k|                if (i_b == st_b) break;
  ------------------
  |  Branch (609:21): [True: 196, False: 6.50k]
  ------------------
  610|  6.50k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  611|  6.50k|            }
  612|  13.7k|        }
  613|  8.18k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (613:13): [True: 7.54k, False: 648]
  |  Branch (613:29): [True: 7.34k, False: 196]
  ------------------
  614|   197k|            while (true) {
  ------------------
  |  Branch (614:20): [True: 197k, Folded]
  ------------------
  615|   197k|                const __m128i res_v = _mm_cmpistrm(
  616|   197k|                    v_b, v_a,
  617|   197k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  618|   197k|                const int r = _mm_extract_epi32(res_v, 0);
  619|   197k|                count += _mm_popcnt_u32(r);
  620|   197k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  621|   197k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  622|   197k|                if (a_max <= b_max) {
  ------------------
  |  Branch (622:21): [True: 85.2k, False: 111k]
  ------------------
  623|  85.2k|                    i_a += vectorlength;
  624|  85.2k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (624:25): [True: 3.80k, False: 81.4k]
  ------------------
  625|  81.4k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  626|  81.4k|                }
  627|   193k|                if (b_max <= a_max) {
  ------------------
  |  Branch (627:21): [True: 118k, False: 75.3k]
  ------------------
  628|   118k|                    i_b += vectorlength;
  629|   118k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (629:25): [True: 3.53k, False: 114k]
  ------------------
  630|   114k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  631|   114k|                }
  632|   193k|            }
  633|  8.18k|    }
  634|       |    // intersect the tail using scalar intersection
  635|   236k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (635:12): [True: 228k, False: 8.41k]
  |  Branch (635:25): [True: 225k, False: 3.22k]
  ------------------
  636|   225k|        uint16_t a = A[i_a];
  637|   225k|        uint16_t b = B[i_b];
  638|   225k|        if (a < b) {
  ------------------
  |  Branch (638:13): [True: 110k, False: 114k]
  ------------------
  639|   110k|            i_a++;
  640|   114k|        } else if (b < a) {
  ------------------
  |  Branch (640:20): [True: 77.3k, False: 36.7k]
  ------------------
  641|  77.3k|            i_b++;
  642|  77.3k|        } else {
  643|  36.7k|            count++;
  644|  36.7k|            i_a++;
  645|  36.7k|            i_b++;
  646|  36.7k|        }
  647|   225k|    }
  648|  11.6k|    return (int32_t)count;
  649|  11.6k|}
difference_vector16:
  659|  2.13k|                            size_t s_b, uint16_t *C) {
  660|       |    // we handle the degenerate case
  661|  2.13k|    if (s_a == 0) return 0;
  ------------------
  |  Branch (661:9): [True: 0, False: 2.13k]
  ------------------
  662|  2.13k|    if (s_b == 0) {
  ------------------
  |  Branch (662:9): [True: 0, False: 2.13k]
  ------------------
  663|      0|        if (A != C) memcpy(C, A, sizeof(uint16_t) * s_a);
  ------------------
  |  Branch (663:13): [True: 0, False: 0]
  ------------------
  664|      0|        return (int32_t)s_a;
  665|      0|    }
  666|       |    // handle the leading zeroes, it is messy but it allows us to use the fast
  667|       |    // _mm_cmpistrm instrinsic safely
  668|  2.13k|    int32_t count = 0;
  669|  2.13k|    if ((A[0] == 0) || (B[0] == 0)) {
  ------------------
  |  Branch (669:9): [True: 2.04k, False: 89]
  |  Branch (669:24): [True: 1, False: 88]
  ------------------
  670|  2.04k|        if ((A[0] == 0) && (B[0] == 0)) {
  ------------------
  |  Branch (670:13): [True: 2.04k, False: 1]
  |  Branch (670:28): [True: 354, False: 1.69k]
  ------------------
  671|    354|            A++;
  672|    354|            s_a--;
  673|    354|            B++;
  674|    354|            s_b--;
  675|  1.69k|        } else if (A[0] == 0) {
  ------------------
  |  Branch (675:20): [True: 1.69k, False: 1]
  ------------------
  676|  1.69k|            C[count++] = 0;
  677|  1.69k|            A++;
  678|  1.69k|            s_a--;
  679|  1.69k|        } else {
  680|      1|            B++;
  681|      1|            s_b--;
  682|      1|        }
  683|  2.04k|    }
  684|       |    // at this point, we have two non-empty arrays, made of non-zero
  685|       |    // increasing values.
  686|  2.13k|    size_t i_a = 0, i_b = 0;
  687|  2.13k|    const size_t vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  688|  2.13k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  689|  2.13k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  690|  2.13k|    if ((i_a < st_a) && (i_b < st_b)) {  // this is the vectorized code path
  ------------------
  |  Branch (690:9): [True: 2.11k, False: 27]
  |  Branch (690:25): [True: 2.10k, False: 2]
  ------------------
  691|  2.10k|        __m128i v_a, v_b;                //, v_bmax;
  692|       |        // we load a vector from A and a vector from B
  693|  2.10k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  694|  2.10k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  695|       |        // we have a runningmask which indicates which values from A have been
  696|       |        // spotted in B, these don't get written out.
  697|  2.10k|        __m128i runningmask_a_found_in_b = _mm_setzero_si128();
  698|       |        /****
  699|       |         * start of the main vectorized loop
  700|       |         *****/
  701|  53.5k|        while (true) {
  ------------------
  |  Branch (701:16): [True: 53.5k, Folded]
  ------------------
  702|       |            // afoundinb will contain a mask indicate for each entry in A
  703|       |            // whether it is seen
  704|       |            // in B
  705|  53.5k|            const __m128i a_found_in_b = _mm_cmpistrm(
  706|  53.5k|                v_b, v_a,
  707|  53.5k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  708|  53.5k|            runningmask_a_found_in_b =
  709|  53.5k|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  710|       |            // we always compare the last values of A and B
  711|  53.5k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  712|  53.5k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  713|  53.5k|            if (a_max <= b_max) {
  ------------------
  |  Branch (713:17): [True: 23.5k, False: 29.9k]
  ------------------
  714|       |                // Ok. In this code path, we are ready to write our v_a
  715|       |                // because there is no need to read more from B, they will
  716|       |                // all be large values.
  717|  23.5k|                const int bitmask_belongs_to_difference =
  718|  23.5k|                    _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  719|       |                /*** next few lines are probably expensive *****/
  720|  23.5k|                __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  721|  23.5k|                                               bitmask_belongs_to_difference);
  722|  23.5k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  723|  23.5k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  724|  23.5k|                count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  725|       |                // we advance a
  726|  23.5k|                i_a += vectorlength;
  727|  23.5k|                if (i_a == st_a)  // no more
  ------------------
  |  Branch (727:21): [True: 1.29k, False: 22.2k]
  ------------------
  728|  1.29k|                    break;
  729|  22.2k|                runningmask_a_found_in_b = _mm_setzero_si128();
  730|  22.2k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  731|  22.2k|            }
  732|  52.2k|            if (b_max <= a_max) {
  ------------------
  |  Branch (732:17): [True: 33.5k, False: 18.7k]
  ------------------
  733|       |                // in this code path, the current v_b has become useless
  734|  33.5k|                i_b += vectorlength;
  735|  33.5k|                if (i_b == st_b) break;
  ------------------
  |  Branch (735:21): [True: 815, False: 32.7k]
  ------------------
  736|  32.7k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  737|  32.7k|            }
  738|  52.2k|        }
  739|       |        // at this point, either we have i_a == st_a, which is the end of the
  740|       |        // vectorized processing,
  741|       |        // or we have i_b == st_b,  and we are not done processing the vector...
  742|       |        // so we need to finish it off.
  743|  2.10k|        if (i_a < st_a) {        // we have unfinished business...
  ------------------
  |  Branch (743:13): [True: 815, False: 1.29k]
  ------------------
  744|    815|            uint16_t buffer[8];  // buffer to do a masked load
  745|    815|            memset(buffer, 0, 8 * sizeof(uint16_t));
  746|    815|            memcpy(buffer, B + i_b, (s_b - i_b) * sizeof(uint16_t));
  747|    815|            v_b = _mm_lddqu_si128((__m128i *)buffer);
  748|    815|            const __m128i a_found_in_b = _mm_cmpistrm(
  749|    815|                v_b, v_a,
  750|    815|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  751|    815|            runningmask_a_found_in_b =
  752|    815|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  753|    815|            const int bitmask_belongs_to_difference =
  754|    815|                _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  755|    815|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  756|    815|                                           bitmask_belongs_to_difference);
  757|    815|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  758|    815|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  759|    815|            count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  760|    815|            i_a += vectorlength;
  761|    815|        }
  762|       |        // at this point we should have i_a == st_a and i_b == st_b
  763|  2.10k|    }
  764|       |    // do the tail using scalar code
  765|  36.8k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (765:12): [True: 35.2k, False: 1.67k]
  |  Branch (765:25): [True: 34.7k, False: 465]
  ------------------
  766|  34.7k|        uint16_t a = A[i_a];
  767|  34.7k|        uint16_t b = B[i_b];
  768|  34.7k|        if (b < a) {
  ------------------
  |  Branch (768:13): [True: 21.2k, False: 13.4k]
  ------------------
  769|  21.2k|            i_b++;
  770|  21.2k|        } else if (a < b) {
  ------------------
  |  Branch (770:20): [True: 8.63k, False: 4.84k]
  ------------------
  771|  8.63k|            C[count] = a;
  772|  8.63k|            count++;
  773|  8.63k|            i_a++;
  774|  8.63k|        } else {  //==
  775|  4.84k|            i_a++;
  776|  4.84k|            i_b++;
  777|  4.84k|        }
  778|  34.7k|    }
  779|  2.13k|    if (i_a < s_a) {
  ------------------
  |  Branch (779:9): [True: 465, False: 1.67k]
  ------------------
  780|    465|        if (C == A) {
  ------------------
  |  Branch (780:13): [True: 0, False: 465]
  ------------------
  781|      0|            assert((size_t)count <= i_a);
  782|      0|            if ((size_t)count < i_a) {
  ------------------
  |  Branch (782:17): [True: 0, False: 0]
  ------------------
  783|      0|                memmove(C + count, A + i_a, sizeof(uint16_t) * (s_a - i_a));
  784|      0|            }
  785|    465|        } else {
  786|  12.7k|            for (size_t i = 0; i < (s_a - i_a); i++) {
  ------------------
  |  Branch (786:32): [True: 12.3k, False: 465]
  ------------------
  787|  12.3k|                C[count + i] = A[i + i_a];
  788|  12.3k|            }
  789|    465|        }
  790|    465|        count += (int32_t)(s_a - i_a);
  791|    465|    }
  792|  2.13k|    return count;
  793|  2.13k|}
intersect_skewed_uint16:
  861|    671|                                uint16_t *buffer) {
  862|    671|    size_t pos = 0, idx_l = 0, idx_s = 0;
  863|       |
  864|    671|    if (0 == size_s) {
  ------------------
  |  Branch (864:9): [True: 0, False: 671]
  ------------------
  865|      0|        return 0;
  866|      0|    }
  867|    671|    int32_t index1 = 0, index2 = 0, index3 = 0, index4 = 0;
  868|  1.81k|    while ((idx_s + 4 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (868:12): [True: 1.14k, False: 671]
  |  Branch (868:37): [True: 1.14k, False: 0]
  ------------------
  869|  1.14k|        uint16_t target1 = small[idx_s];
  870|  1.14k|        uint16_t target2 = small[idx_s + 1];
  871|  1.14k|        uint16_t target3 = small[idx_s + 2];
  872|  1.14k|        uint16_t target4 = small[idx_s + 3];
  873|  1.14k|        binarySearch4(large + idx_l, (int32_t)(size_l - idx_l), target1,
  874|  1.14k|                      target2, target3, target4, &index1, &index2, &index3,
  875|  1.14k|                      &index4);
  876|  1.14k|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (876:13): [True: 1.14k, False: 1]
  |  Branch (876:42): [True: 618, False: 524]
  ------------------
  877|    618|            buffer[pos++] = target1;
  878|    618|        }
  879|  1.14k|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (879:13): [True: 1.14k, False: 2]
  |  Branch (879:42): [True: 768, False: 373]
  ------------------
  880|    768|            buffer[pos++] = target2;
  881|    768|        }
  882|  1.14k|        if ((index3 + idx_l < size_l) && (large[idx_l + index3] == target3)) {
  ------------------
  |  Branch (882:13): [True: 1.14k, False: 3]
  |  Branch (882:42): [True: 740, False: 400]
  ------------------
  883|    740|            buffer[pos++] = target3;
  884|    740|        }
  885|  1.14k|        if ((index4 + idx_l < size_l) && (large[idx_l + index4] == target4)) {
  ------------------
  |  Branch (885:13): [True: 1.13k, False: 7]
  |  Branch (885:42): [True: 719, False: 417]
  ------------------
  886|    719|            buffer[pos++] = target4;
  887|    719|        }
  888|  1.14k|        idx_s += 4;
  889|  1.14k|        idx_l += index4;
  890|  1.14k|    }
  891|    671|    if ((idx_s + 2 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (891:9): [True: 342, False: 329]
  |  Branch (891:34): [True: 341, False: 1]
  ------------------
  892|    341|        uint16_t target1 = small[idx_s];
  893|    341|        uint16_t target2 = small[idx_s + 1];
  894|    341|        binarySearch2(large + idx_l, (int32_t)(size_l - idx_l), target1,
  895|    341|                      target2, &index1, &index2);
  896|    341|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (896:13): [True: 336, False: 5]
  |  Branch (896:42): [True: 222, False: 114]
  ------------------
  897|    222|            buffer[pos++] = target1;
  898|    222|        }
  899|    341|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (899:13): [True: 325, False: 16]
  |  Branch (899:42): [True: 231, False: 94]
  ------------------
  900|    231|            buffer[pos++] = target2;
  901|    231|        }
  902|    341|        idx_s += 2;
  903|    341|        idx_l += index2;
  904|    341|    }
  905|    671|    if ((idx_s < size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (905:9): [True: 310, False: 361]
  |  Branch (905:29): [True: 308, False: 2]
  ------------------
  906|    308|        uint16_t val_s = small[idx_s];
  907|    308|        int32_t index =
  908|    308|            binarySearch(large + idx_l, (int32_t)(size_l - idx_l), val_s);
  909|    308|        if (index >= 0) buffer[pos++] = val_s;
  ------------------
  |  Branch (909:13): [True: 218, False: 90]
  ------------------
  910|    308|    }
  911|    671|    return (int32_t)pos;
  912|    671|}
intersect_skewed_uint16_cardinality:
  918|  1.95k|                                            size_t size_l) {
  919|  1.95k|    size_t pos = 0, idx_l = 0, idx_s = 0;
  920|       |
  921|  1.95k|    if (0 == size_s) {
  ------------------
  |  Branch (921:9): [True: 0, False: 1.95k]
  ------------------
  922|      0|        return 0;
  923|      0|    }
  924|       |
  925|  1.95k|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  926|       |
  927|  25.4k|    while (true) {
  ------------------
  |  Branch (927:12): [True: 25.4k, Folded]
  ------------------
  928|  25.4k|        if (val_l < val_s) {
  ------------------
  |  Branch (928:13): [True: 4.79k, False: 20.6k]
  ------------------
  929|  4.79k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  930|  4.79k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (930:17): [True: 144, False: 4.64k]
  ------------------
  931|  4.64k|            val_l = large[idx_l];
  932|  20.6k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (932:20): [True: 7.92k, False: 12.7k]
  ------------------
  933|  7.92k|            idx_s++;
  934|  7.92k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (934:17): [True: 696, False: 7.22k]
  ------------------
  935|  7.22k|            val_s = small[idx_s];
  936|  12.7k|        } else {
  937|  12.7k|            pos++;
  938|  12.7k|            idx_s++;
  939|  12.7k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (939:17): [True: 1.04k, False: 11.6k]
  ------------------
  940|  11.6k|            val_s = small[idx_s];
  941|  11.6k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  942|  11.6k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (942:17): [True: 76, False: 11.6k]
  ------------------
  943|  11.6k|            val_l = large[idx_l];
  944|  11.6k|        }
  945|  25.4k|    }
  946|       |
  947|  1.95k|    return (int32_t)pos;
  948|  1.95k|}
intersect_skewed_uint16_nonempty:
  951|    489|                                      const uint16_t *large, size_t size_l) {
  952|    489|    size_t idx_l = 0, idx_s = 0;
  953|       |
  954|    489|    if (0 == size_s) {
  ------------------
  |  Branch (954:9): [True: 0, False: 489]
  ------------------
  955|      0|        return false;
  956|      0|    }
  957|       |
  958|    489|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  959|       |
  960|  2.01k|    while (true) {
  ------------------
  |  Branch (960:12): [True: 2.01k, Folded]
  ------------------
  961|  2.01k|        if (val_l < val_s) {
  ------------------
  |  Branch (961:13): [True: 755, False: 1.26k]
  ------------------
  962|    755|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  963|    755|            if (idx_l == size_l) break;
  ------------------
  |  Branch (963:17): [True: 34, False: 721]
  ------------------
  964|    721|            val_l = large[idx_l];
  965|  1.26k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (965:20): [True: 873, False: 387]
  ------------------
  966|    873|            idx_s++;
  967|    873|            if (idx_s == size_s) break;
  ------------------
  |  Branch (967:17): [True: 68, False: 805]
  ------------------
  968|    805|            val_s = small[idx_s];
  969|    805|        } else {
  970|    387|            return true;
  971|    387|        }
  972|  2.01k|    }
  973|       |
  974|    102|    return false;
  975|    489|}
intersect_uint16_nonempty:
 1239|  2.91k|                               const uint16_t *B, const size_t lenB) {
 1240|  2.91k|    if (lenA == 0 || lenB == 0) return 0;
  ------------------
  |  Branch (1240:9): [True: 0, False: 2.91k]
  |  Branch (1240:22): [True: 0, False: 2.91k]
  ------------------
 1241|  2.91k|    const uint16_t *endA = A + lenA;
 1242|  2.91k|    const uint16_t *endB = B + lenB;
 1243|       |
 1244|  2.91k|    while (1) {
  ------------------
  |  Branch (1244:12): [True: 2.91k, Folded]
  ------------------
 1245|  15.8k|        while (*A < *B) {
  ------------------
  |  Branch (1245:16): [True: 12.2k, False: 3.65k]
  ------------------
 1246|  13.0k|        SKIP_FIRST_COMPARE:
 1247|  13.0k|            if (++A == endA) return false;
  ------------------
  |  Branch (1247:17): [True: 64, False: 12.9k]
  ------------------
 1248|  13.0k|        }
 1249|  9.26k|        while (*A > *B) {
  ------------------
  |  Branch (1249:16): [True: 5.62k, False: 3.63k]
  ------------------
 1250|  5.62k|            if (++B == endB) return false;
  ------------------
  |  Branch (1250:17): [True: 13, False: 5.60k]
  ------------------
 1251|  5.62k|        }
 1252|  3.63k|        if (*A == *B) {
  ------------------
  |  Branch (1252:13): [True: 2.83k, False: 804]
  ------------------
 1253|  2.83k|            return true;
 1254|  2.83k|        } else {
 1255|    804|            goto SKIP_FIRST_COMPARE;
 1256|    804|        }
 1257|  3.63k|    }
 1258|      0|    return false;  // NOTREACHED
 1259|  2.91k|}
union_uint16:
 1320|  6.75k|                    size_t size_2, uint16_t *buffer) {
 1321|       |    // Every write goes before buffer + idx_1 + size_2, so buffer may start
 1322|       |    // size_2 values before set_1 (array_array_container_inplace_union).
 1323|  6.75k|    if (croaring_skewed_sizes(size_1, size_2)) {
  ------------------
  |  Branch (1323:9): [True: 1.14k, False: 5.61k]
  ------------------
 1324|  1.14k|        return union_skewed_uint16(set_1, size_1, set_2, size_2, buffer);
 1325|  1.14k|    }
 1326|  5.61k|    if (croaring_skewed_sizes(size_2, size_1)) {
  ------------------
  |  Branch (1326:9): [True: 357, False: 5.25k]
  ------------------
 1327|    357|        return union_skewed_uint16(set_2, size_2, set_1, size_1, buffer);
 1328|    357|    }
 1329|  5.25k|    size_t pos = 0, idx_1 = 0, idx_2 = 0;
 1330|  18.9k|    while (idx_1 + 4 <= size_1 && idx_2 + 4 <= size_2) {
  ------------------
  |  Branch (1330:12): [True: 14.0k, False: 4.89k]
  |  Branch (1330:35): [True: 13.6k, False: 362]
  ------------------
 1331|  13.6k|        if (set_1[idx_1 + 3] < set_2[idx_2]) {
  ------------------
  |  Branch (1331:13): [True: 429, False: 13.2k]
  ------------------
 1332|    429|            memmove(buffer + pos, set_1 + idx_1, 4 * sizeof(uint16_t));
 1333|    429|            pos += 4;
 1334|    429|            idx_1 += 4;
 1335|  13.2k|        } else if (set_2[idx_2 + 3] < set_1[idx_1]) {
  ------------------
  |  Branch (1335:20): [True: 1.49k, False: 11.7k]
  ------------------
 1336|  1.49k|            memmove(buffer + pos, set_2 + idx_2, 4 * sizeof(uint16_t));
 1337|  1.49k|            pos += 4;
 1338|  1.49k|            idx_2 += 4;
 1339|  11.7k|        } else if (croaring_equal4_uint16(set_1 + idx_1, set_2 + idx_2)) {
  ------------------
  |  Branch (1339:20): [True: 5.17k, False: 6.58k]
  ------------------
 1340|  5.17k|            memmove(buffer + pos, set_1 + idx_1, 4 * sizeof(uint16_t));
 1341|  5.17k|            pos += 4;
 1342|  5.17k|            idx_1 += 4;
 1343|  5.17k|            idx_2 += 4;
 1344|  6.58k|        } else {
 1345|  32.9k|            for (int step = 0; step < 4; step++) {
  ------------------
  |  Branch (1345:32): [True: 26.3k, False: 6.58k]
  ------------------
 1346|  26.3k|                const uint16_t val_1 = set_1[idx_1], val_2 = set_2[idx_2];
 1347|  26.3k|                buffer[pos++] = val_1 < val_2 ? val_1 : val_2;
  ------------------
  |  Branch (1347:33): [True: 5.72k, False: 20.6k]
  ------------------
 1348|  26.3k|                idx_1 += (val_1 <= val_2);
 1349|  26.3k|                idx_2 += (val_1 >= val_2);
 1350|  26.3k|            }
 1351|  6.58k|        }
 1352|  13.6k|    }
 1353|       |    // Fewer than four values remain on one side. If many remain on the
 1354|       |    // other, gallop rather than step through them one at a time.
 1355|  5.25k|    const size_t rem_1 = size_1 - idx_1, rem_2 = size_2 - idx_2;
 1356|  5.25k|    if (croaring_skewed_sizes(rem_1, rem_2)) {
  ------------------
  |  Branch (1356:9): [True: 712, False: 4.54k]
  ------------------
 1357|    712|        return pos + union_skewed_uint16(set_1 + idx_1, rem_1, set_2 + idx_2,
 1358|    712|                                         rem_2, buffer + pos);
 1359|    712|    }
 1360|  4.54k|    if (croaring_skewed_sizes(rem_2, rem_1)) {
  ------------------
  |  Branch (1360:9): [True: 96, False: 4.44k]
  ------------------
 1361|     96|        return pos + union_skewed_uint16(set_2 + idx_2, rem_2, set_1 + idx_1,
 1362|     96|                                         rem_1, buffer + pos);
 1363|     96|    }
 1364|  17.0k|    while (idx_1 < size_1 && idx_2 < size_2) {
  ------------------
  |  Branch (1364:12): [True: 12.9k, False: 4.15k]
  |  Branch (1364:30): [True: 12.6k, False: 293]
  ------------------
 1365|  12.6k|        const uint16_t val_1 = set_1[idx_1], val_2 = set_2[idx_2];
 1366|  12.6k|        buffer[pos++] = val_1 < val_2 ? val_1 : val_2;
  ------------------
  |  Branch (1366:25): [True: 1.17k, False: 11.4k]
  ------------------
 1367|  12.6k|        idx_1 += (val_1 <= val_2);
 1368|  12.6k|        idx_2 += (val_1 >= val_2);
 1369|  12.6k|    }
 1370|  4.44k|    if (idx_1 < size_1) {
  ------------------
  |  Branch (1370:9): [True: 293, False: 4.15k]
  ------------------
 1371|    293|        const size_t n_elems = size_1 - idx_1;
 1372|    293|        memmove(buffer + pos, set_1 + idx_1, n_elems * sizeof(uint16_t));
 1373|    293|        pos += n_elems;
 1374|  4.15k|    } else if (idx_2 < size_2) {
  ------------------
  |  Branch (1374:16): [True: 968, False: 3.18k]
  ------------------
 1375|    968|        const size_t n_elems = size_2 - idx_2;
 1376|    968|        memmove(buffer + pos, set_2 + idx_2, n_elems * sizeof(uint16_t));
 1377|    968|        pos += n_elems;
 1378|    968|    }
 1379|  4.44k|    return pos;
 1380|  4.54k|}
difference_uint16:
 1384|  5.68k|                      int length2, uint16_t *a_out) {
 1385|       |    // Every write goes to a_out[k..] with k <= i, so a_out may be a1.
 1386|  5.68k|    if (croaring_skewed_sizes((size_t)length2, (size_t)length1)) {
  ------------------
  |  Branch (1386:9): [True: 1.04k, False: 4.63k]
  ------------------
 1387|  1.04k|        return difference_skewed_small_a2_uint16(a1, length1, a2, length2,
 1388|  1.04k|                                                 a_out);
 1389|  1.04k|    }
 1390|  4.63k|    if (croaring_skewed_sizes((size_t)length1, (size_t)length2)) {
  ------------------
  |  Branch (1390:9): [True: 303, False: 4.33k]
  ------------------
 1391|    303|        return difference_skewed_small_a1_uint16(a1, length1, a2, length2,
 1392|    303|                                                 a_out);
 1393|    303|    }
 1394|  4.33k|    int i = 0, j = 0, k = 0;
 1395|  77.7k|    while (i + 4 <= length1 && j + 4 <= length2) {
  ------------------
  |  Branch (1395:12): [True: 74.7k, False: 2.98k]
  |  Branch (1395:32): [True: 73.4k, False: 1.34k]
  ------------------
 1396|  73.4k|        if (a1[i + 3] < a2[j]) {
  ------------------
  |  Branch (1396:13): [True: 8.35k, False: 65.0k]
  ------------------
 1397|  8.35k|            memmove(a_out + k, a1 + i, 4 * sizeof(uint16_t));
 1398|  8.35k|            k += 4;
 1399|  8.35k|            i += 4;
 1400|  65.0k|        } else if (a2[j + 3] < a1[i]) {
  ------------------
  |  Branch (1400:20): [True: 35, False: 65.0k]
  ------------------
 1401|     35|            j += 4;
 1402|  65.0k|        } else if (croaring_equal4_uint16(a1 + i, a2 + j)) {
  ------------------
  |  Branch (1402:20): [True: 32.0k, False: 33.0k]
  ------------------
 1403|  32.0k|            i += 4;
 1404|  32.0k|            j += 4;
 1405|  33.0k|        } else {
 1406|   165k|            for (int step = 0; step < 4; step++) {
  ------------------
  |  Branch (1406:32): [True: 132k, False: 33.0k]
  ------------------
 1407|   132k|                const uint16_t a = a1[i], b = a2[j];
 1408|   132k|                a_out[k] = a;
 1409|   132k|                k += (a < b);
 1410|   132k|                i += (a <= b);
 1411|   132k|                j += (a >= b);
 1412|   132k|            }
 1413|  33.0k|        }
 1414|  73.4k|    }
 1415|       |    // Fewer than four values remain on one side. If many remain on the
 1416|       |    // other, gallop rather than step through them one at a time.
 1417|  4.33k|    const int rem_1 = length1 - i, rem_2 = length2 - j;
 1418|  4.33k|    if (croaring_skewed_sizes((size_t)rem_2, (size_t)rem_1)) {
  ------------------
  |  Branch (1418:9): [True: 354, False: 3.97k]
  ------------------
 1419|    354|        return k + difference_skewed_small_a2_uint16(a1 + i, rem_1, a2 + j,
 1420|    354|                                                     rem_2, a_out + k);
 1421|    354|    }
 1422|  3.97k|    if (croaring_skewed_sizes((size_t)rem_1, (size_t)rem_2)) {
  ------------------
  |  Branch (1422:9): [True: 105, False: 3.87k]
  ------------------
 1423|    105|        return k + difference_skewed_small_a1_uint16(a1 + i, rem_1, a2 + j,
 1424|    105|                                                     rem_2, a_out + k);
 1425|    105|    }
 1426|  14.7k|    while (i < length1 && j < length2) {
  ------------------
  |  Branch (1426:12): [True: 11.7k, False: 2.96k]
  |  Branch (1426:27): [True: 10.8k, False: 904]
  ------------------
 1427|  10.8k|        const uint16_t a = a1[i], b = a2[j];
 1428|  10.8k|        a_out[k] = a;
 1429|  10.8k|        k += (a < b);
 1430|  10.8k|        i += (a <= b);
 1431|  10.8k|        j += (a >= b);
 1432|  10.8k|    }
 1433|  3.87k|    if (i < length1) {
  ------------------
  |  Branch (1433:9): [True: 904, False: 2.96k]
  ------------------
 1434|    904|        memmove(a_out + k, a1 + i, sizeof(uint16_t) * (length1 - i));
 1435|    904|        k += length1 - i;
 1436|    904|    }
 1437|  3.87k|    return k;
 1438|  3.97k|}
xor_uint16:
 1442|  9.29k|                   const uint16_t *array_2, int32_t card_2, uint16_t *out) {
 1443|  9.29k|    if (croaring_skewed_sizes((size_t)card_1, (size_t)card_2)) {
  ------------------
  |  Branch (1443:9): [True: 1.55k, False: 7.74k]
  ------------------
 1444|  1.55k|        return xor_skewed_uint16(array_1, (size_t)card_1, array_2,
 1445|  1.55k|                                 (size_t)card_2, out);
 1446|  1.55k|    }
 1447|  7.74k|    if (croaring_skewed_sizes((size_t)card_2, (size_t)card_1)) {
  ------------------
  |  Branch (1447:9): [True: 433, False: 7.31k]
  ------------------
 1448|    433|        return xor_skewed_uint16(array_2, (size_t)card_2, array_1,
 1449|    433|                                 (size_t)card_1, out);
 1450|    433|    }
 1451|  7.31k|    int32_t pos1 = 0, pos2 = 0, pos_out = 0;
 1452|  22.6k|    while (pos1 + 4 <= card_1 && pos2 + 4 <= card_2) {
  ------------------
  |  Branch (1452:12): [True: 15.7k, False: 6.86k]
  |  Branch (1452:34): [True: 15.3k, False: 444]
  ------------------
 1453|  15.3k|        if (array_1[pos1 + 3] < array_2[pos2]) {
  ------------------
  |  Branch (1453:13): [True: 546, False: 14.7k]
  ------------------
 1454|    546|            memcpy(out + pos_out, array_1 + pos1, 4 * sizeof(uint16_t));
 1455|    546|            pos_out += 4;
 1456|    546|            pos1 += 4;
 1457|  14.7k|        } else if (array_2[pos2 + 3] < array_1[pos1]) {
  ------------------
  |  Branch (1457:20): [True: 2.57k, False: 12.1k]
  ------------------
 1458|  2.57k|            memcpy(out + pos_out, array_2 + pos2, 4 * sizeof(uint16_t));
 1459|  2.57k|            pos_out += 4;
 1460|  2.57k|            pos2 += 4;
 1461|  12.1k|        } else if (croaring_equal4_uint16(array_1 + pos1, array_2 + pos2)) {
  ------------------
  |  Branch (1461:20): [True: 4.07k, False: 8.11k]
  ------------------
 1462|  4.07k|            pos1 += 4;
 1463|  4.07k|            pos2 += 4;
 1464|  8.11k|        } else {
 1465|  40.5k|            for (int step = 0; step < 4; step++) {
  ------------------
  |  Branch (1465:32): [True: 32.4k, False: 8.11k]
  ------------------
 1466|  32.4k|                const uint16_t v1 = array_1[pos1], v2 = array_2[pos2];
 1467|  32.4k|                out[pos_out] = v1 < v2 ? v1 : v2;
  ------------------
  |  Branch (1467:32): [True: 6.17k, False: 26.2k]
  ------------------
 1468|  32.4k|                pos_out += (v1 != v2);
 1469|  32.4k|                pos1 += (v1 <= v2);
 1470|  32.4k|                pos2 += (v1 >= v2);
 1471|  32.4k|            }
 1472|  8.11k|        }
 1473|  15.3k|    }
 1474|       |    // Fewer than four values remain on one side. If many remain on the
 1475|       |    // other, gallop rather than step through them one at a time.
 1476|  7.31k|    const size_t rem_1 = (size_t)(card_1 - pos1),
 1477|  7.31k|                 rem_2 = (size_t)(card_2 - pos2);
 1478|  7.31k|    if (croaring_skewed_sizes(rem_1, rem_2)) {
  ------------------
  |  Branch (1478:9): [True: 558, False: 6.75k]
  ------------------
 1479|    558|        return pos_out + xor_skewed_uint16(array_1 + pos1, rem_1,
 1480|    558|                                           array_2 + pos2, rem_2,
 1481|    558|                                           out + pos_out);
 1482|    558|    }
 1483|  6.75k|    if (croaring_skewed_sizes(rem_2, rem_1)) {
  ------------------
  |  Branch (1483:9): [True: 213, False: 6.54k]
  ------------------
 1484|    213|        return pos_out + xor_skewed_uint16(array_2 + pos2, rem_2,
 1485|    213|                                           array_1 + pos1, rem_1,
 1486|    213|                                           out + pos_out);
 1487|    213|    }
 1488|  23.5k|    while (pos1 < card_1 && pos2 < card_2) {
  ------------------
  |  Branch (1488:12): [True: 17.4k, False: 6.16k]
  |  Branch (1488:29): [True: 17.0k, False: 380]
  ------------------
 1489|  17.0k|        const uint16_t v1 = array_1[pos1], v2 = array_2[pos2];
 1490|  17.0k|        out[pos_out] = v1 < v2 ? v1 : v2;
  ------------------
  |  Branch (1490:24): [True: 1.48k, False: 15.5k]
  ------------------
 1491|  17.0k|        pos_out += (v1 != v2);
 1492|  17.0k|        pos1 += (v1 <= v2);
 1493|  17.0k|        pos2 += (v1 >= v2);
 1494|  17.0k|    }
 1495|  6.54k|    if (pos1 < card_1) {
  ------------------
  |  Branch (1495:9): [True: 380, False: 6.16k]
  ------------------
 1496|    380|        const size_t n_elems = card_1 - pos1;
 1497|    380|        memcpy(out + pos_out, array_1 + pos1, n_elems * sizeof(uint16_t));
 1498|    380|        pos_out += (int32_t)n_elems;
 1499|  6.16k|    } else if (pos2 < card_2) {
  ------------------
  |  Branch (1499:16): [True: 1.02k, False: 5.13k]
  ------------------
 1500|  1.02k|        const size_t n_elems = card_2 - pos2;
 1501|  1.02k|        memcpy(out + pos_out, array_2 + pos2, n_elems * sizeof(uint16_t));
 1502|  1.02k|        pos_out += (int32_t)n_elems;
 1503|  1.02k|    }
 1504|  6.54k|    return pos_out;
 1505|  6.75k|}
union_vector16:
 1936|  5.86k|                        uint16_t *output) {
 1937|  5.86k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1937:9): [True: 1.12k, False: 4.74k]
  |  Branch (1937:26): [True: 0, False: 4.74k]
  ------------------
 1938|  1.12k|        return (uint32_t)union_uint16(array1, length1, array2, length2, output);
 1939|  1.12k|    }
 1940|  4.74k|    __m128i vA, vB, V, vecMin, vecMax;
 1941|  4.74k|    __m128i laststore;
 1942|  4.74k|    uint16_t *initoutput = output;
 1943|  4.74k|    uint32_t len1 = length1 / 8;
 1944|  4.74k|    uint32_t len2 = length2 / 8;
 1945|  4.74k|    uint32_t pos1 = 0;
 1946|  4.74k|    uint32_t pos2 = 0;
 1947|       |    // we start the machine
 1948|  4.74k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1949|  4.74k|    pos1++;
 1950|  4.74k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1951|  4.74k|    pos2++;
 1952|  4.74k|    sse_merge(vA, vB, &vecMin, &vecMax);
 1953|  4.74k|    laststore = _mm_set1_epi16(-1);
 1954|  4.74k|    output += store_unique(laststore, vecMin, output);
 1955|  4.74k|    laststore = vecMin;
 1956|  4.74k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1956:9): [True: 3.86k, False: 879]
  |  Branch (1956:26): [True: 3.86k, False: 0]
  ------------------
 1957|  3.86k|        uint16_t curA, curB;
 1958|  3.86k|        curA = array1[8 * pos1];
 1959|  3.86k|        curB = array2[8 * pos2];
 1960|   112k|        while (true) {
  ------------------
  |  Branch (1960:16): [True: 112k, Folded]
  ------------------
 1961|   112k|            if (curA <= curB) {
  ------------------
  |  Branch (1961:17): [True: 47.8k, False: 64.9k]
  ------------------
 1962|  47.8k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1963|  47.8k|                pos1++;
 1964|  47.8k|                if (pos1 < len1) {
  ------------------
  |  Branch (1964:21): [True: 44.8k, False: 3.01k]
  ------------------
 1965|  44.8k|                    curA = array1[8 * pos1];
 1966|  44.8k|                } else {
 1967|  3.01k|                    break;
 1968|  3.01k|                }
 1969|  64.9k|            } else {
 1970|  64.9k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1971|  64.9k|                pos2++;
 1972|  64.9k|                if (pos2 < len2) {
  ------------------
  |  Branch (1972:21): [True: 64.1k, False: 846]
  ------------------
 1973|  64.1k|                    curB = array2[8 * pos2];
 1974|  64.1k|                } else {
 1975|    846|                    break;
 1976|    846|                }
 1977|  64.9k|            }
 1978|   108k|            sse_merge(vecMax, V, &vecMin, &vecMax);
 1979|   108k|            output += store_unique(laststore, vecMin, output);
 1980|   108k|            laststore = vecMin;
 1981|   108k|        }
 1982|  3.86k|        sse_merge(vecMax, V, &vecMin, &vecMax);
 1983|  3.86k|        output += store_unique(laststore, vecMin, output);
 1984|  3.86k|        laststore = vecMin;
 1985|  3.86k|    }
 1986|       |    // we finish the rest off using a scalar algorithm
 1987|       |    // could be improved?
 1988|       |    //
 1989|       |    // copy the small end on a tmp buffer
 1990|  4.74k|    uint32_t len = (uint32_t)(output - initoutput);
 1991|  4.74k|    uint16_t buffer[16];
 1992|  4.74k|    uint32_t leftoversize = store_unique(laststore, vecMax, buffer);
 1993|  4.74k|    if (pos1 == len1) {
  ------------------
  |  Branch (1993:9): [True: 3.89k, False: 846]
  ------------------
 1994|  3.89k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1995|  3.89k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1996|  3.89k|        leftoversize += length1 - 8 * len1;
 1997|  3.89k|        sort_uint16_short(buffer, leftoversize);
 1998|       |
 1999|  3.89k|        leftoversize = unique(buffer, leftoversize);
 2000|  3.89k|        len += (uint32_t)union_uint16(buffer, leftoversize, array2 + 8 * pos2,
 2001|  3.89k|                                      length2 - 8 * pos2, output);
 2002|  3.89k|    } else {
 2003|    846|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 2004|    846|               (length2 - 8 * len2) * sizeof(uint16_t));
 2005|    846|        leftoversize += length2 - 8 * len2;
 2006|    846|        sort_uint16_short(buffer, leftoversize);
 2007|    846|        leftoversize = unique(buffer, leftoversize);
 2008|    846|        len += (uint32_t)union_uint16(buffer, leftoversize, array1 + 8 * pos1,
 2009|    846|                                      length1 - 8 * pos1, output);
 2010|    846|    }
 2011|  4.74k|    return len;
 2012|  5.86k|}
xor_vector16:
 2245|  8.34k|                      uint16_t *output) {
 2246|  8.34k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (2246:9): [True: 2.98k, False: 5.36k]
  |  Branch (2246:26): [True: 394, False: 4.96k]
  ------------------
 2247|  3.37k|        return xor_uint16(array1, length1, array2, length2, output);
 2248|  3.37k|    }
 2249|  4.96k|    __m128i vA, vB, V, vecMin, vecMax;
 2250|  4.96k|    __m128i laststore;
 2251|  4.96k|    uint16_t *initoutput = output;
 2252|  4.96k|    uint32_t len1 = length1 / 8;
 2253|  4.96k|    uint32_t len2 = length2 / 8;
 2254|  4.96k|    uint32_t pos1 = 0;
 2255|  4.96k|    uint32_t pos2 = 0;
 2256|       |    // we start the machine
 2257|  4.96k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 2258|  4.96k|    pos1++;
 2259|  4.96k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 2260|  4.96k|    pos2++;
 2261|  4.96k|    sse_merge(vA, vB, &vecMin, &vecMax);
 2262|  4.96k|    laststore = _mm_set1_epi16(-1);
 2263|  4.96k|    uint16_t buffer[17];
 2264|  4.96k|    output += store_unique_xor(laststore, vecMin, output);
 2265|       |
 2266|  4.96k|    laststore = vecMin;
 2267|  4.96k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (2267:9): [True: 4.46k, False: 505]
  |  Branch (2267:26): [True: 4.12k, False: 335]
  ------------------
 2268|  4.12k|        uint16_t curA, curB;
 2269|  4.12k|        curA = array1[8 * pos1];
 2270|  4.12k|        curB = array2[8 * pos2];
 2271|   188k|        while (true) {
  ------------------
  |  Branch (2271:16): [True: 188k, Folded]
  ------------------
 2272|   188k|            if (curA <= curB) {
  ------------------
  |  Branch (2272:17): [True: 90.1k, False: 98.5k]
  ------------------
 2273|  90.1k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 2274|  90.1k|                pos1++;
 2275|  90.1k|                if (pos1 < len1) {
  ------------------
  |  Branch (2275:21): [True: 87.5k, False: 2.59k]
  ------------------
 2276|  87.5k|                    curA = array1[8 * pos1];
 2277|  87.5k|                } else {
 2278|  2.59k|                    break;
 2279|  2.59k|                }
 2280|  98.5k|            } else {
 2281|  98.5k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 2282|  98.5k|                pos2++;
 2283|  98.5k|                if (pos2 < len2) {
  ------------------
  |  Branch (2283:21): [True: 97.0k, False: 1.52k]
  ------------------
 2284|  97.0k|                    curB = array2[8 * pos2];
 2285|  97.0k|                } else {
 2286|  1.52k|                    break;
 2287|  1.52k|                }
 2288|  98.5k|            }
 2289|   184k|            sse_merge(vecMax, V, &vecMin, &vecMax);
 2290|       |            // conditionally stores the last value of laststore as well as all
 2291|       |            // but the
 2292|       |            // last value of vecMin
 2293|   184k|            output += store_unique_xor(laststore, vecMin, output);
 2294|   184k|            laststore = vecMin;
 2295|   184k|        }
 2296|  4.12k|        sse_merge(vecMax, V, &vecMin, &vecMax);
 2297|       |        // conditionally stores the last value of laststore as well as all but
 2298|       |        // the
 2299|       |        // last value of vecMin
 2300|  4.12k|        output += store_unique_xor(laststore, vecMin, output);
 2301|  4.12k|        laststore = vecMin;
 2302|  4.12k|    }
 2303|  4.96k|    uint32_t len = (uint32_t)(output - initoutput);
 2304|       |
 2305|       |    // we finish the rest off using a scalar algorithm
 2306|       |    // could be improved?
 2307|       |    // conditionally stores the last value of laststore as well as all but the
 2308|       |    // last value of vecMax,
 2309|       |    // we store to "buffer"
 2310|  4.96k|    int leftoversize = store_unique_xor(laststore, vecMax, buffer);
 2311|  4.96k|    uint16_t vec7 = (uint16_t)_mm_extract_epi16(vecMax, 7);
 2312|  4.96k|    uint16_t vec6 = (uint16_t)_mm_extract_epi16(vecMax, 6);
 2313|  4.96k|    if (vec7 != vec6) buffer[leftoversize++] = vec7;
  ------------------
  |  Branch (2313:9): [True: 4.89k, False: 72]
  ------------------
 2314|  4.96k|    if (pos1 == len1) {
  ------------------
  |  Branch (2314:9): [True: 3.10k, False: 1.86k]
  ------------------
 2315|  3.10k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 2316|  3.10k|               (length1 - 8 * len1) * sizeof(uint16_t));
 2317|  3.10k|        leftoversize += length1 - 8 * len1;
 2318|  3.10k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (2318:13): [True: 9, False: 3.09k]
  ------------------
 2319|      9|            memcpy(output, array2 + 8 * pos2,
 2320|      9|                   (length2 - 8 * pos2) * sizeof(uint16_t));
 2321|      9|            len += (length2 - 8 * pos2);
 2322|  3.09k|        } else {
 2323|  3.09k|            sort_uint16_short(buffer, leftoversize);
 2324|  3.09k|            leftoversize = unique_xor(buffer, leftoversize);
 2325|  3.09k|            len += xor_uint16(buffer, leftoversize, array2 + 8 * pos2,
 2326|  3.09k|                              length2 - 8 * pos2, output);
 2327|  3.09k|        }
 2328|  3.10k|    } else {
 2329|  1.86k|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 2330|  1.86k|               (length2 - 8 * len2) * sizeof(uint16_t));
 2331|  1.86k|        leftoversize += length2 - 8 * len2;
 2332|  1.86k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (2332:13): [True: 2, False: 1.86k]
  ------------------
 2333|      2|            memcpy(output, array1 + 8 * pos1,
 2334|      2|                   (length1 - 8 * pos1) * sizeof(uint16_t));
 2335|      2|            len += (length1 - 8 * pos1);
 2336|  1.86k|        } else {
 2337|  1.86k|            sort_uint16_short(buffer, leftoversize);
 2338|  1.86k|            leftoversize = unique_xor(buffer, leftoversize);
 2339|  1.86k|            len += xor_uint16(buffer, leftoversize, array1 + 8 * pos1,
 2340|  1.86k|                              length1 - 8 * pos1, output);
 2341|  1.86k|        }
 2342|  1.86k|    }
 2343|  4.96k|    return len;
 2344|  8.34k|}
fast_union_uint16:
 2447|  6.75k|                         uint16_t *buffer) {
 2448|  6.75k|#if CROARING_IS_X64
 2449|  6.75k|    if (size_1 * CROARING_SKEWED_VECTOR_MERGE_RATIO < size_2 ||
  ------------------
  |  |  291|  6.75k|#define CROARING_SKEWED_VECTOR_MERGE_RATIO 32
  ------------------
  |  Branch (2449:9): [True: 615, False: 6.14k]
  ------------------
 2450|  6.14k|        size_2 * CROARING_SKEWED_VECTOR_MERGE_RATIO < size_1) {
  ------------------
  |  |  291|  6.14k|#define CROARING_SKEWED_VECTOR_MERGE_RATIO 32
  ------------------
  |  Branch (2450:9): [True: 279, False: 5.86k]
  ------------------
 2451|    894|        return union_uint16(set_1, size_1, set_2, size_2, buffer);
 2452|    894|    }
 2453|  5.86k|    const unsigned support = (unsigned)croaring_hardware_support();
 2454|  5.86k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2455|  5.86k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2455:9): [True: 0, False: 5.86k]
  ------------------
 2456|       |        // compute union with smallest array first
 2457|      0|        if (size_1 < size_2) {
  ------------------
  |  Branch (2457:13): [True: 0, False: 0]
  ------------------
 2458|      0|            return avx512_union_uint16(set_1, (uint32_t)size_1, set_2,
 2459|      0|                                       (uint32_t)size_2, buffer);
 2460|      0|        } else {
 2461|      0|            return avx512_union_uint16(set_2, (uint32_t)size_2, set_1,
 2462|      0|                                       (uint32_t)size_1, buffer);
 2463|      0|        }
 2464|      0|    }
 2465|  5.86k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2466|  5.86k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2466:9): [True: 5.86k, False: 0]
  ------------------
 2467|       |        // compute union with smallest array first
 2468|  5.86k|        if (size_1 < size_2) {
  ------------------
  |  Branch (2468:13): [True: 2.62k, False: 3.23k]
  ------------------
 2469|  2.62k|            return union_vector16(set_1, (uint32_t)size_1, set_2,
 2470|  2.62k|                                  (uint32_t)size_2, buffer);
 2471|  3.23k|        } else {
 2472|  3.23k|            return union_vector16(set_2, (uint32_t)size_2, set_1,
 2473|  3.23k|                                  (uint32_t)size_1, buffer);
 2474|  3.23k|        }
 2475|  5.86k|    } else {
 2476|       |        // compute union with smallest array first
 2477|      0|        if (size_1 < size_2) {
  ------------------
  |  Branch (2477:13): [True: 0, False: 0]
  ------------------
 2478|      0|            return union_uint16(set_1, size_1, set_2, size_2, buffer);
 2479|      0|        } else {
 2480|      0|            return union_uint16(set_2, size_2, set_1, size_1, buffer);
 2481|      0|        }
 2482|      0|    }
 2483|       |#else
 2484|       |    // compute union with smallest array first
 2485|       |    if (size_1 < size_2) {
 2486|       |        return union_uint16(set_1, size_1, set_2, size_2, buffer);
 2487|       |    } else {
 2488|       |        return union_uint16(set_2, size_2, set_1, size_1, buffer);
 2489|       |    }
 2490|       |#endif
 2491|  5.86k|}
memequals:
 2597|  7.91k|bool memequals(const void *s1, const void *s2, size_t n) {
 2598|  7.91k|    if (n == 0) {
  ------------------
  |  Branch (2598:9): [True: 0, False: 7.91k]
  ------------------
 2599|      0|        return true;
 2600|      0|    }
 2601|  7.91k|#if CROARING_IS_X64
 2602|  7.91k|    int support = croaring_hardware_support();
 2603|  7.91k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2604|  7.91k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2604:9): [True: 0, False: 7.91k]
  ------------------
 2605|      0|        return _avx512_memequals(s1, s2, n);
 2606|      0|    } else
 2607|  7.91k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2608|  7.91k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2608:13): [True: 7.91k, False: 0]
  ------------------
 2609|  7.91k|            return _avx2_memequals(s1, s2, n);
 2610|  7.91k|        } else {
 2611|      0|            return memcmp(s1, s2, n) == 0;
 2612|      0|        }
 2613|       |#else
 2614|       |    return memcmp(s1, s2, n) == 0;
 2615|       |#endif
 2616|  7.91k|}
array_util.c:binarySearch4:
  809|  1.14k|                          int32_t *index4) {
  810|  1.14k|    const uint16_t *base1 = array;
  811|  1.14k|    const uint16_t *base2 = array;
  812|  1.14k|    const uint16_t *base3 = array;
  813|  1.14k|    const uint16_t *base4 = array;
  814|  1.14k|    if (n == 0) return;
  ------------------
  |  Branch (814:9): [True: 0, False: 1.14k]
  ------------------
  815|  14.3k|    while (n > 1) {
  ------------------
  |  Branch (815:12): [True: 13.1k, False: 1.14k]
  ------------------
  816|  13.1k|        int32_t half = n >> 1;
  817|  13.1k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (817:17): [True: 1.13k, False: 12.0k]
  ------------------
  818|  13.1k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (818:17): [True: 2.05k, False: 11.1k]
  ------------------
  819|  13.1k|        base3 = (base3[half] < target3) ? &base3[half] : base3;
  ------------------
  |  Branch (819:17): [True: 2.67k, False: 10.4k]
  ------------------
  820|  13.1k|        base4 = (base4[half] < target4) ? &base4[half] : base4;
  ------------------
  |  Branch (820:17): [True: 3.05k, False: 10.1k]
  ------------------
  821|  13.1k|        n -= half;
  822|  13.1k|    }
  823|  1.14k|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  824|  1.14k|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  825|  1.14k|    *index3 = (int32_t)((*base3 < target3) + base3 - array);
  826|  1.14k|    *index4 = (int32_t)((*base4 < target4) + base4 - array);
  827|  1.14k|}
array_util.c:binarySearch2:
  839|    341|                          uint16_t target2, int32_t *index1, int32_t *index2) {
  840|    341|    const uint16_t *base1 = array;
  841|    341|    const uint16_t *base2 = array;
  842|    341|    if (n == 0) return;
  ------------------
  |  Branch (842:9): [True: 0, False: 341]
  ------------------
  843|  3.16k|    while (n > 1) {
  ------------------
  |  Branch (843:12): [True: 2.82k, False: 341]
  ------------------
  844|  2.82k|        int32_t half = n >> 1;
  845|  2.82k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (845:17): [True: 672, False: 2.15k]
  ------------------
  846|  2.82k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (846:17): [True: 1.15k, False: 1.66k]
  ------------------
  847|  2.82k|        n -= half;
  848|  2.82k|    }
  849|    341|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  850|    341|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  851|    341|}
array_util.c:croaring_equal4_uint16:
  988|  88.9k|                                          const uint16_t *b) {
  989|  88.9k|    uint64_t x, y;
  990|  88.9k|    memcpy(&x, a, sizeof(x));
  991|  88.9k|    memcpy(&y, b, sizeof(y));
  992|  88.9k|    return x == y;
  993|  88.9k|}
array_util.c:croaring_gallop_uint16:
 1004|  58.9k|                                            size_t n, uint16_t key) {
 1005|  58.9k|    if (lo >= n || array[lo] >= key) return lo;
  ------------------
  |  Branch (1005:9): [True: 267, False: 58.6k]
  |  Branch (1005:20): [True: 26.7k, False: 31.8k]
  ------------------
 1006|       |    // Invariant: array[lo] < key, and the answer is in (lo, hi], where
 1007|       |    // hi == n stands for a value >= key past the end.
 1008|  31.8k|    size_t step = 1, hi = lo + 1;
 1009|   106k|    while (hi < n && array[hi] < key) {
  ------------------
  |  Branch (1009:12): [True: 103k, False: 3.33k]
  |  Branch (1009:22): [True: 74.5k, False: 28.5k]
  ------------------
 1010|  74.5k|        lo = hi;
 1011|  74.5k|        step <<= 1;
 1012|  74.5k|        hi = lo + step;
 1013|  74.5k|    }
 1014|  31.8k|    if (hi > n) hi = n;
  ------------------
  |  Branch (1014:9): [True: 3.01k, False: 28.8k]
  ------------------
 1015|  31.8k|    size_t len = hi - lo;
 1016|   103k|    while (len > 1) {
  ------------------
  |  Branch (1016:12): [True: 71.7k, False: 31.8k]
  ------------------
 1017|  71.7k|        const size_t half = len >> 1;
 1018|  71.7k|        if (array[lo + half] < key) lo += half;
  ------------------
  |  Branch (1018:13): [True: 32.6k, False: 39.1k]
  ------------------
 1019|  71.7k|        len -= half;
 1020|  71.7k|    }
 1021|  31.8k|    return lo + 1;
 1022|  58.9k|}
array_util.c:union_skewed_uint16:
 1030|  2.31k|                                  uint16_t *out) {
 1031|  2.31k|    size_t pos = 0, j = 0;
 1032|  17.5k|    for (size_t i = 0; i < size_s; i++) {
  ------------------
  |  Branch (1032:24): [True: 15.2k, False: 2.31k]
  ------------------
 1033|  15.2k|        const uint16_t v = small[i];
 1034|  15.2k|        const size_t p = croaring_gallop_uint16(large, j, size_l, v);
 1035|  15.2k|        memmove(out + pos, large + j, (p - j) * sizeof(uint16_t));
 1036|  15.2k|        pos += p - j;
 1037|  15.2k|        j = p;
 1038|  15.2k|        out[pos++] = v;
 1039|  15.2k|        j += (j < size_l && large[j] == v);
  ------------------
  |  Branch (1039:15): [True: 15.0k, False: 280]
  |  Branch (1039:29): [True: 11.5k, False: 3.42k]
  ------------------
 1040|  15.2k|    }
 1041|  2.31k|    memmove(out + pos, large + j, (size_l - j) * sizeof(uint16_t));
 1042|  2.31k|    return pos + size_l - j;
 1043|  2.31k|}
array_util.c:difference_skewed_small_a2_uint16:
 1072|  1.40k|                                             uint16_t *a_out) {
 1073|  1.40k|    size_t i = 0, k = 0;
 1074|  27.4k|    for (int j = 0; j < length2 && i < (size_t)length1; j++) {
  ------------------
  |  Branch (1074:21): [True: 26.1k, False: 1.38k]
  |  Branch (1074:36): [True: 26.0k, False: 19]
  ------------------
 1075|  26.0k|        const uint16_t v = a2[j];
 1076|  26.0k|        const size_t p = croaring_gallop_uint16(a1, i, (size_t)length1, v);
 1077|  26.0k|        memmove(a_out + k, a1 + i, (p - i) * sizeof(uint16_t));
 1078|  26.0k|        k += p - i;
 1079|  26.0k|        i = p;
 1080|  26.0k|        i += (i < (size_t)length1 && a1[i] == v);
  ------------------
  |  Branch (1080:15): [True: 26.0k, False: 76]
  |  Branch (1080:38): [True: 25.8k, False: 204]
  ------------------
 1081|  26.0k|    }
 1082|  1.40k|    memmove(a_out + k, a1 + i, ((size_t)length1 - i) * sizeof(uint16_t));
 1083|  1.40k|    return (int)(k + (size_t)length1 - i);
 1084|  1.40k|}
array_util.c:difference_skewed_small_a1_uint16:
 1091|    408|                                             uint16_t *a_out) {
 1092|    408|    size_t j = 0, k = 0;
 1093|  2.34k|    for (int i = 0; i < length1; i++) {
  ------------------
  |  Branch (1093:21): [True: 1.93k, False: 408]
  ------------------
 1094|  1.93k|        const uint16_t v = a1[i];
 1095|  1.93k|        j = croaring_gallop_uint16(a2, j, (size_t)length2, v);
 1096|  1.93k|        a_out[k] = v;
 1097|  1.93k|        k += (j == (size_t)length2 || a2[j] != v);
  ------------------
  |  Branch (1097:15): [True: 64, False: 1.87k]
  |  Branch (1097:39): [True: 877, False: 994]
  ------------------
 1098|  1.93k|    }
 1099|    408|    return (int)k;
 1100|    408|}
array_util.c:xor_skewed_uint16:
 1049|  2.75k|                                 uint16_t *out) {
 1050|  2.75k|    size_t pos = 0, j = 0;
 1051|  18.3k|    for (size_t i = 0; i < size_s; i++) {
  ------------------
  |  Branch (1051:24): [True: 15.6k, False: 2.75k]
  ------------------
 1052|  15.6k|        const uint16_t v = small[i];
 1053|  15.6k|        const size_t p = croaring_gallop_uint16(large, j, size_l, v);
 1054|  15.6k|        memcpy(out + pos, large + j, (p - j) * sizeof(uint16_t));
 1055|  15.6k|        pos += p - j;
 1056|  15.6k|        j = p;
 1057|  15.6k|        if (j < size_l && large[j] == v) {
  ------------------
  |  Branch (1057:13): [True: 15.3k, False: 317]
  |  Branch (1057:27): [True: 10.6k, False: 4.68k]
  ------------------
 1058|  10.6k|            j++;
 1059|  10.6k|        } else {
 1060|  5.00k|            out[pos++] = v;
 1061|  5.00k|        }
 1062|  15.6k|    }
 1063|  2.75k|    memcpy(out + pos, large + j, (size_l - j) * sizeof(uint16_t));
 1064|  2.75k|    return (int32_t)(pos + size_l - j);
 1065|  2.75k|}
array_util.c:sse_merge:
 1528|   311k|                             __m128i *vecMax) {
 1529|   311k|    const __m128i rev =
 1530|   311k|        _mm_setr_epi8(14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1);
 1531|   311k|    __m128i x = a;
 1532|   311k|    __m128i y = _mm_shuffle_epi8(b, rev);
 1533|  1.55M|    for (int i = 0; i < 4; i++) {
  ------------------
  |  Branch (1533:21): [True: 1.24M, False: 311k]
  ------------------
 1534|  1.24M|        __m128i mn = _mm_min_epu16(x, y);
 1535|  1.24M|        __m128i mx = _mm_max_epu16(x, y);
 1536|  1.24M|        x = _mm_unpacklo_epi16(mn, mx);
 1537|  1.24M|        y = _mm_unpackhi_epi16(mn, mx);
 1538|  1.24M|    }
 1539|   311k|    *vecMin = x;
 1540|   311k|    *vecMax = y;
 1541|   311k|}
array_util.c:store_unique:
 1890|   122k|static inline int store_unique(__m128i old, __m128i newval, uint16_t *output) {
 1891|   122k|    __m128i vecTmp = _mm_alignr_epi8(newval, old, 16 - 2);
 1892|       |    // lots of high latency instructions follow (optimize?)
 1893|   122k|    int M = _mm_movemask_epi8(
 1894|   122k|        _mm_packs_epi16(_mm_cmpeq_epi16(vecTmp, newval), _mm_setzero_si128()));
 1895|   122k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1896|   122k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1897|   122k|    __m128i val = _mm_shuffle_epi8(newval, key);
 1898|   122k|    _mm_storeu_si128((__m128i *)output, val);
 1899|   122k|    return numberofnewvalues;
 1900|   122k|}
array_util.c:sort_uint16_short:
 1918|  9.69k|static inline void sort_uint16_short(uint16_t *z, uint32_t n) {
 1919|  97.1k|    for (uint32_t i = 1; i < n; i++) {
  ------------------
  |  Branch (1919:26): [True: 87.4k, False: 9.69k]
  ------------------
 1920|  87.4k|        uint16_t v = z[i];
 1921|  87.4k|        uint32_t j = i;
 1922|  90.6k|        while (j > 0 && z[j - 1] > v) {
  ------------------
  |  Branch (1922:16): [True: 90.6k, False: 19]
  |  Branch (1922:25): [True: 3.28k, False: 87.3k]
  ------------------
 1923|  3.28k|            z[j] = z[j - 1];
 1924|  3.28k|            j--;
 1925|  3.28k|        }
 1926|  87.4k|        z[j] = v;
 1927|  87.4k|    }
 1928|  9.69k|}
array_util.c:unique:
 1905|  4.74k|static inline uint32_t unique(uint16_t *out, uint32_t len) {
 1906|  4.74k|    uint32_t pos = 1;
 1907|  48.5k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1907:26): [True: 43.8k, False: 4.74k]
  ------------------
 1908|  43.8k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1908:13): [True: 43.6k, False: 210]
  ------------------
 1909|  43.6k|            out[pos++] = out[i];
 1910|  43.6k|        }
 1911|  43.8k|    }
 1912|  4.74k|    return pos;
 1913|  4.74k|}
array_util.c:store_unique_xor:
 2212|   198k|                                   uint16_t *output) {
 2213|   198k|    __m128i vecTmp1 = _mm_alignr_epi8(newval, old, 16 - 4);
 2214|       |    __m128i vecTmp2 = _mm_alignr_epi8(newval, old, 16 - 2);
 2215|   198k|    __m128i equalleft = _mm_cmpeq_epi16(vecTmp2, vecTmp1);
 2216|   198k|    __m128i equalright = _mm_cmpeq_epi16(vecTmp2, newval);
 2217|   198k|    __m128i equalleftoright = _mm_or_si128(equalleft, equalright);
 2218|   198k|    int M = _mm_movemask_epi8(
 2219|   198k|        _mm_packs_epi16(equalleftoright, _mm_setzero_si128()));
 2220|   198k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 2221|   198k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 2222|   198k|    __m128i val = _mm_shuffle_epi8(vecTmp2, key);
 2223|   198k|    _mm_storeu_si128((__m128i *)output, val);
 2224|   198k|    return numberofnewvalues;
 2225|   198k|}
array_util.c:unique_xor:
 2230|  4.95k|static inline uint32_t unique_xor(uint16_t *out, uint32_t len) {
 2231|  4.95k|    uint32_t pos = 1;
 2232|  48.5k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (2232:26): [True: 43.5k, False: 4.95k]
  ------------------
 2233|  43.5k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (2233:13): [True: 43.1k, False: 386]
  ------------------
 2234|  43.1k|            out[pos++] = out[i];
 2235|  43.1k|        } else
 2236|    386|            pos--;  // if it is identical to previous, delete it
 2237|  43.5k|    }
 2238|  4.95k|    return pos;
 2239|  4.95k|}
array_util.c:_avx2_memequals:
 2555|  7.91k|static inline bool _avx2_memequals(const void *s1, const void *s2, size_t n) {
 2556|  7.91k|    const uint8_t *ptr1 = (const uint8_t *)s1;
 2557|  7.91k|    const uint8_t *ptr2 = (const uint8_t *)s2;
 2558|  7.91k|    const uint8_t *end1 = ptr1 + n;
 2559|  7.91k|    const uint8_t *end8 = ptr1 + n / 8 * 8;
 2560|  7.91k|    const uint8_t *end32 = ptr1 + n / 32 * 32;
 2561|       |
 2562|   136k|    while (ptr1 < end32) {
  ------------------
  |  Branch (2562:12): [True: 128k, False: 7.85k]
  ------------------
 2563|   128k|        __m256i r1 = _mm256_loadu_si256((const __m256i *)ptr1);
 2564|   128k|        __m256i r2 = _mm256_loadu_si256((const __m256i *)ptr2);
 2565|   128k|        int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 2566|   128k|        if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (2566:13): [True: 56, False: 128k]
  ------------------
 2567|     56|            return false;
 2568|     56|        }
 2569|   128k|        ptr1 += 32;
 2570|   128k|        ptr2 += 32;
 2571|   128k|    }
 2572|       |
 2573|  14.9k|    while (ptr1 < end8) {
  ------------------
  |  Branch (2573:12): [True: 7.24k, False: 7.75k]
  ------------------
 2574|  7.24k|        uint64_t v1, v2;
 2575|  7.24k|        memcpy(&v1, ptr1, sizeof(uint64_t));
 2576|  7.24k|        memcpy(&v2, ptr2, sizeof(uint64_t));
 2577|  7.24k|        if (v1 != v2) {
  ------------------
  |  Branch (2577:13): [True: 109, False: 7.13k]
  ------------------
 2578|    109|            return false;
 2579|    109|        }
 2580|  7.13k|        ptr1 += 8;
 2581|  7.13k|        ptr2 += 8;
 2582|  7.13k|    }
 2583|       |
 2584|  27.7k|    while (ptr1 < end1) {
  ------------------
  |  Branch (2584:12): [True: 19.9k, False: 7.71k]
  ------------------
 2585|  19.9k|        if (*ptr1 != *ptr2) {
  ------------------
  |  Branch (2585:13): [True: 36, False: 19.9k]
  ------------------
 2586|     36|            return false;
 2587|     36|        }
 2588|  19.9k|        ptr1++;
 2589|  19.9k|        ptr2++;
 2590|  19.9k|    }
 2591|       |
 2592|  7.71k|    return true;
 2593|  7.75k|}

bitset_extract_setbits_avx2:
  825|    994|                                   uint32_t base) {
  826|    994|    if (outcapacity == 0) return 0;
  ------------------
  |  Branch (826:9): [True: 0, False: 994]
  ------------------
  827|    994|    uint32_t *initout = out;
  828|    994|    __m256i baseVec = _mm256_set1_epi32(base - 1);
  829|    994|    __m256i incVec = _mm256_set1_epi32(64);
  830|    994|    __m256i add8 = _mm256_set1_epi32(8);
  831|    994|    uint32_t *safeout = out + outcapacity;
  832|    994|    size_t i = 0;
  833|   842k|    for (; (i < length) && (out + 64 <= safeout); ++i) {
  ------------------
  |  Branch (833:12): [True: 842k, False: 273]
  |  Branch (833:28): [True: 841k, False: 721]
  ------------------
  834|   841k|        uint64_t w = words[i];
  835|   841k|        if (w == 0) {
  ------------------
  |  Branch (835:13): [True: 88.7k, False: 752k]
  ------------------
  836|  88.7k|            baseVec = _mm256_add_epi32(baseVec, incVec);
  837|   752k|        } else {
  838|  3.76M|            for (int k = 0; k < 4; ++k) {
  ------------------
  |  Branch (838:29): [True: 3.01M, False: 752k]
  ------------------
  839|  3.01M|                uint8_t byteA = (uint8_t)w;
  840|  3.01M|                uint8_t byteB = (uint8_t)(w >> 8);
  841|  3.01M|                w >>= 16;
  842|  3.01M|                __m256i vecA =
  843|  3.01M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteA]);
  844|  3.01M|                __m256i vecB =
  845|  3.01M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteB]);
  846|  3.01M|                uint8_t advanceA = lengthTable[byteA];
  847|  3.01M|                uint8_t advanceB = lengthTable[byteB];
  848|  3.01M|                vecA = _mm256_add_epi32(baseVec, vecA);
  849|  3.01M|                baseVec = _mm256_add_epi32(baseVec, add8);
  850|  3.01M|                vecB = _mm256_add_epi32(baseVec, vecB);
  851|  3.01M|                baseVec = _mm256_add_epi32(baseVec, add8);
  852|  3.01M|                _mm256_storeu_si256((__m256i *)out, vecA);
  853|  3.01M|                out += advanceA;
  854|  3.01M|                _mm256_storeu_si256((__m256i *)out, vecB);
  855|  3.01M|                out += advanceB;
  856|  3.01M|            }
  857|   752k|        }
  858|   841k|    }
  859|    994|    base += i * 64;
  860|  8.24k|    for (; (i < length) && (out < safeout); ++i) {
  ------------------
  |  Branch (860:12): [True: 7.86k, False: 379]
  |  Branch (860:28): [True: 7.24k, False: 615]
  ------------------
  861|  7.24k|        uint64_t w = words[i];
  862|  26.3k|        while ((w != 0) && (out < safeout)) {
  ------------------
  |  Branch (862:16): [True: 19.0k, False: 7.24k]
  |  Branch (862:28): [True: 19.0k, False: 0]
  ------------------
  863|  19.0k|            int r =
  864|  19.0k|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  865|  19.0k|            uint32_t val = r + base;
  866|  19.0k|            memcpy(out, &val,
  867|  19.0k|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  868|  19.0k|            out++;
  869|  19.0k|            w &= (w - 1);
  870|  19.0k|        }
  871|  7.24k|        base += 64;
  872|  7.24k|    }
  873|    994|    return out - initout;
  874|    994|}
bitset_extract_setbits:
  880|    435|                              uint32_t *out, uint32_t base) {
  881|    435|    int outpos = 0;
  882|   445k|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (882:24): [True: 445k, False: 435]
  ------------------
  883|   445k|        uint64_t w = words[i];
  884|  2.50M|        while (w != 0) {
  ------------------
  |  Branch (884:16): [True: 2.05M, False: 445k]
  ------------------
  885|  2.05M|            int r =
  886|  2.05M|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  887|  2.05M|            uint32_t val = r + base;
  888|  2.05M|            memcpy(out + outpos, &val,
  889|  2.05M|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  890|  2.05M|            outpos++;
  891|  2.05M|            w &= (w - 1);
  892|  2.05M|        }
  893|   445k|        base += 64;
  894|   445k|    }
  895|    435|    return outpos;
  896|    435|}
bitset_extract_setbits_uint16:
 1068|  2.84k|                                     uint16_t *out, uint16_t base) {
 1069|  2.84k|    int outpos = 0;
 1070|  2.91M|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (1070:24): [True: 2.91M, False: 2.84k]
  ------------------
 1071|  2.91M|        uint64_t w = words[i];
 1072|  5.76M|        while (w != 0) {
  ------------------
  |  Branch (1072:16): [True: 2.84M, False: 2.91M]
  ------------------
 1073|  2.84M|            int r = roaring_trailing_zeroes(w);
 1074|  2.84M|            out[outpos++] = (uint16_t)(r + base);
 1075|  2.84M|            w &= (w - 1);
 1076|  2.84M|        }
 1077|  2.91M|        base += 64;
 1078|  2.91M|    }
 1079|  2.84k|    return outpos;
 1080|  2.84k|}
bitset_clear_list:
 1248|  1.41k|                           uint64_t length) {
 1249|  1.41k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1249:9): [True: 1.41k, False: 0]
  ------------------
 1250|  1.41k|        return _asm_bitset_clear_list(words, card, list, length);
 1251|  1.41k|    } else {
 1252|      0|        return _scalar_bitset_clear_list(words, card, list, length);
 1253|      0|    }
 1254|  1.41k|}
bitset_set_list_withcard:
 1257|  1.39k|                                  const uint16_t *list, uint64_t length) {
 1258|  1.39k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1258:9): [True: 1.39k, False: 0]
  ------------------
 1259|  1.39k|        return _asm_bitset_set_list_withcard(words, card, list, length);
 1260|  1.39k|    } else {
 1261|      0|        return _scalar_bitset_set_list_withcard(words, card, list, length);
 1262|      0|    }
 1263|  1.39k|}
bitset_set_list:
 1265|    208|void bitset_set_list(uint64_t *words, const uint16_t *list, uint64_t length) {
 1266|    208|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1266:9): [True: 208, False: 0]
  ------------------
 1267|    208|        _asm_bitset_set_list(words, list, length);
 1268|    208|    } else {
 1269|      0|        _scalar_bitset_set_list(words, list, length);
 1270|      0|    }
 1271|    208|}
bitset_flip_list_withcard:
 1327|  1.48k|                                   const uint16_t *list, uint64_t length) {
 1328|  1.48k|    uint64_t offset, load, newload, pos, index;
 1329|  1.48k|    const uint16_t *end = list + length;
 1330|  2.78M|    while (list != end) {
  ------------------
  |  Branch (1330:12): [True: 2.78M, False: 1.48k]
  ------------------
 1331|  2.78M|        pos = *list;
 1332|  2.78M|        offset = pos >> 6;
 1333|  2.78M|        index = pos % 64;
 1334|  2.78M|        load = words[offset];
 1335|  2.78M|        newload = load ^ (UINT64_C(1) << index);
 1336|       |        // todo: is a branch here all that bad?
 1337|  2.78M|        card +=
 1338|       |            (1 - 2 * (((UINT64_C(1) << index) & load) >> index));  // +1 or -1
 1339|  2.78M|        words[offset] = newload;
 1340|  2.78M|        list++;
 1341|  2.78M|    }
 1342|  1.48k|    return card;
 1343|  1.48k|}
bitset_util.c:_asm_bitset_clear_list:
 1169|  1.41k|                                              uint64_t length) {
 1170|  1.41k|    uint64_t offset, load, pos;
 1171|  1.41k|    uint64_t shift = 6;
 1172|  1.41k|    const uint16_t *end = list + length;
 1173|  1.41k|    if (!length) return card;
  ------------------
  |  Branch (1173:9): [True: 0, False: 1.41k]
  ------------------
 1174|       |    // btr is not available as an intrinsic in GCC
 1175|  1.41k|    __asm volatile(
 1176|  1.41k|        "1:\n"
 1177|  1.41k|        "movzwq (%[list]), %[pos]\n"
 1178|  1.41k|        "shrx %[shift], %[pos], %[offset]\n"
 1179|  1.41k|        "mov (%[words],%[offset],8), %[load]\n"
 1180|  1.41k|        "btr %[pos], %[load]\n"
 1181|  1.41k|        "mov %[load], (%[words],%[offset],8)\n"
 1182|  1.41k|        "sbb $0, %[card]\n"
 1183|  1.41k|        "add $2, %[list]\n"
 1184|  1.41k|        "cmp %[list], %[end]\n"
 1185|  1.41k|        "jnz 1b"
 1186|  1.41k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
 1187|  1.41k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
 1188|  1.41k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift)
 1189|  1.41k|        :
 1190|  1.41k|        /* clobbers */ "memory");
 1191|  1.41k|    return card;
 1192|  1.41k|}
bitset_util.c:_asm_bitset_set_list_withcard:
 1087|  1.39k|                                                     uint64_t length) {
 1088|  1.39k|    uint64_t offset, load, pos;
 1089|  1.39k|    uint64_t shift = 6;
 1090|  1.39k|    const uint16_t *end = list + length;
 1091|  1.39k|    if (!length) return card;
  ------------------
  |  Branch (1091:9): [True: 0, False: 1.39k]
  ------------------
 1092|       |    // TODO: could unroll for performance, see bitset_set_list
 1093|       |    // bts is not available as an intrinsic in GCC
 1094|  1.39k|    __asm volatile(
 1095|  1.39k|        "1:\n"
 1096|  1.39k|        "movzwq (%[list]), %[pos]\n"
 1097|  1.39k|        "shrx %[shift], %[pos], %[offset]\n"
 1098|  1.39k|        "mov (%[words],%[offset],8), %[load]\n"
 1099|  1.39k|        "bts %[pos], %[load]\n"
 1100|  1.39k|        "mov %[load], (%[words],%[offset],8)\n"
 1101|  1.39k|        "sbb $-1, %[card]\n"
 1102|  1.39k|        "add $2, %[list]\n"
 1103|  1.39k|        "cmp %[list], %[end]\n"
 1104|  1.39k|        "jnz 1b"
 1105|  1.39k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
 1106|  1.39k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
 1107|  1.39k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift));
 1108|  1.39k|    return card;
 1109|  1.39k|}
bitset_util.c:_asm_bitset_set_list:
 1112|    208|                                        uint64_t length) {
 1113|    208|    uint64_t pos;
 1114|    208|    const uint16_t *end = list + length;
 1115|       |
 1116|    208|    uint64_t shift = 6;
 1117|    208|    uint64_t offset;
 1118|    208|    uint64_t load;
 1119|  5.78k|    for (; list + 3 < end; list += 4) {
  ------------------
  |  Branch (1119:12): [True: 5.58k, False: 208]
  ------------------
 1120|  5.58k|        pos = list[0];
 1121|  5.58k|        __asm volatile(
 1122|  5.58k|            "shrx %[shift], %[pos], %[offset]\n"
 1123|  5.58k|            "mov (%[words],%[offset],8), %[load]\n"
 1124|  5.58k|            "bts %[pos], %[load]\n"
 1125|  5.58k|            "mov %[load], (%[words],%[offset],8)"
 1126|  5.58k|            : [load] "=&r"(load), [offset] "=&r"(offset)
 1127|  5.58k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
 1128|  5.58k|        pos = list[1];
 1129|  5.58k|        __asm volatile(
 1130|  5.58k|            "shrx %[shift], %[pos], %[offset]\n"
 1131|  5.58k|            "mov (%[words],%[offset],8), %[load]\n"
 1132|  5.58k|            "bts %[pos], %[load]\n"
 1133|  5.58k|            "mov %[load], (%[words],%[offset],8)"
 1134|  5.58k|            : [load] "=&r"(load), [offset] "=&r"(offset)
 1135|  5.58k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
 1136|  5.58k|        pos = list[2];
 1137|  5.58k|        __asm volatile(
 1138|  5.58k|            "shrx %[shift], %[pos], %[offset]\n"
 1139|  5.58k|            "mov (%[words],%[offset],8), %[load]\n"
 1140|  5.58k|            "bts %[pos], %[load]\n"
 1141|  5.58k|            "mov %[load], (%[words],%[offset],8)"
 1142|  5.58k|            : [load] "=&r"(load), [offset] "=&r"(offset)
 1143|  5.58k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
 1144|  5.58k|        pos = list[3];
 1145|  5.58k|        __asm volatile(
 1146|  5.58k|            "shrx %[shift], %[pos], %[offset]\n"
 1147|  5.58k|            "mov (%[words],%[offset],8), %[load]\n"
 1148|  5.58k|            "bts %[pos], %[load]\n"
 1149|  5.58k|            "mov %[load], (%[words],%[offset],8)"
 1150|  5.58k|            : [load] "=&r"(load), [offset] "=&r"(offset)
 1151|  5.58k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
 1152|  5.58k|    }
 1153|       |
 1154|    506|    while (list != end) {
  ------------------
  |  Branch (1154:12): [True: 298, False: 208]
  ------------------
 1155|    298|        pos = list[0];
 1156|    298|        __asm volatile(
 1157|    298|            "shrx %[shift], %[pos], %[offset]\n"
 1158|    298|            "mov (%[words],%[offset],8), %[load]\n"
 1159|    298|            "bts %[pos], %[load]\n"
 1160|    298|            "mov %[load], (%[words],%[offset],8)"
 1161|    298|            : [load] "=&r"(load), [offset] "=&r"(offset)
 1162|    298|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
 1163|    298|        list++;
 1164|    298|    }
 1165|    208|}

array_container_create_given_capacity:
   49|   150k|array_container_t *array_container_create_given_capacity(int32_t size) {
   50|   150k|    array_container_t *container;
   51|       |
   52|   150k|    if ((container = (array_container_t *)roaring_malloc(
  ------------------
  |  Branch (52:9): [True: 0, False: 150k]
  ------------------
   53|   150k|             sizeof(array_container_t))) == NULL) {
   54|      0|        return NULL;
   55|      0|    }
   56|       |
   57|   150k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (57:9): [True: 88.5k, False: 61.8k]
  ------------------
   58|  88.5k|        container->array = NULL;
   59|  88.5k|    } else if ((container->array = (uint16_t *)roaring_malloc(sizeof(uint16_t) *
  ------------------
  |  Branch (59:16): [True: 0, False: 61.8k]
  ------------------
   60|  61.8k|                                                              size)) == NULL) {
   61|      0|        roaring_free(container);
   62|      0|        return NULL;
   63|      0|    }
   64|       |
   65|   150k|    container->capacity = size;
   66|   150k|    container->cardinality = 0;
   67|       |
   68|   150k|    return container;
   69|   150k|}
array_container_create:
   72|  29.0k|array_container_t *array_container_create(void) {
   73|  29.0k|    return array_container_create_given_capacity(ARRAY_DEFAULT_INIT_SIZE);
   74|  29.0k|}
array_container_create_range:
   77|    133|array_container_t *array_container_create_range(uint32_t min, uint32_t max) {
   78|    133|    array_container_t *answer =
   79|    133|        array_container_create_given_capacity(max - min + 1);
   80|    133|    if (answer == NULL) return answer;
  ------------------
  |  Branch (80:9): [True: 0, False: 133]
  ------------------
   81|    133|    answer->cardinality = 0;
   82|    266|    for (uint32_t k = min; k < max; k++) {
  ------------------
  |  Branch (82:28): [True: 133, False: 133]
  ------------------
   83|    133|        answer->array[answer->cardinality++] = k;
   84|    133|    }
   85|    133|    return answer;
   86|    133|}
array_container_clone:
   90|  24.0k|array_container_t *array_container_clone(const array_container_t *src) {
   91|  24.0k|    array_container_t *newcontainer =
   92|  24.0k|        array_container_create_given_capacity(src->capacity);
   93|  24.0k|    if (newcontainer == NULL) return NULL;
  ------------------
  |  Branch (93:9): [True: 0, False: 24.0k]
  ------------------
   94|       |
   95|  24.0k|    newcontainer->cardinality = src->cardinality;
   96|       |
   97|  24.0k|    memcpy(newcontainer->array, src->array,
   98|  24.0k|           src->cardinality * sizeof(uint16_t));
   99|       |
  100|  24.0k|    return newcontainer;
  101|  24.0k|}
array_container_shrink_to_fit:
  134|  4.78k|int array_container_shrink_to_fit(array_container_t *src) {
  135|  4.78k|    int32_t cardinality = src->cardinality;
  136|  4.78k|    int32_t capacity = src->capacity;
  137|  4.78k|    if (cardinality == capacity) return 0;  // nothing to do
  ------------------
  |  Branch (137:9): [True: 548, False: 4.23k]
  ------------------
  138|  4.78k|    bool shrunk;
  139|  4.23k|    src->array = (uint16_t *)croaring_realloc_shrink(
  140|  4.23k|        src->array, cardinality * sizeof(uint16_t), &shrunk);
  141|  4.23k|    if (!shrunk) return 0;
  ------------------
  |  Branch (141:9): [True: 0, False: 4.23k]
  ------------------
  142|  4.23k|    src->capacity = cardinality;
  143|  4.23k|    return (capacity - cardinality) * (int)sizeof(uint16_t);
  144|  4.23k|}
array_container_free:
  147|   150k|void array_container_free(array_container_t *arr) {
  148|   150k|    if (arr == NULL) return;
  ------------------
  |  Branch (148:9): [True: 0, False: 150k]
  ------------------
  149|   150k|    roaring_free(arr->array);
  150|   150k|    roaring_free(arr);
  151|   150k|}
array_container_grow:
  165|   126k|                          bool preserve) {
  166|   126k|    int32_t max = (min <= DEFAULT_MAX_SIZE ? DEFAULT_MAX_SIZE : 65536);
  ------------------
  |  Branch (166:20): [True: 126k, False: 0]
  ------------------
  167|   126k|    int32_t new_capacity = clamp(grow_capacity(container->capacity), min, max);
  168|       |
  169|   126k|    container->capacity = new_capacity;
  170|   126k|    uint16_t *array = container->array;
  171|       |
  172|   126k|    if (preserve) {
  ------------------
  |  Branch (172:9): [True: 115k, False: 11.6k]
  ------------------
  173|   115k|        container->array =
  174|   115k|            (uint16_t *)roaring_realloc(array, new_capacity * sizeof(uint16_t));
  175|   115k|        if (container->array == NULL) roaring_free(array);
  ------------------
  |  Branch (175:13): [True: 0, False: 115k]
  ------------------
  176|   115k|    } else {
  177|  11.6k|        roaring_free(array);
  178|  11.6k|        container->array =
  179|  11.6k|            (uint16_t *)roaring_malloc(new_capacity * sizeof(uint16_t));
  180|  11.6k|    }
  181|       |
  182|       |    // if realloc fails, we have container->array == NULL.
  183|   126k|}
array_container_copy:
  187|     34|                          array_container_t *dst) {
  188|     34|    const int32_t cardinality = src->cardinality;
  189|     34|    if (cardinality > dst->capacity) {
  ------------------
  |  Branch (189:9): [True: 34, False: 0]
  ------------------
  190|     34|        array_container_grow(dst, cardinality, false);
  191|     34|    }
  192|       |
  193|     34|    dst->cardinality = cardinality;
  194|     34|    memcpy(dst->array, src->array, cardinality * sizeof(uint16_t));
  195|     34|}
array_container_union:
  209|  6.75k|                           array_container_t *out) {
  210|  6.75k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  211|  6.75k|    const int32_t max_cardinality = card_1 + card_2;
  212|       |
  213|  6.75k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (213:9): [True: 0, False: 6.75k]
  ------------------
  214|       |        array_container_grow(out, max_cardinality, false);
  215|      0|    }
  216|  6.75k|    out->cardinality = (int32_t)fast_union_uint16(
  217|  6.75k|        array_1->array, card_1, array_2->array, card_2, out->array);
  218|  6.75k|}
array_container_andnot:
  226|  7.82k|                            array_container_t *out) {
  227|  7.82k|    if (out->capacity < array_1->cardinality)
  ------------------
  |  Branch (227:9): [True: 3.40k, False: 4.42k]
  ------------------
  228|  3.40k|        array_container_grow(out, array_1->cardinality, false);
  229|  7.82k|#if CROARING_IS_X64
  230|       |    // difference_vector16 only vectorizes while 8 values remain on each
  231|       |    // side, and loses to the galloping scalar code when one side is
  232|       |    // much shorter.
  233|  7.82k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  234|  7.82k|    const int32_t card_min = card_1 < card_2 ? card_1 : card_2;
  ------------------
  |  Branch (234:30): [True: 1.26k, False: 6.55k]
  ------------------
  235|  7.82k|    const int32_t card_max = card_1 < card_2 ? card_2 : card_1;
  ------------------
  |  Branch (235:30): [True: 1.26k, False: 6.55k]
  ------------------
  236|  7.82k|    const bool skewed = card_min < 8 || card_min * 128 < card_max;
  ------------------
  |  Branch (236:25): [True: 2.72k, False: 5.09k]
  |  Branch (236:41): [True: 97, False: 5.00k]
  ------------------
  237|  7.82k|    if (!skewed && (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) &&
  ------------------
  |  Branch (237:9): [True: 5.00k, False: 2.81k]
  |  Branch (237:20): [True: 5.00k, False: 0]
  ------------------
  238|  5.00k|        (out != array_1) && (out != array_2)) {
  ------------------
  |  Branch (238:9): [True: 2.13k, False: 2.86k]
  |  Branch (238:29): [True: 2.13k, False: 0]
  ------------------
  239|  2.13k|        out->cardinality = difference_vector16(
  240|  2.13k|            array_1->array, array_1->cardinality, array_2->array,
  241|  2.13k|            array_2->cardinality, out->array);
  242|  5.68k|    } else {
  243|  5.68k|        out->cardinality =
  244|  5.68k|            difference_uint16(array_1->array, array_1->cardinality,
  245|  5.68k|                              array_2->array, array_2->cardinality, out->array);
  246|  5.68k|    }
  247|       |#else
  248|       |    out->cardinality =
  249|       |        difference_uint16(array_1->array, array_1->cardinality, array_2->array,
  250|       |                          array_2->cardinality, out->array);
  251|       |#endif
  252|  7.82k|}
array_container_xor:
  261|  9.30k|                         array_container_t *out) {
  262|  9.30k|    const int32_t card_1 = array_1->cardinality, card_2 = array_2->cardinality;
  263|  9.30k|    const int32_t max_cardinality = card_1 + card_2;
  264|  9.30k|    if (out->capacity < max_cardinality) {
  ------------------
  |  Branch (264:9): [True: 0, False: 9.30k]
  ------------------
  265|      0|        array_container_grow(out, max_cardinality, false);
  266|      0|    }
  267|       |
  268|  9.30k|#if CROARING_IS_X64
  269|  9.30k|    if (!(card_1 * CROARING_SKEWED_VECTOR_MERGE_RATIO < card_2 ||
  ------------------
  |  |  291|  9.30k|#define CROARING_SKEWED_VECTOR_MERGE_RATIO 32
  ------------------
  |  Branch (269:11): [True: 663, False: 8.64k]
  ------------------
  270|  8.64k|          card_2 * CROARING_SKEWED_VECTOR_MERGE_RATIO < card_1) &&
  ------------------
  |  |  291|  8.64k|#define CROARING_SKEWED_VECTOR_MERGE_RATIO 32
  ------------------
  |  Branch (270:11): [True: 306, False: 8.34k]
  ------------------
  271|  8.34k|        (croaring_hardware_support() & ROARING_SUPPORTS_AVX2)) {
  ------------------
  |  Branch (271:9): [True: 8.34k, False: 0]
  ------------------
  272|  8.34k|        out->cardinality =
  273|  8.34k|            xor_vector16(array_1->array, array_1->cardinality, array_2->array,
  274|  8.34k|                         array_2->cardinality, out->array);
  275|  8.34k|    } else {
  276|    969|        out->cardinality =
  277|    969|            xor_uint16(array_1->array, array_1->cardinality, array_2->array,
  278|    969|                       array_2->cardinality, out->array);
  279|    969|    }
  280|       |#else
  281|       |    out->cardinality =
  282|       |        xor_uint16(array_1->array, array_1->cardinality, array_2->array,
  283|       |                   array_2->cardinality, out->array);
  284|       |#endif
  285|  9.30k|}
array_container_intersection:
  297|  3.40k|                                  array_container_t *out) {
  298|  3.40k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality,
  299|  3.40k|            min_card = minimum_int32(card_1, card_2);
  300|  3.40k|    const int threshold = 64;  // subject to tuning
  301|  3.40k|#if CROARING_IS_X64
  302|  3.40k|    if (out->capacity < min_card) {
  ------------------
  |  Branch (302:9): [True: 3.40k, False: 0]
  ------------------
  303|  3.40k|        array_container_grow(out, min_card + sizeof(__m128i) / sizeof(uint16_t),
  304|  3.40k|                             false);
  305|  3.40k|    }
  306|       |#else
  307|       |    if (out->capacity < min_card) {
  308|       |        array_container_grow(out, min_card, false);
  309|       |    }
  310|       |#endif
  311|       |
  312|  3.40k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (312:9): [True: 316, False: 3.08k]
  ------------------
  313|    316|        out->cardinality = intersect_skewed_uint16(
  314|    316|            array1->array, card_1, array2->array, card_2, out->array);
  315|  3.08k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (315:16): [True: 173, False: 2.91k]
  ------------------
  316|    173|        out->cardinality = intersect_skewed_uint16(
  317|    173|            array2->array, card_2, array1->array, card_1, out->array);
  318|  2.91k|    } else {
  319|  2.91k|#if CROARING_IS_X64
  320|  2.91k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (320:13): [True: 2.91k, False: 0]
  ------------------
  321|  2.91k|            out->cardinality = intersect_vector16(
  322|  2.91k|                array1->array, card_1, array2->array, card_2, out->array);
  323|  2.91k|        } else {
  324|      0|            out->cardinality = intersect_uint16(
  325|      0|                array1->array, card_1, array2->array, card_2, out->array);
  326|      0|        }
  327|       |#else
  328|       |        out->cardinality = intersect_uint16(array1->array, card_1,
  329|       |                                            array2->array, card_2, out->array);
  330|       |#endif
  331|  2.91k|    }
  332|  3.40k|}
array_container_intersection_cardinality:
  337|  13.6k|                                             const array_container_t *array2) {
  338|  13.6k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  339|  13.6k|    const int threshold = 64;  // subject to tuning
  340|  13.6k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (340:9): [True: 1.26k, False: 12.3k]
  ------------------
  341|  1.26k|        return intersect_skewed_uint16_cardinality(array1->array, card_1,
  342|  1.26k|                                                   array2->array, card_2);
  343|  12.3k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (343:16): [True: 692, False: 11.6k]
  ------------------
  344|    692|        return intersect_skewed_uint16_cardinality(array2->array, card_2,
  345|    692|                                                   array1->array, card_1);
  346|  11.6k|    } else {
  347|  11.6k|#if CROARING_IS_X64
  348|  11.6k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (348:13): [True: 11.6k, False: 0]
  ------------------
  349|  11.6k|            return intersect_vector16_cardinality(array1->array, card_1,
  350|  11.6k|                                                  array2->array, card_2);
  351|  11.6k|        } else {
  352|      0|            return intersect_uint16_cardinality(array1->array, card_1,
  353|      0|                                                array2->array, card_2);
  354|      0|        }
  355|       |#else
  356|       |        return intersect_uint16_cardinality(array1->array, card_1,
  357|       |                                            array2->array, card_2);
  358|       |#endif
  359|  11.6k|    }
  360|  13.6k|}
array_container_intersect:
  363|  3.40k|                               const array_container_t *array2) {
  364|  3.40k|    int32_t card_1 = array1->cardinality, card_2 = array2->cardinality;
  365|  3.40k|    const int threshold = 64;  // subject to tuning
  366|  3.40k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (366:9): [True: 316, False: 3.08k]
  ------------------
  367|    316|        return intersect_skewed_uint16_nonempty(array1->array, card_1,
  368|    316|                                                array2->array, card_2);
  369|  3.08k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (369:16): [True: 173, False: 2.91k]
  ------------------
  370|    173|        return intersect_skewed_uint16_nonempty(array2->array, card_2,
  371|    173|                                                array1->array, card_1);
  372|  2.91k|    } else {
  373|       |        // we do not bother vectorizing
  374|  2.91k|        return intersect_uint16_nonempty(array1->array, card_1, array2->array,
  375|  2.91k|                                         card_2);
  376|  2.91k|    }
  377|  3.40k|}
array_container_intersection_inplace:
  383|  5.75k|                                          const array_container_t *src_2) {
  384|  5.75k|    int32_t card_1 = src_1->cardinality, card_2 = src_2->cardinality;
  385|  5.75k|    const int threshold = 64;  // subject to tuning
  386|  5.75k|    if (card_1 * threshold < card_2) {
  ------------------
  |  Branch (386:9): [True: 0, False: 5.75k]
  ------------------
  387|      0|        src_1->cardinality = intersect_skewed_uint16(
  388|      0|            src_1->array, card_1, src_2->array, card_2, src_1->array);
  389|  5.75k|    } else if (card_2 * threshold < card_1) {
  ------------------
  |  Branch (389:16): [True: 182, False: 5.57k]
  ------------------
  390|    182|        src_1->cardinality = intersect_skewed_uint16(
  391|    182|            src_2->array, card_2, src_1->array, card_1, src_1->array);
  392|  5.57k|    } else {
  393|  5.57k|#if CROARING_IS_X64
  394|  5.57k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (394:13): [True: 5.57k, False: 0]
  ------------------
  395|  5.57k|            src_1->cardinality = intersect_vector16_inplace(
  396|  5.57k|                src_1->array, card_1, src_2->array, card_2);
  397|  5.57k|        } else {
  398|      0|            src_1->cardinality = intersect_uint16(
  399|      0|                src_1->array, card_1, src_2->array, card_2, src_1->array);
  400|      0|        }
  401|       |#else
  402|       |        src_1->cardinality = intersect_uint16(
  403|       |            src_1->array, card_1, src_2->array, card_2, src_1->array);
  404|       |#endif
  405|  5.57k|    }
  406|  5.75k|}
array_container_to_uint32_array:
  419|  6.70k|                                    uint32_t base) {
  420|  6.70k|#if CROARING_IS_X64
  421|  6.70k|    int support = croaring_hardware_support();
  422|  6.70k|#if CROARING_COMPILER_SUPPORTS_AVX512
  423|  6.70k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (423:9): [True: 0, False: 6.70k]
  ------------------
  424|      0|        return avx512_array_container_to_uint32_array(vout, cont->array,
  425|      0|                                                      cont->cardinality, base);
  426|      0|    }
  427|  6.70k|#endif
  428|  6.70k|    if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (428:9): [True: 6.70k, False: 0]
  ------------------
  429|  6.70k|        return array_container_to_uint32_array_vector16(
  430|  6.70k|            vout, cont->array, cont->cardinality, base);
  431|  6.70k|    }
  432|      0|#endif  // CROARING_IS_X64
  433|      0|    const size_t cardinality = (size_t)cont->cardinality;
  434|      0|    const uint16_t *array = cont->array;
  435|       |    // Typed stores vectorize on every compiler; all callers but
  436|       |    // roaring_bitmap_serialize pass an aligned vout.
  437|      0|    if (cardinality >= 4 && ((uintptr_t)vout & 3) == 0) {
  ------------------
  |  Branch (437:9): [True: 0, False: 0]
  |  Branch (437:29): [True: 0, False: 0]
  ------------------
  438|      0|        uint32_t *out = (uint32_t *)vout;
  439|      0|        uint32_t *out_end = out + cardinality;
  440|      0|        const uint16_t *array_end = array + cardinality;
  441|      0|        if (cardinality < 8) {  // overlapping writes end at cardinality
  ------------------
  |  Branch (441:13): [True: 0, False: 0]
  ------------------
  442|      0|            array_put(out, array, base, 4);
  443|      0|            array_put(out_end - 4, array_end - 4, base, 4);
  444|      0|            return (int)cardinality;
  445|      0|        }
  446|      0|        const size_t full = cardinality & ~(size_t)15;
  447|      0|        for (size_t i = 0; i < full; i += 16) {
  ------------------
  |  Branch (447:28): [True: 0, False: 0]
  ------------------
  448|      0|            array_put(out + i, array + i, base, 16);
  449|      0|        }
  450|      0|        if (cardinality - full > 8) {
  ------------------
  |  Branch (450:13): [True: 0, False: 0]
  ------------------
  451|      0|            array_put(out + full, array + full, base, 8);
  452|      0|        }
  453|      0|        if (full != cardinality) {
  ------------------
  |  Branch (453:13): [True: 0, False: 0]
  ------------------
  454|      0|            array_put(out_end - 8, array_end - 8, base, 8);
  455|      0|        }
  456|      0|        return (int)cardinality;
  457|      0|    }
  458|      0|    int outpos = 0;
  459|      0|    uint32_t *out = (uint32_t *)vout;
  460|      0|    size_t i = 0;
  461|      0|    for (; i < (size_t)cont->cardinality; ++i) {
  ------------------
  |  Branch (461:12): [True: 0, False: 0]
  ------------------
  462|      0|        const uint32_t val = base + cont->array[i];
  463|      0|        memcpy(out + outpos, &val,
  464|      0|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  465|      0|        outpos++;
  466|      0|    }
  467|      0|    return outpos;
  468|      0|}
array_container_number_of_runs:
  537|  14.2k|int32_t array_container_number_of_runs(const array_container_t *ac) {
  538|  14.2k|    const uint16_t *array = ac->array;
  539|  14.2k|    const int32_t card = ac->cardinality;
  540|  14.2k|    if (card == 0) return 0;
  ------------------
  |  Branch (540:9): [True: 0, False: 14.2k]
  ------------------
  541|       |    // Every value starts a run unless it follows its predecessor. The values
  542|       |    // are strictly increasing, so array[i - 1] + 1 cannot wrap around to a
  543|       |    // match. The loop has no branch on the data and compilers vectorize it.
  544|  14.2k|    int32_t continuing = 0;
  545|  1.52M|    for (int32_t i = 1; i < card; ++i) {
  ------------------
  |  Branch (545:25): [True: 1.51M, False: 14.2k]
  ------------------
  546|  1.51M|        continuing += (array[i] == (uint16_t)(array[i - 1] + 1));
  547|  1.51M|    }
  548|  14.2k|    return card - continuing;
  549|  14.2k|}
array_container_write:
  558|  7.71k|int32_t array_container_write(const array_container_t *container, char *buf) {
  559|       |#if CROARING_IS_BIG_ENDIAN
  560|       |    for (int32_t i = 0; i < container->cardinality; ++i) {
  561|       |        uint16_t v_le = croaring_htole16(container->array[i]);
  562|       |        memcpy(buf + i * sizeof(uint16_t), &v_le, sizeof(uint16_t));
  563|       |    }
  564|       |#else
  565|  7.71k|    memcpy(buf, container->array, container->cardinality * sizeof(uint16_t));
  566|  7.71k|#endif
  567|  7.71k|    return array_container_size_in_bytes(container);
  568|  7.71k|}
array_container_is_subset:
  572|  7.12k|                               const array_container_t *container2) {
  573|  7.12k|    if (container1->cardinality > container2->cardinality) {
  ------------------
  |  Branch (573:9): [True: 1.12k, False: 5.99k]
  ------------------
  574|  1.12k|        return false;
  575|  1.12k|    }
  576|  5.99k|    int i1 = 0, i2 = 0;
  577|  51.2k|    while (i1 < container1->cardinality && i2 < container2->cardinality) {
  ------------------
  |  Branch (577:12): [True: 51.2k, False: 0]
  |  Branch (577:44): [True: 51.1k, False: 37]
  ------------------
  578|  51.1k|        if (container1->array[i1] == container2->array[i2]) {
  ------------------
  |  Branch (578:13): [True: 0, False: 51.1k]
  ------------------
  579|      0|            i1++;
  580|      0|            i2++;
  581|  51.1k|        } else if (container1->array[i1] > container2->array[i2]) {
  ------------------
  |  Branch (581:20): [True: 45.2k, False: 5.95k]
  ------------------
  582|  45.2k|            i2++;
  583|  45.2k|        } else {  // container1->array[i1] < container2->array[i2]
  584|  5.95k|            return false;
  585|  5.95k|        }
  586|  51.1k|    }
  587|     37|    if (i1 == container1->cardinality) {
  ------------------
  |  Branch (587:9): [True: 0, False: 37]
  ------------------
  588|      0|        return true;
  589|     37|    } else {
  590|       |        return false;
  591|     37|    }
  592|     37|}
array_container_read:
  595|  7.75k|                             const char *buf) {
  596|  7.75k|    if (container->capacity < cardinality) {
  ------------------
  |  Branch (596:9): [True: 0, False: 7.75k]
  ------------------
  597|      0|        array_container_grow(container, cardinality, false);
  598|      0|    }
  599|  7.75k|    container->cardinality = cardinality;
  600|       |#if CROARING_IS_BIG_ENDIAN
  601|       |    for (int32_t i = 0; i < cardinality; ++i) {
  602|       |        uint16_t v_le;
  603|       |        memcpy(&v_le, buf + i * sizeof(uint16_t), sizeof(uint16_t));
  604|       |        container->array[i] = croaring_letoh16(v_le);
  605|       |    }
  606|       |#else
  607|  7.75k|    memcpy(container->array, buf, container->cardinality * sizeof(uint16_t));
  608|  7.75k|#endif
  609|       |
  610|  7.75k|    return array_container_size_in_bytes(container);
  611|  7.75k|}
array_container_iterate:
  615|  7.27k|                             roaring_iterator iterator, void *ptr) {
  616|  2.14M|    for (int i = 0; i < cont->cardinality; i++)
  ------------------
  |  Branch (616:21): [True: 2.13M, False: 7.27k]
  ------------------
  617|  2.13M|        if (!iterator(cont->array[i] + base, ptr)) return false;
  ------------------
  |  Branch (617:13): [True: 0, False: 2.13M]
  ------------------
  618|  7.27k|    return true;
  619|  7.27k|}
array.c:clamp:
  160|   126k|static inline int32_t clamp(int32_t val, int32_t min, int32_t max) {
  161|   126k|    return ((val < min) ? min : (val > max) ? max : val);
  ------------------
  |  Branch (161:13): [True: 29.5k, False: 97.1k]
  |  Branch (161:33): [True: 233, False: 96.9k]
  ------------------
  162|   126k|}
array.c:grow_capacity:
  153|   126k|static inline int32_t grow_capacity(int32_t capacity) {
  154|   126k|    return (capacity <= 0)   ? ARRAY_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (154:12): [True: 28.9k, False: 97.7k]
  ------------------
  155|   126k|           : capacity < 64   ? capacity * 2
  ------------------
  |  Branch (155:14): [True: 73.9k, False: 23.8k]
  ------------------
  156|  97.7k|           : capacity < 1024 ? capacity * 3 / 2
  ------------------
  |  Branch (156:14): [True: 23.5k, False: 275]
  ------------------
  157|  23.8k|                             : capacity * 5 / 4;
  158|   126k|}
array.c:minimum_int32:
  287|  3.40k|static inline int32_t minimum_int32(int32_t a, int32_t b) {
  288|  3.40k|    return (a < b) ? a : b;
  ------------------
  |  Branch (288:12): [True: 1.26k, False: 2.13k]
  ------------------
  289|  3.40k|}

bitset_container_clear:
   51|  71.9k|void bitset_container_clear(bitset_container_t *bitset) {
   52|  71.9k|    memset(bitset->words, 0, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   53|  71.9k|    bitset->cardinality = 0;
   54|  71.9k|}
bitset_container_set_all:
   56|     18|void bitset_container_set_all(bitset_container_t *bitset) {
   57|       |    memset(bitset->words, INT64_C(-1),
   58|     18|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   59|     18|    bitset->cardinality = (1 << 16);
   60|     18|}
bitset_container_create:
   91|  71.9k|bitset_container_t *bitset_container_create(void) {
   92|  71.9k|    bitset_container_t *bitset = bitset_container_allocate();
   93|  71.9k|    if (bitset) {
  ------------------
  |  Branch (93:9): [True: 71.9k, False: 0]
  ------------------
   94|  71.9k|        bitset_container_clear(bitset);
   95|  71.9k|    }
   96|  71.9k|    return bitset;
   97|  71.9k|}
bitset_container_create_uninitialized:
   99|  66.6k|bitset_container_t *bitset_container_create_uninitialized(void) {
  100|  66.6k|    bitset_container_t *bitset = bitset_container_allocate();
  101|  66.6k|    if (bitset) {
  ------------------
  |  Branch (101:9): [True: 66.6k, False: 0]
  ------------------
  102|  66.6k|        bitset->cardinality = 0;
  103|  66.6k|    }
  104|  66.6k|    return bitset;
  105|  66.6k|}
bitset_container_copy:
  109|  3.74k|                           bitset_container_t *dest) {
  110|  3.74k|    dest->cardinality = source->cardinality;
  111|  3.74k|    memcpy(dest->words, source->words,
  112|  3.74k|           sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
  113|  3.74k|}
bitset_container_free:
  144|   272k|void bitset_container_free(bitset_container_t *bitset) {
  145|   272k|    if (bitset == NULL) return;
  ------------------
  |  Branch (145:9): [True: 0, False: 272k]
  ------------------
  146|   272k|    roaring_aligned_free(bitset->words);
  147|   272k|    roaring_free(bitset);
  148|   272k|}
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:
  289|  3.11k|int bitset_container_compute_cardinality(const bitset_container_t *bitset) {
  290|  3.11k|    int support = croaring_hardware_support();
  291|  3.11k|#if CROARING_COMPILER_SUPPORTS_AVX512
  292|  3.11k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (292:9): [True: 0, False: 3.11k]
  ------------------
  293|      0|        return (int)avx512_vpopcount(
  294|      0|            (const __m512i *)bitset->words,
  295|      0|            BITSET_CONTAINER_SIZE_IN_WORDS / (WORDS_IN_AVX512_REG));
  ------------------
  |  |  272|      0|#define WORDS_IN_AVX512_REG sizeof(__m512i) / sizeof(uint64_t)
  ------------------
  296|      0|    } else
  297|  3.11k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
  298|  3.11k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (298:13): [True: 3.11k, False: 0]
  ------------------
  299|  3.11k|            return (int)avx2_harley_seal_popcount256(
  300|  3.11k|                (const __m256i *)bitset->words,
  301|  3.11k|                BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));
  ------------------
  |  |  269|  3.11k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  302|  3.11k|        } else {
  303|      0|            return _scalar_bitset_container_compute_cardinality(bitset);
  304|      0|        }
  305|  3.11k|}
bitset_container_and_nocard:
  747|  1.42k|                                         bitset_container_t *dst) {            \
  748|  1.42k|    int support = croaring_hardware_support();                                 \
  749|  1.42k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (749:10): [True: 0, False: 1.42k]
  ------------------
  750|      0|      return _avx512_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  751|      0|    }                                                                          \
  752|  1.42k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (752:15): [True: 1.42k, False: 0]
  ------------------
  753|  1.42k|      return _avx2_bitset_container_##opname##_nocard(src_1, src_2, dst);      \
  754|  1.42k|    } else {                                                                   \
  755|      0|      return _scalar_bitset_container_##opname##_nocard(src_1, src_2, dst);    \
  756|      0|    }                                                                          \
  757|  1.42k|  }                                                                            \
bitset_container_and_justcard:
  759|  1.42k|                                           const bitset_container_t *src_2) {  \
  760|  1.42k|     int support = croaring_hardware_support();                                \
  761|  1.42k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (761:10): [True: 0, False: 1.42k]
  ------------------
  762|      0|      return _avx512_bitset_container_##opname##_justcard(src_1, src_2);       \
  763|      0|    }                                                                          \
  764|  1.42k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (764:15): [True: 1.42k, False: 0]
  ------------------
  765|  1.42k|      return _avx2_bitset_container_##opname##_justcard(src_1, src_2);         \
  766|  1.42k|    } else {                                                                   \
  767|      0|      return _scalar_bitset_container_##opname##_justcard(src_1, src_2);       \
  768|      0|    }                                                                          \
  769|  1.42k|  }
bitset_container_xor:
  734|  1.41k|                                bitset_container_t *dst) {                     \
  735|  1.41k|    int support = croaring_hardware_support();                                 \
  736|  1.41k|    if ( support & ROARING_SUPPORTS_AVX512 ) {                                 \
  ------------------
  |  Branch (736:10): [True: 0, False: 1.41k]
  ------------------
  737|      0|      return _avx512_bitset_container_##opname(src_1, src_2, dst);             \
  738|      0|    }                                                                          \
  739|  1.41k|    else if ( support & ROARING_SUPPORTS_AVX2 ) {                              \
  ------------------
  |  Branch (739:15): [True: 1.41k, False: 0]
  ------------------
  740|  1.41k|      return _avx2_bitset_container_##opname(src_1, src_2, dst);               \
  741|  1.41k|    } else {                                                                   \
  742|      0|      return _scalar_bitset_container_##opname(src_1, src_2, dst);             \
  743|      0|    }                                                                          \
  744|  1.41k|  }                                                                            \
bitset_container_to_uint32_array:
  959|  1.42k|){
  960|  1.42k|#if CROARING_IS_X64
  961|  1.42k|   int support = croaring_hardware_support();
  962|  1.42k|#if CROARING_COMPILER_SUPPORTS_AVX512
  963|       |   // Unlike the AVX2 kernel, the AVX-512 one needs no cardinality heuristic:
  964|       |   // it skips empty words and only stores the blocks that carry a value, so it
  965|       |   // beat the scalar loop at every cardinality measured from 16 to 65536 (on
  966|       |   // an Emerald Rapids Xeon, 1.3x at 512 values, 6x at 4096, 7.5x at 8192).
  967|  1.42k|   if( support & ROARING_SUPPORTS_AVX512 )
  ------------------
  |  Branch (967:8): [True: 0, False: 1.42k]
  ------------------
  968|      0|		return (int) bitset_extract_setbits_avx512(bc->words,
  969|      0|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  970|  1.42k|   else
  971|  1.42k|#endif
  972|  1.42k|   if(( support & ROARING_SUPPORTS_AVX2 ) &&  (bc->cardinality >= 8192))  // heuristic
  ------------------
  |  Branch (972:7): [True: 1.42k, False: 0]
  |  Branch (972:47): [True: 994, False: 435]
  ------------------
  973|    994|		return (int) bitset_extract_setbits_avx2(bc->words,
  974|    994|                BITSET_CONTAINER_SIZE_IN_WORDS, out, bc->cardinality, base);
  975|    435|	else
  976|    435|		return (int) bitset_extract_setbits(bc->words,
  977|    435|                BITSET_CONTAINER_SIZE_IN_WORDS, out, base);
  978|       |#else
  979|       |	return (int) bitset_extract_setbits(bc->words,
  980|       |                BITSET_CONTAINER_SIZE_IN_WORDS, out, base);
  981|       |#endif
  982|  1.42k|}
bitset_container_write:
 1079|  66.6k|                                  char *buf) {
 1080|       |#if CROARING_IS_BIG_ENDIAN
 1081|       |	for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i) {
 1082|       |		uint64_t w_le = croaring_htole64(container->words[i]);
 1083|       |		memcpy(buf + i * sizeof(uint64_t), &w_le, sizeof(uint64_t));
 1084|       |	}
 1085|       |#else
 1086|  66.6k|	memcpy(buf, container->words, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1087|  66.6k|#endif
 1088|  66.6k|	return bitset_container_size_in_bytes(container);
 1089|  66.6k|}
bitset_container_read:
 1093|  66.6k|		const char *buf)  {
 1094|  66.6k|	container->cardinality = cardinality;
 1095|       |#if CROARING_IS_BIG_ENDIAN
 1096|       |	for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i) {
 1097|       |		uint64_t w_le;
 1098|       |		memcpy(&w_le, buf + i * sizeof(uint64_t), sizeof(uint64_t));
 1099|       |		container->words[i] = croaring_letoh64(w_le);
 1100|       |	}
 1101|       |#else
 1102|  66.6k|	memcpy(container->words, buf, BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t));
 1103|  66.6k|#endif
 1104|  66.6k|	return bitset_container_size_in_bytes(container);
 1105|  66.6k|}
bitset_container_iterate:
 1108|  1.56k|bool bitset_container_iterate(const bitset_container_t *cont, uint32_t base, roaring_iterator iterator, void *ptr) {
 1109|  1.60M|  for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i ) {
  ------------------
  |  Branch (1109:23): [True: 1.60M, False: 1.56k]
  ------------------
 1110|  1.60M|    uint64_t w = cont->words[i];
 1111|  62.2M|    while (w != 0) {
  ------------------
  |  Branch (1111:12): [True: 60.6M, False: 1.60M]
  ------------------
 1112|  60.6M|      uint64_t t = w & (~w + 1);
 1113|  60.6M|      int r = roaring_trailing_zeroes(w);
 1114|  60.6M|      if(!iterator(r + base, ptr)) return false;
  ------------------
  |  Branch (1114:10): [True: 0, False: 60.6M]
  ------------------
 1115|  60.6M|      w ^= t;
 1116|  60.6M|    }
 1117|  1.60M|    base += 64;
 1118|  1.60M|  }
 1119|  1.56k|  return true;
 1120|  1.56k|}
bitset_container_equals:
 1175|  66.6k|bool bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1176|  66.6k|  if((container1->cardinality != BITSET_UNKNOWN_CARDINALITY) && (container2->cardinality != BITSET_UNKNOWN_CARDINALITY)) {
  ------------------
  |  Branch (1176:6): [True: 66.6k, False: 0]
  |  Branch (1176:65): [True: 66.6k, False: 0]
  ------------------
 1177|  66.6k|    if(container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (1177:8): [True: 0, False: 66.6k]
  ------------------
 1178|      0|      return false;
 1179|      0|    }
 1180|  66.6k|    if (container1->cardinality == INT32_C(0x10000)) {
  ------------------
  |  Branch (1180:9): [True: 62.8k, False: 3.82k]
  ------------------
 1181|  62.8k|      return true;
 1182|  62.8k|    }
 1183|  66.6k|  }
 1184|  3.82k|#if CROARING_IS_X64
 1185|  3.82k|  int support = croaring_hardware_support();
 1186|  3.82k|#if CROARING_COMPILER_SUPPORTS_AVX512
 1187|  3.82k|  if( support & ROARING_SUPPORTS_AVX512 ) {
  ------------------
  |  Branch (1187:7): [True: 0, False: 3.82k]
  ------------------
 1188|      0|    return _avx512_bitset_container_equals(container1, container2);
 1189|      0|  }
 1190|  3.82k|  else
 1191|  3.82k|#endif
 1192|  3.82k|  if( support & ROARING_SUPPORTS_AVX2 ) {
  ------------------
  |  Branch (1192:7): [True: 3.82k, False: 0]
  ------------------
 1193|  3.82k|    return _avx2_bitset_container_equals(container1, container2);
 1194|  3.82k|  }
 1195|      0|#endif
 1196|      0|  return memcmp(container1->words,
 1197|      0|                container2->words,
 1198|      0|                BITSET_CONTAINER_SIZE_IN_WORDS*sizeof(uint64_t)) == 0;
 1199|  3.82k|}
bitset_container_minimum:
 1291|  1.17k|uint16_t bitset_container_minimum(const bitset_container_t *container) {
 1292|  14.0k|  for (int32_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS; ++i ) {
  ------------------
  |  Branch (1292:23): [True: 14.0k, False: 0]
  ------------------
 1293|  14.0k|    uint64_t w = container->words[i];
 1294|  14.0k|    if (w != 0) {
  ------------------
  |  Branch (1294:9): [True: 1.17k, False: 12.9k]
  ------------------
 1295|  1.17k|      int r = roaring_trailing_zeroes(w);
 1296|  1.17k|      return r + i * 64;
 1297|  1.17k|    }
 1298|  14.0k|  }
 1299|      0|  return UINT16_MAX;
 1300|  1.17k|}
bitset_container_maximum:
 1304|  4.19k|uint16_t bitset_container_maximum(const bitset_container_t *container) {
 1305|  1.04M|  for (int32_t i = BITSET_CONTAINER_SIZE_IN_WORDS - 1; i >= 0; --i ) {
  ------------------
  |  Branch (1305:56): [True: 1.04M, False: 0]
  ------------------
 1306|  1.04M|    uint64_t w = container->words[i];
 1307|  1.04M|    if (w != 0) {
  ------------------
  |  Branch (1307:9): [True: 4.19k, False: 1.04M]
  ------------------
 1308|  4.19k|      int r = roaring_leading_zeroes(w);
 1309|  4.19k|      return i * 64 + 63  - r;
 1310|  4.19k|    }
 1311|  1.04M|  }
 1312|      0|  return 0;
 1313|  4.19k|}
bitset_container_index_equalorlarger:
 1377|  1.81k|int bitset_container_index_equalorlarger(const bitset_container_t *container, uint16_t x) {
 1378|  1.81k|  uint32_t x32 = x;
 1379|  1.81k|  uint32_t k = x32 / 64;
 1380|  1.81k|  uint64_t word = container->words[k];
 1381|  1.81k|  const int diff = x32 - k * 64; // in [0,64)
 1382|  1.81k|  word = (word >> diff) << diff; // a mask is faster, but we don't care
 1383|  6.28k|  while(word == 0) {
  ------------------
  |  Branch (1383:9): [True: 4.46k, False: 1.81k]
  ------------------
 1384|  4.46k|    k++;
 1385|  4.46k|    if(k == BITSET_CONTAINER_SIZE_IN_WORDS) return -1;
  ------------------
  |  Branch (1385:8): [True: 0, False: 4.46k]
  ------------------
 1386|  4.46k|    word = container->words[k];
 1387|  4.46k|  }
 1388|  1.81k|  return k * 64 + roaring_trailing_zeroes(word);
 1389|  1.81k|}
bitset.c:bitset_container_allocate:
   62|   138k|static bitset_container_t *bitset_container_allocate(void) {
   63|   138k|    bitset_container_t *bitset =
   64|   138k|        (bitset_container_t *)roaring_malloc(sizeof(bitset_container_t));
   65|       |
   66|   138k|    if (!bitset) {
  ------------------
  |  Branch (66:9): [True: 0, False: 138k]
  ------------------
   67|      0|        return NULL;
   68|      0|    }
   69|       |
   70|   138k|    size_t align_size = 32;
   71|   138k|#if CROARING_IS_X64
   72|   138k|    int support = croaring_hardware_support();
   73|   138k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (73:9): [True: 0, False: 138k]
  ------------------
   74|       |        // sizeof(__m512i) == 64
   75|      0|        align_size = 64;
   76|   138k|    } else {
   77|       |        // sizeof(__m256i) == 32
   78|   138k|        align_size = 32;
   79|   138k|    }
   80|   138k|#endif
   81|   138k|    bitset->words = (uint64_t *)roaring_aligned_malloc(
   82|   138k|        align_size, sizeof(uint64_t) * BITSET_CONTAINER_SIZE_IN_WORDS);
   83|   138k|    if (!bitset->words) {
  ------------------
  |  Branch (83:9): [True: 0, False: 138k]
  ------------------
   84|      0|        roaring_free(bitset);
   85|      0|        return NULL;
   86|      0|    }
   87|   138k|    return bitset;
   88|   138k|}
bitset.c:_avx2_bitset_container_and_nocard:
  523|  1.42k|      bitset_container_t *dst) {                                               \
  524|  1.42k|    const uint8_t *__restrict__ words_1 = (const uint8_t *)src_1->words;       \
  525|  1.42k|    const uint8_t *__restrict__ words_2 = (const uint8_t *)src_2->words;       \
  526|  1.42k|    /* not using the blocking optimization for some reason*/                   \
  527|  1.42k|    uint8_t *out = (uint8_t *)dst->words;                                      \
  528|  1.42k|    const int innerloop = 8;                                                   \
  529|  1.42k|    for (size_t i = 0;                                                         \
  530|  47.1k|         i < BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG);             \
  ------------------
  |  |  269|  47.1k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  |  Branch (530:10): [True: 45.7k, False: 1.42k]
  ------------------
  531|  45.7k|         i += innerloop) {                                                     \
  532|  45.7k|      __m256i A1, A2, AO;                                                      \
  533|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1));                     \
  534|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2));                     \
  535|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  536|  45.7k|      _mm256_storeu_si256((__m256i *)out, AO);                                 \
  537|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 32));                \
  538|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 32));                \
  539|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  540|  45.7k|      _mm256_storeu_si256((__m256i *)(out + 32), AO);                          \
  541|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 64));                \
  542|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 64));                \
  543|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  544|  45.7k|      _mm256_storeu_si256((__m256i *)(out + 64), AO);                          \
  545|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 96));                \
  546|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 96));                \
  547|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  548|  45.7k|      _mm256_storeu_si256((__m256i *)(out + 96), AO);                          \
  549|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 128));               \
  550|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 128));               \
  551|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  552|  45.7k|      _mm256_storeu_si256((__m256i *)(out + 128), AO);                         \
  553|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 160));               \
  554|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 160));               \
  555|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  556|  45.7k|      _mm256_storeu_si256((__m256i *)(out + 160), AO);                         \
  557|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 192));               \
  558|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 192));               \
  559|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  560|  45.7k|      _mm256_storeu_si256((__m256i *)(out + 192), AO);                         \
  561|  45.7k|      A1 = _mm256_loadu_si256((const __m256i *)(words_1 + 224));               \
  562|  45.7k|      A2 = _mm256_loadu_si256((const __m256i *)(words_2 + 224));               \
  563|  45.7k|      AO = avx_intrinsic(A2, A1);                                              \
  564|  45.7k|      _mm256_storeu_si256((__m256i *)(out + 224), AO);                         \
  565|  45.7k|      out += 256;                                                              \
  566|  45.7k|      words_1 += 256;                                                          \
  567|  45.7k|      words_2 += 256;                                                          \
  568|  45.7k|    }                                                                          \
  569|  1.42k|    dst->cardinality = BITSET_UNKNOWN_CARDINALITY;                             \
  570|  1.42k|    return dst->cardinality;                                                   \
  571|  1.42k|  }
bitset.c:_avx2_bitset_container_and_justcard:
  592|  1.42k|      const bitset_container_t *src_1, const bitset_container_t *src_2) {      \
  593|  1.42k|    const __m256i *__restrict__ data1 = (const __m256i *)src_1->words;         \
  594|  1.42k|    const __m256i *__restrict__ data2 = (const __m256i *)src_2->words;         \
  595|  1.42k|    return (int)avx2_harley_seal_popcount256_##opname(                         \
  596|  1.42k|        data2, data1, BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));   \
  ------------------
  |  |  269|  1.42k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  597|  1.42k|  }
bitset.c:_avx2_bitset_container_xor:
  578|  1.41k|                                      bitset_container_t *dst) {               \
  579|  1.41k|    const __m256i *__restrict__ words_1 = (const __m256i *)src_1->words;       \
  580|  1.41k|    const __m256i *__restrict__ words_2 = (const __m256i *)src_2->words;       \
  581|  1.41k|    __m256i *out = (__m256i *)dst->words;                                      \
  582|  1.41k|    dst->cardinality = (int32_t)avx2_harley_seal_popcount256andstore_##opname( \
  583|  1.41k|        words_2, words_1, out,                                                 \
  584|  1.41k|        BITSET_CONTAINER_SIZE_IN_WORDS / (CROARING_WORDS_IN_AVX2_REG));                 \
  ------------------
  |  |  269|  1.41k|#define CROARING_WORDS_IN_AVX2_REG sizeof(__m256i) / sizeof(uint64_t)
  ------------------
  585|  1.41k|    return dst->cardinality;                                                   \
  586|  1.41k|  }                                                                            \
bitset.c:_avx2_bitset_container_equals:
 1158|  3.82k|static inline bool _avx2_bitset_container_equals(const bitset_container_t *container1, const bitset_container_t *container2) {
 1159|  3.82k|    const __m256i *ptr1 = (const __m256i*)container1->words;
 1160|  3.82k|    const __m256i *ptr2 = (const __m256i*)container2->words;
 1161|   983k|    for (size_t i = 0; i < BITSET_CONTAINER_SIZE_IN_WORDS*sizeof(uint64_t)/32; i++) {
  ------------------
  |  Branch (1161:24): [True: 979k, False: 3.82k]
  ------------------
 1162|   979k|      __m256i r1 = _mm256_loadu_si256(ptr1+i);
 1163|   979k|      __m256i r2 = _mm256_loadu_si256(ptr2+i);
 1164|   979k|      int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 1165|   979k|      if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (1165:11): [True: 0, False: 979k]
  ------------------
 1166|      0|          return false;
 1167|      0|      }
 1168|   979k|  }
 1169|  3.82k|	return true;
 1170|  3.82k|}

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

bitset_container_from_array:
   23|  2.23k|bitset_container_t *bitset_container_from_array(const array_container_t *ac) {
   24|  2.23k|    bitset_container_t *ans = bitset_container_create();
   25|  2.23k|    int limit = array_container_cardinality(ac);
   26|  2.37M|    for (int i = 0; i < limit; ++i) bitset_container_set(ans, ac->array[i]);
  ------------------
  |  Branch (26:21): [True: 2.37M, False: 2.23k]
  ------------------
   27|  2.23k|    return ans;
   28|  2.23k|}
bitset_container_from_run:
   31|    488|bitset_container_t *bitset_container_from_run(const run_container_t *arr) {
   32|    488|    int card = run_container_cardinality(arr);
   33|    488|    bitset_container_t *answer = bitset_container_create();
   34|  16.6k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (34:26): [True: 16.1k, False: 488]
  ------------------
   35|  16.1k|        rle16_t vl = arr->runs[rlepos];
   36|  16.1k|        bitset_set_lenrange(answer->words, vl.value, vl.length);
   37|  16.1k|    }
   38|    488|    answer->cardinality = card;
   39|    488|    return answer;
   40|    488|}
array_container_from_run:
   42|  1.05k|array_container_t *array_container_from_run(const run_container_t *arr) {
   43|  1.05k|    array_container_t *answer =
   44|  1.05k|        array_container_create_given_capacity(run_container_cardinality(arr));
   45|  1.05k|    answer->cardinality = 0;
   46|  74.4k|    for (int rlepos = 0; rlepos < arr->n_runs; ++rlepos) {
  ------------------
  |  Branch (46:26): [True: 73.3k, False: 1.05k]
  ------------------
   47|  73.3k|        int run_start = arr->runs[rlepos].value;
   48|  73.3k|        int run_end = run_start + arr->runs[rlepos].length;
   49|       |
   50|   454k|        for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (50:41): [True: 381k, False: 73.3k]
  ------------------
   51|   381k|            answer->array[answer->cardinality++] = (uint16_t)run_value;
   52|   381k|        }
   53|  73.3k|    }
   54|  1.05k|    return answer;
   55|  1.05k|}
array_container_from_bitset:
   57|  2.75k|array_container_t *array_container_from_bitset(const bitset_container_t *bits) {
   58|  2.75k|    array_container_t *result =
   59|  2.75k|        array_container_create_given_capacity(bits->cardinality);
   60|  2.75k|    result->cardinality = bits->cardinality;
   61|  2.75k|#if CROARING_IS_X64
   62|  2.75k|#if CROARING_COMPILER_SUPPORTS_AVX512
   63|       |    // Every caller first checks that the cardinality fits an array container
   64|       |    // (<= DEFAULT_MAX_SIZE), so the input here is sparse: under 6.25% density.
   65|       |    // The vector decoder is still faster than the scalar loop at every
   66|       |    // cardinality, from 16 values up, whether the values are spread out,
   67|       |    // clustered or in runs: see microbenchmarks/bitset_to_array_bench.cpp.
   68|       |    // Do not gate it on the cardinality without measuring there: a gate at
   69|       |    // 1024 values made this conversion up to 2.3x slower below the gate.
   70|  2.75k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (70:9): [True: 0, False: 2.75k]
  ------------------
   71|      0|        bitset_extract_setbits_avx512_uint16(
   72|      0|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array,
   73|      0|            bits->cardinality, 0);
   74|      0|    } else
   75|  2.75k|#endif
   76|  2.75k|    {
   77|       |        //  sse version ends up being slower here
   78|       |        // (bitset_extract_setbits_sse_uint16)
   79|       |        // because of the sparsity of the data
   80|  2.75k|        bitset_extract_setbits_uint16(
   81|  2.75k|            bits->words, BITSET_CONTAINER_SIZE_IN_WORDS, result->array, 0);
   82|  2.75k|    }
   83|       |#else
   84|       |    // If the system is not x64, then we have no accelerated function.
   85|       |    bitset_extract_setbits_uint16(bits->words, BITSET_CONTAINER_SIZE_IN_WORDS,
   86|       |                                  result->array, 0);
   87|       |#endif
   88|       |
   89|  2.75k|    return result;
   90|  2.75k|}
convert_to_bitset_or_array_container:
  129|  66.3k|                                                  uint8_t *resulttype) {
  130|  66.3k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (130:9): [True: 1.14k, False: 65.2k]
  ------------------
  131|  1.14k|        array_container_t *answer = array_container_create_given_capacity(card);
  132|  1.14k|        answer->cardinality = 0;
  133|  56.0k|        for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (133:30): [True: 54.8k, False: 1.14k]
  ------------------
  134|  54.8k|            uint16_t run_start = rc->runs[rlepos].value;
  135|  54.8k|            uint16_t run_end = run_start + rc->runs[rlepos].length;
  136|   634k|            for (uint16_t run_value = run_start; run_value < run_end;
  ------------------
  |  Branch (136:50): [True: 579k, False: 54.8k]
  ------------------
  137|   579k|                 ++run_value) {
  138|   579k|                answer->array[answer->cardinality++] = run_value;
  139|   579k|            }
  140|  54.8k|            answer->array[answer->cardinality++] = run_end;
  141|  54.8k|        }
  142|  1.14k|        assert(card == answer->cardinality);
  143|  1.14k|        *resulttype = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.14k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  144|       |        // run_container_free(r);
  145|  1.14k|        return answer;
  146|  1.14k|    }
  147|  65.2k|    bitset_container_t *answer = bitset_container_create();
  148|   161k|    for (int rlepos = 0; rlepos < rc->n_runs; ++rlepos) {
  ------------------
  |  Branch (148:26): [True: 96.4k, False: 65.2k]
  ------------------
  149|  96.4k|        uint16_t run_start = rc->runs[rlepos].value;
  150|  96.4k|        bitset_set_lenrange(answer->words, run_start, rc->runs[rlepos].length);
  151|  96.4k|    }
  152|  65.2k|    answer->cardinality = card;
  153|  65.2k|    *resulttype = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  65.2k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  154|       |    // run_container_free(r);
  155|  65.2k|    return answer;
  156|  66.3k|}
convert_run_to_efficient_container:
  164|   125k|                                                uint8_t *typecode_after) {
  165|   125k|    int32_t size_as_run_container =
  166|   125k|        run_container_serialized_size_in_bytes(c->n_runs);
  167|       |
  168|   125k|    int32_t size_as_bitset_container =
  169|   125k|        bitset_container_serialized_size_in_bytes();
  170|   125k|    int32_t card = run_container_cardinality(c);
  171|   125k|    int32_t size_as_array_container =
  172|   125k|        array_container_serialized_size_in_bytes(card);
  173|       |
  174|   125k|    int32_t min_size_non_run =
  175|   125k|        size_as_bitset_container < size_as_array_container
  ------------------
  |  Branch (175:9): [True: 55.7k, False: 69.5k]
  ------------------
  176|   125k|            ? size_as_bitset_container
  177|   125k|            : size_as_array_container;
  178|   125k|    if (size_as_run_container <= min_size_non_run) {  // no conversion
  ------------------
  |  Branch (178:9): [True: 63.5k, False: 61.6k]
  ------------------
  179|  63.5k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  63.5k|#define RUN_CONTAINER_TYPE 3
  ------------------
  180|  63.5k|        return c;
  181|  63.5k|    }
  182|  61.6k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (182:9): [True: 61.6k, False: 0]
  ------------------
  183|       |        // to array
  184|  61.6k|        array_container_t *answer = array_container_create_given_capacity(card);
  185|  61.6k|        answer->cardinality = 0;
  186|   195k|        for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (186:30): [True: 133k, False: 61.6k]
  ------------------
  187|   133k|            int run_start = c->runs[rlepos].value;
  188|   133k|            int run_end = run_start + c->runs[rlepos].length;
  189|       |
  190|   359k|            for (int run_value = run_start; run_value <= run_end; ++run_value) {
  ------------------
  |  Branch (190:45): [True: 225k, False: 133k]
  ------------------
  191|   225k|                answer->array[answer->cardinality++] = (uint16_t)run_value;
  192|   225k|            }
  193|   133k|        }
  194|  61.6k|        *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  61.6k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  195|  61.6k|        return answer;
  196|  61.6k|    }
  197|       |
  198|       |    // else to bitset
  199|      0|    bitset_container_t *answer = bitset_container_create();
  200|       |
  201|      0|    for (int rlepos = 0; rlepos < c->n_runs; ++rlepos) {
  ------------------
  |  Branch (201:26): [True: 0, False: 0]
  ------------------
  202|      0|        int start = c->runs[rlepos].value;
  203|      0|        int end = start + c->runs[rlepos].length;
  204|      0|        bitset_set_range(answer->words, start, end + 1);
  205|      0|    }
  206|      0|    answer->cardinality = card;
  207|      0|    *typecode_after = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  208|      0|    return answer;
  209|  61.6k|}
convert_run_to_efficient_container_and_free:
  213|   113k|    run_container_t *c, uint8_t *typecode_after) {
  214|   113k|    container_t *answer = convert_run_to_efficient_container(c, typecode_after);
  215|   113k|    if (answer != c) run_container_free(c);
  ------------------
  |  Branch (215:9): [True: 54.8k, False: 58.5k]
  ------------------
  216|   113k|    return answer;
  217|   113k|}
convert_run_optimize:
  227|  14.2k|                                  uint8_t *typecode_after) {
  228|  14.2k|    if (typecode_original == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  14.2k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (228:9): [True: 0, False: 14.2k]
  ------------------
  229|      0|        container_t *newc =
  230|      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)
  |  |  ------------------
  ------------------
  231|      0|        if (newc != c) {
  ------------------
  |  Branch (231:13): [True: 0, False: 0]
  ------------------
  232|      0|            container_free(c, typecode_original);
  233|      0|        }
  234|      0|        return newc;
  235|  14.2k|    } else if (typecode_original == ARRAY_CONTAINER_TYPE) {
  ------------------
  |  |   49|  14.2k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (235:16): [True: 14.2k, False: 0]
  ------------------
  236|       |        // it might need to be converted to a run container.
  237|  14.2k|        array_container_t *c_qua_array = CAST_array(c);
  ------------------
  |  |   54|  14.2k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  14.2k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  238|  14.2k|        int32_t n_runs = array_container_number_of_runs(c_qua_array);
  239|  14.2k|        int32_t size_as_run_container =
  240|  14.2k|            run_container_serialized_size_in_bytes(n_runs);
  241|  14.2k|        int32_t card = array_container_cardinality(c_qua_array);
  242|  14.2k|        int32_t size_as_array_container =
  243|  14.2k|            array_container_serialized_size_in_bytes(card);
  244|       |
  245|  14.2k|        if (size_as_run_container >= size_as_array_container) {
  ------------------
  |  Branch (245:13): [True: 10.6k, False: 3.64k]
  ------------------
  246|  10.6k|            *typecode_after = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  10.6k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  247|  10.6k|            return c;
  248|  10.6k|        }
  249|       |        // else convert array to run container
  250|  3.64k|        run_container_t *answer = run_container_create_given_capacity(n_runs);
  251|  3.64k|        int prev = -2;
  252|  3.64k|        int run_start = -1;
  253|       |
  254|  3.64k|        assert(card > 0);
  255|   568k|        for (int i = 0; i < card; ++i) {
  ------------------
  |  Branch (255:25): [True: 565k, False: 3.64k]
  ------------------
  256|   565k|            uint16_t cur_val = c_qua_array->array[i];
  257|   565k|            if (cur_val != prev + 1) {
  ------------------
  |  Branch (257:17): [True: 230k, False: 334k]
  ------------------
  258|       |                // new run starts; flush old one, if any
  259|   230k|                if (run_start != -1) add_run(answer, run_start, prev);
  ------------------
  |  Branch (259:21): [True: 227k, False: 3.64k]
  ------------------
  260|   230k|                run_start = cur_val;
  261|   230k|            }
  262|   565k|            prev = c_qua_array->array[i];
  263|   565k|        }
  264|  3.64k|        assert(run_start >= 0);
  265|       |        // now prev is the last seen value
  266|  3.64k|        add_run(answer, run_start, prev);
  267|  3.64k|        *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|  3.64k|#define RUN_CONTAINER_TYPE 3
  ------------------
  268|  3.64k|        array_container_free(c_qua_array);
  269|  3.64k|        return answer;
  270|  14.2k|    } else if (typecode_original ==
  ------------------
  |  Branch (270:16): [True: 0, False: 0]
  ------------------
  271|      0|               BITSET_CONTAINER_TYPE) {  // run conversions on bitset
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  272|       |        // does bitset need conversion to run?
  273|      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)
  |  |  ------------------
  ------------------
  274|      0|        int32_t n_runs = bitset_container_number_of_runs(c_qua_bitset);
  275|      0|        int32_t size_as_run_container =
  276|      0|            run_container_serialized_size_in_bytes(n_runs);
  277|      0|        int32_t size_as_bitset_container =
  278|      0|            bitset_container_serialized_size_in_bytes();
  279|       |
  280|      0|        if (size_as_bitset_container <= size_as_run_container) {
  ------------------
  |  Branch (280:13): [True: 0, False: 0]
  ------------------
  281|       |            // no conversion needed.
  282|      0|            *typecode_after = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|      0|#define BITSET_CONTAINER_TYPE 1
  ------------------
  283|      0|            return c;
  284|      0|        }
  285|       |        // bitset to runcontainer (ported from Java  RunContainer(
  286|       |        // BitmapContainer bc, int nbrRuns))
  287|      0|        assert(n_runs > 0);  // no empty bitmaps
  288|      0|        run_container_t *answer = run_container_create_given_capacity(n_runs);
  289|       |
  290|      0|        int long_ctr = 0;
  291|      0|        uint64_t cur_word = c_qua_bitset->words[0];
  292|      0|        while (true) {
  ------------------
  |  Branch (292:16): [True: 0, Folded]
  ------------------
  293|      0|            while (cur_word == UINT64_C(0) &&
  ------------------
  |  Branch (293:20): [True: 0, False: 0]
  ------------------
  294|      0|                   long_ctr < BITSET_CONTAINER_SIZE_IN_WORDS - 1)
  ------------------
  |  Branch (294:20): [True: 0, False: 0]
  ------------------
  295|      0|                cur_word = c_qua_bitset->words[++long_ctr];
  296|       |
  297|      0|            if (cur_word == UINT64_C(0)) {
  ------------------
  |  Branch (297:17): [True: 0, False: 0]
  ------------------
  298|      0|                bitset_container_free(c_qua_bitset);
  299|      0|                *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  300|      0|                return answer;
  301|      0|            }
  302|       |
  303|      0|            int local_run_start = roaring_trailing_zeroes(cur_word);
  304|      0|            int run_start = local_run_start + 64 * long_ctr;
  305|      0|            uint64_t cur_word_with_1s = cur_word | (cur_word - 1);
  306|       |
  307|      0|            int run_end = 0;
  308|      0|            while (cur_word_with_1s == UINT64_C(0xFFFFFFFFFFFFFFFF) &&
  ------------------
  |  Branch (308:20): [True: 0, False: 0]
  ------------------
  309|      0|                   long_ctr < BITSET_CONTAINER_SIZE_IN_WORDS - 1)
  ------------------
  |  Branch (309:20): [True: 0, False: 0]
  ------------------
  310|      0|                cur_word_with_1s = c_qua_bitset->words[++long_ctr];
  311|       |
  312|      0|            if (cur_word_with_1s == UINT64_C(0xFFFFFFFFFFFFFFFF)) {
  ------------------
  |  Branch (312:17): [True: 0, False: 0]
  ------------------
  313|      0|                run_end = 64 + long_ctr * 64;  // exclusive, I guess
  314|      0|                add_run(answer, run_start, run_end - 1);
  315|      0|                bitset_container_free(c_qua_bitset);
  316|      0|                *typecode_after = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  317|      0|                return answer;
  318|      0|            }
  319|      0|            int local_run_end = roaring_trailing_zeroes(~cur_word_with_1s);
  320|      0|            run_end = local_run_end + long_ctr * 64;
  321|      0|            add_run(answer, run_start, run_end - 1);
  322|      0|            cur_word = cur_word_with_1s & (cur_word_with_1s + 1);
  323|      0|        }
  324|      0|        return answer;
  325|      0|    } else {
  326|      0|        assert(false);
  327|      0|        roaring_unreachable;
  ------------------
  |  |  246|      0|#define roaring_unreachable __builtin_unreachable()
  ------------------
  328|      0|        return NULL;
  329|      0|    }
  330|  14.2k|}
convert.c:add_run:
   93|   230k|static void add_run(run_container_t *rc, int s, int e) {
   94|   230k|    rc->runs[rc->n_runs].value = s;
   95|   230k|    rc->runs[rc->n_runs].length = e - s;
   96|   230k|    rc->n_runs++;
   97|   230k|}

array_bitset_container_andnot:
   26|    572|                                   array_container_t *dst) {
   27|       |    // follows Java implementation as of June 2016
   28|    572|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (28:9): [True: 572, False: 0]
  ------------------
   29|    572|        array_container_grow(dst, src_1->cardinality, false);
   30|    572|    }
   31|    572|    int32_t newcard = 0;
   32|    572|    const int32_t origcard = src_1->cardinality;
   33|    572|    const uint16_t *array = src_1->array;
   34|    572|    const uint64_t *words = src_2->words;
   35|    572|    uint16_t *out = dst->array;
   36|  85.5k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (36:21): [True: 84.9k, False: 572]
  ------------------
   37|  84.9k|        uint16_t key = array[i];
   38|  84.9k|        out[newcard] = key;
   39|  84.9k|        newcard += 1 - ((words[key >> 6] >> (key & 63)) & 1);
   40|  84.9k|    }
   41|    572|    dst->cardinality = newcard;
   42|    572|}
bitset_array_container_iandnot:
   86|  1.40k|                                    container_t **dst) {
   87|  1.40k|    *dst = src_1;
   88|  1.40k|    src_1->cardinality =
   89|  1.40k|        (int32_t)bitset_clear_list(src_1->words, (uint64_t)src_1->cardinality,
   90|  1.40k|                                   src_2->array, (uint64_t)src_2->cardinality);
   91|       |
   92|  1.40k|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (92:9): [True: 215, False: 1.18k]
  ------------------
   93|    215|        *dst = array_container_from_bitset(src_1);
   94|    215|        bitset_container_free(src_1);
   95|    215|        return false;  // not bitset
   96|    215|    } else
   97|  1.18k|        return true;
   98|  1.40k|}
run_bitset_container_andnot:
  109|    590|                                 container_t **dst) {
  110|       |    // follows the Java implementation as of June 2016
  111|    590|    int card = run_container_cardinality(src_1);
  112|    590|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (112:9): [True: 590, False: 0]
  ------------------
  113|       |        // must be an array
  114|    590|        array_container_t *answer = array_container_create_given_capacity(card);
  115|    590|        answer->cardinality = 0;
  116|  47.5k|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (116:34): [True: 46.9k, False: 590]
  ------------------
  117|  46.9k|            rle16_t rle = src_1->runs[rlepos];
  118|   167k|            for (int run_value = rle.value; run_value <= rle.value + rle.length;
  ------------------
  |  Branch (118:45): [True: 120k, False: 46.9k]
  ------------------
  119|   120k|                 ++run_value) {
  120|   120k|                if (!bitset_container_get(src_2, (uint16_t)run_value)) {
  ------------------
  |  Branch (120:21): [True: 35.8k, False: 84.8k]
  ------------------
  121|  35.8k|                    answer->array[answer->cardinality++] = (uint16_t)run_value;
  122|  35.8k|                }
  123|   120k|            }
  124|  46.9k|        }
  125|    590|        *dst = answer;
  126|    590|        return false;
  127|    590|    } else {  // we guess it will be a bitset, though have to check guess when
  128|       |              // done
  129|      0|        bitset_container_t *answer = bitset_container_clone(src_2);
  130|       |
  131|      0|        uint32_t last_pos = 0;
  132|      0|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (132:34): [True: 0, False: 0]
  ------------------
  133|      0|            rle16_t rle = src_1->runs[rlepos];
  134|       |
  135|      0|            uint32_t start = rle.value;
  136|      0|            uint32_t end = start + rle.length + 1;
  137|      0|            bitset_reset_range(answer->words, last_pos, start);
  138|      0|            bitset_flip_range(answer->words, start, end);
  139|      0|            last_pos = end;
  140|      0|        }
  141|      0|        bitset_reset_range(answer->words, last_pos, (uint32_t)(1 << 16));
  142|       |
  143|      0|        answer->cardinality = bitset_container_compute_cardinality(answer);
  144|       |
  145|      0|        if (answer->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (145:13): [True: 0, False: 0]
  ------------------
  146|      0|            *dst = array_container_from_bitset(answer);
  147|      0|            bitset_container_free(answer);
  148|      0|            return false;  // not bitset
  149|      0|        }
  150|      0|        *dst = answer;
  151|       |        return true;  // bitset
  152|      0|    }
  153|    590|}
run_array_container_andnot:
  282|  1.82k|                               container_t **dst) {
  283|       |    // follows the Java impl as of June 2016
  284|       |
  285|  1.82k|    int card = run_container_cardinality(src_1);
  286|  1.82k|    const int arbitrary_threshold = 32;
  287|       |
  288|  1.82k|    if (card <= arbitrary_threshold) {
  ------------------
  |  Branch (288:9): [True: 327, False: 1.49k]
  ------------------
  289|    327|        if (src_2->cardinality == 0) {
  ------------------
  |  Branch (289:13): [True: 0, False: 327]
  ------------------
  290|      0|            *dst = run_container_clone(src_1);
  291|      0|            return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  292|      0|        }
  293|       |        // Java's "lazyandNot.toEfficientContainer" thing
  294|    327|        run_container_t *answer = run_container_create_given_capacity(
  295|    327|            card + array_container_cardinality(src_2));
  296|       |
  297|    327|        int rlepos = 0;
  298|    327|        int xrlepos = 0;  // "x" is src_2
  299|    327|        rle16_t rle = src_1->runs[rlepos];
  300|    327|        int32_t start = rle.value;
  301|    327|        int32_t end = start + rle.length + 1;
  302|    327|        int32_t xstart = src_2->array[xrlepos];
  303|       |
  304|  10.2k|        while ((rlepos < src_1->n_runs) && (xrlepos < src_2->cardinality)) {
  ------------------
  |  Branch (304:16): [True: 9.96k, False: 273]
  |  Branch (304:44): [True: 9.90k, False: 54]
  ------------------
  305|  9.90k|            if (end <= xstart) {
  ------------------
  |  Branch (305:17): [True: 562, False: 9.34k]
  ------------------
  306|       |                // output the first run
  307|    562|                answer->runs[answer->n_runs++] =
  308|    562|                    CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    562|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  309|    562|                rlepos++;
  310|    562|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (310:21): [True: 513, False: 49]
  ------------------
  311|    513|                    start = src_1->runs[rlepos].value;
  312|    513|                    end = start + src_1->runs[rlepos].length + 1;
  313|    513|                }
  314|  9.34k|            } else if (xstart + 1 <= start) {
  ------------------
  |  Branch (314:24): [True: 5.96k, False: 3.38k]
  ------------------
  315|       |                // exit the second run
  316|  5.96k|                xrlepos++;
  317|  5.96k|                if (xrlepos < src_2->cardinality) {
  ------------------
  |  Branch (317:21): [True: 5.90k, False: 54]
  ------------------
  318|  5.90k|                    xstart = src_2->array[xrlepos];
  319|  5.90k|                }
  320|  5.96k|            } else {
  321|  3.38k|                if (start < xstart) {
  ------------------
  |  Branch (321:21): [True: 289, False: 3.09k]
  ------------------
  322|    289|                    answer->runs[answer->n_runs++] =
  323|    289|                        CROARING_MAKE_RLE16(start, xstart - start - 1);
  ------------------
  |  |   60|    289|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  324|    289|                }
  325|  3.38k|                if (xstart + 1 < end) {
  ------------------
  |  Branch (325:21): [True: 2.01k, False: 1.37k]
  ------------------
  326|  2.01k|                    start = xstart + 1;
  327|  2.01k|                } else {
  328|  1.37k|                    rlepos++;
  329|  1.37k|                    if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (329:25): [True: 1.14k, False: 224]
  ------------------
  330|  1.14k|                        start = src_1->runs[rlepos].value;
  331|  1.14k|                        end = start + src_1->runs[rlepos].length + 1;
  332|  1.14k|                    }
  333|  1.37k|                }
  334|  3.38k|            }
  335|  9.90k|        }
  336|    327|        if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (336:13): [True: 54, False: 273]
  ------------------
  337|     54|            answer->runs[answer->n_runs++] =
  338|     54|                CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|     54|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  339|     54|            rlepos++;
  340|     54|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (340:17): [True: 19, False: 35]
  ------------------
  341|     19|                memcpy(answer->runs + answer->n_runs, src_1->runs + rlepos,
  342|     19|                       (src_1->n_runs - rlepos) * sizeof(rle16_t));
  343|     19|                answer->n_runs += (src_1->n_runs - rlepos);
  344|     19|            }
  345|     54|        }
  346|    327|        uint8_t return_type;
  347|    327|        *dst = convert_run_to_efficient_container(answer, &return_type);
  348|    327|        if (answer != *dst) run_container_free(answer);
  ------------------
  |  Branch (348:13): [True: 216, False: 111]
  ------------------
  349|    327|        return return_type;
  350|    327|    }
  351|       |    // else it's a bitmap or array
  352|       |
  353|  1.49k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (353:9): [True: 1.22k, False: 270]
  ------------------
  354|  1.22k|        array_container_t *ac = array_container_create_given_capacity(card);
  355|       |        // nb Java code used a generic iterator-based merge to compute
  356|       |        // difference
  357|  1.22k|        ac->cardinality = run_array_array_subtract(src_1, src_2, ac);
  358|  1.22k|        *dst = ac;
  359|  1.22k|        return ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.22k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  360|  1.22k|    }
  361|    270|    bitset_container_t *ans = bitset_container_from_run(src_1);
  362|    270|    bool result_is_bitset = bitset_array_container_iandnot(ans, src_2, dst);
  363|    270|    return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    259|#define BITSET_CONTAINER_TYPE 1
  ------------------
                  return (result_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     11|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (363:13): [True: 259, False: 11]
  ------------------
  364|  1.49k|}
run_array_container_iandnot:
  375|    710|                                container_t **dst) {
  376|       |    // dummy implementation same as June 2016 Java
  377|    710|    int ans = run_array_container_andnot(src_1, src_2, dst);
  378|    710|    run_container_free(src_1);
  379|    710|    return ans;
  380|    710|}
array_run_container_andnot:
  386|    725|                                array_container_t *dst) {
  387|       |    // basically following Java impl as of June 2016
  388|    725|    if (src_1->cardinality > dst->capacity) {
  ------------------
  |  Branch (388:9): [True: 683, False: 42]
  ------------------
  389|    683|        array_container_grow(dst, src_1->cardinality, false);
  390|    683|    }
  391|       |
  392|    725|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (392:9): [True: 0, False: 725]
  ------------------
  393|      0|        memmove(dst->array, src_1->array,
  394|      0|                sizeof(uint16_t) * src_1->cardinality);
  395|      0|        dst->cardinality = src_1->cardinality;
  396|      0|        return;
  397|      0|    }
  398|    725|    int32_t run_start = src_2->runs[0].value;
  399|    725|    int32_t run_end = run_start + src_2->runs[0].length;
  400|    725|    int which_run = 0;
  401|       |
  402|    725|    uint16_t val = 0;
  403|    725|    int dest_card = 0;
  404|   144k|    for (int i = 0; i < src_1->cardinality; ++i) {
  ------------------
  |  Branch (404:21): [True: 143k, False: 725]
  ------------------
  405|   143k|        val = src_1->array[i];
  406|   143k|        if (val < run_start)
  ------------------
  |  Branch (406:13): [True: 38.3k, False: 105k]
  ------------------
  407|  38.3k|            dst->array[dest_card++] = val;
  408|   105k|        else if (val <= run_end) {
  ------------------
  |  Branch (408:18): [True: 74.9k, False: 30.3k]
  ------------------
  409|  74.9k|            ;  // omitted item
  410|  74.9k|        } else {
  411|  42.8k|            do {
  412|  42.8k|                if (which_run + 1 < src_2->n_runs) {
  ------------------
  |  Branch (412:21): [True: 42.6k, False: 167]
  ------------------
  413|  42.6k|                    ++which_run;
  414|  42.6k|                    run_start = src_2->runs[which_run].value;
  415|  42.6k|                    run_end = run_start + src_2->runs[which_run].length;
  416|       |
  417|  42.6k|                } else
  418|    167|                    run_start = run_end = (1 << 16) + 1;
  419|  42.8k|            } while (val > run_end);
  ------------------
  |  Branch (419:22): [True: 12.4k, False: 30.3k]
  ------------------
  420|  30.3k|            --i;
  421|  30.3k|        }
  422|   143k|    }
  423|    725|    dst->cardinality = dest_card;
  424|    725|}
array_run_container_iandnot:
  431|     42|                                 const run_container_t *src_2) {
  432|     42|    array_run_container_andnot(src_1, src_2, src_1);
  433|     42|}
run_run_container_andnot:
  440|  1.02k|                             const run_container_t *src_2, container_t **dst) {
  441|  1.02k|    run_container_t *ans = run_container_create();
  442|  1.02k|    run_container_andnot(src_1, src_2, ans);
  443|  1.02k|    uint8_t typecode_after;
  444|  1.02k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  445|  1.02k|    return typecode_after;
  446|  1.02k|}
run_run_container_iandnot:
  456|    401|                              const run_container_t *src_2, container_t **dst) {
  457|       |    // following Java impl as of June 2016 (dummy)
  458|    401|    int ans = run_run_container_andnot(src_1, src_2, dst);
  459|    401|    run_container_free(src_1);
  460|    401|    return ans;
  461|    401|}
array_array_container_andnot:
  469|  3.40k|                                  array_container_t *dst) {
  470|  3.40k|    array_container_andnot(src_1, src_2, dst);
  471|  3.40k|}
array_array_container_iandnot:
  476|  4.42k|                                   const array_container_t *src_2) {
  477|  4.42k|    array_container_andnot(src_1, src_2, src_1);
  478|  4.42k|}
mixed_andnot.c:run_array_array_subtract:
  238|  1.22k|                                    array_container_t *a_out) {
  239|  1.22k|    int out_card = 0;
  240|  1.22k|    int32_t in_array_pos =
  241|  1.22k|        -1;  // since advanceUntil always assumes we start the search AFTER this
  242|       |
  243|  87.6k|    for (int rlepos = 0; rlepos < rc->n_runs; rlepos++) {
  ------------------
  |  Branch (243:26): [True: 86.4k, False: 1.22k]
  ------------------
  244|  86.4k|        int32_t start = rc->runs[rlepos].value;
  245|  86.4k|        int32_t end = start + rc->runs[rlepos].length + 1;
  246|       |
  247|  86.4k|        in_array_pos = advanceUntil(a_in->array, in_array_pos,
  248|  86.4k|                                    a_in->cardinality, (uint16_t)start);
  249|       |
  250|  86.4k|        if (in_array_pos >= a_in->cardinality) {  // run has no items subtracted
  ------------------
  |  Branch (250:13): [True: 4.40k, False: 82.0k]
  ------------------
  251|   119k|            for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (251:37): [True: 115k, False: 4.40k]
  ------------------
  252|   115k|                a_out->array[out_card++] = (uint16_t)i;
  253|  82.0k|        } else {
  254|  82.0k|            uint16_t next_nonincluded = a_in->array[in_array_pos];
  255|  82.0k|            if (next_nonincluded >= end) {
  ------------------
  |  Branch (255:17): [True: 28.6k, False: 53.3k]
  ------------------
  256|       |                // another case when run goes unaltered
  257|  77.2k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (257:41): [True: 48.5k, False: 28.6k]
  ------------------
  258|  48.5k|                    a_out->array[out_card++] = (uint16_t)i;
  259|  28.6k|                in_array_pos--;  // ensure we see this item again if necessary
  260|  53.3k|            } else {
  261|   299k|                for (int32_t i = start; i < end; ++i)
  ------------------
  |  Branch (261:41): [True: 246k, False: 53.3k]
  ------------------
  262|   246k|                    if (i != next_nonincluded)
  ------------------
  |  Branch (262:25): [True: 125k, False: 120k]
  ------------------
  263|   125k|                        a_out->array[out_card++] = (uint16_t)i;
  264|   120k|                    else  // 0 should ensure  we don't match
  265|   120k|                        next_nonincluded =
  266|   120k|                            (in_array_pos + 1 >= a_in->cardinality)
  ------------------
  |  Branch (266:29): [True: 971, False: 119k]
  ------------------
  267|   120k|                                ? 0
  268|   120k|                                : a_in->array[++in_array_pos];
  269|  53.3k|                in_array_pos--;  // see again
  270|  53.3k|            }
  271|  82.0k|        }
  272|  86.4k|    }
  273|  1.22k|    return out_card;
  274|  1.22k|}

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

array_bitset_container_intersection:
   21|    616|                                         array_container_t *dst) {
   22|    616|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (22:9): [True: 616, False: 0]
  ------------------
   23|    616|        array_container_grow(dst, src_1->cardinality, false);
   24|    616|    }
   25|    616|    int32_t newcard = 0;  // dst could be src_1
   26|    616|    const int32_t origcard = src_1->cardinality;
   27|    616|    const uint16_t *array = src_1->array;
   28|    616|    const uint64_t *words = src_2->words;
   29|    616|    uint16_t *out = dst->array;
   30|   265k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (30:21): [True: 264k, False: 616]
  ------------------
   31|   264k|        uint16_t key = array[i];
   32|       |        // this branchless approach is much faster...
   33|   264k|        out[newcard] = key;
   34|   264k|        newcard += (words[key >> 6] >> (key & 63)) & 1;
   35|       |        /**
   36|       |         * we could do it this way instead...
   37|       |         * if (bitset_container_contains(src_2, key)) {
   38|       |         * dst->array[newcard++] = key;
   39|       |         * }
   40|       |         * but if the result is unpredictible, the processor generates
   41|       |         * many mispredicted branches.
   42|       |         * Difference can be huge (from 3 cycles when predictible all the way
   43|       |         * to 16 cycles when unpredictible.
   44|       |         * See
   45|       |         * https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/master/extra/bitset/c/arraybitsetintersection.c
   46|       |         */
   47|   264k|    }
   48|    616|    dst->cardinality = newcard;
   49|    616|}
array_bitset_container_intersection_cardinality:
   53|  2.28k|    const array_container_t *src_1, const bitset_container_t *src_2) {
   54|  2.28k|    int32_t newcard = 0;
   55|  2.28k|    const int32_t origcard = src_1->cardinality;
   56|   342k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (56:21): [True: 339k, False: 2.28k]
  ------------------
   57|   339k|        uint16_t key = src_1->array[i];
   58|   339k|        newcard += bitset_container_contains(src_2, key);
   59|   339k|    }
   60|  2.28k|    return newcard;
   61|  2.28k|}
array_bitset_container_intersect:
   64|    572|                                      const bitset_container_t *src_2) {
   65|    572|    const int32_t origcard = src_1->cardinality;
   66|  3.73k|    for (int i = 0; i < origcard; ++i) {
  ------------------
  |  Branch (66:21): [True: 3.71k, False: 20]
  ------------------
   67|  3.71k|        uint16_t key = src_1->array[i];
   68|  3.71k|        if (bitset_container_contains(src_2, key)) return true;
  ------------------
  |  Branch (68:13): [True: 552, False: 3.16k]
  ------------------
   69|  3.71k|    }
   70|     20|    return false;
   71|    572|}
array_run_container_intersection:
   78|  2.89k|                                      array_container_t *dst) {
   79|  2.89k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (79:9): [True: 34, False: 2.85k]
  ------------------
   80|     34|        if (dst != src_1) array_container_copy(src_1, dst);
  ------------------
  |  Branch (80:13): [True: 34, False: 0]
  ------------------
   81|     34|        return;
   82|     34|    }
   83|  2.85k|    if (dst->capacity < src_1->cardinality) {
  ------------------
  |  Branch (83:9): [True: 2.85k, False: 0]
  ------------------
   84|  2.85k|        array_container_grow(dst, src_1->cardinality, false);
   85|  2.85k|    }
   86|  2.85k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (86:9): [True: 0, False: 2.85k]
  ------------------
   87|      0|        return;
   88|      0|    }
   89|  2.85k|    int32_t rlepos = 0;
   90|  2.85k|    int32_t arraypos = 0;
   91|  2.85k|    rle16_t rle = src_2->runs[rlepos];
   92|  2.85k|    int32_t newcard = 0;
   93|   407k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (93:12): [True: 405k, False: 2.34k]
  ------------------
   94|   405k|        const uint16_t arrayval = src_1->array[arraypos];
   95|   535k|        while (rle.value + rle.length <
  ------------------
  |  Branch (95:16): [True: 130k, False: 405k]
  ------------------
   96|   535k|               arrayval) {  // this will frequently be false
   97|   130k|            ++rlepos;
   98|   130k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (98:17): [True: 508, False: 129k]
  ------------------
   99|    508|                dst->cardinality = newcard;
  100|    508|                return;  // we are done
  101|    508|            }
  102|   129k|            rle = src_2->runs[rlepos];
  103|   129k|        }
  104|   405k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (104:13): [True: 25.2k, False: 379k]
  ------------------
  105|  25.2k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  106|  25.2k|                                    rle.value);
  107|   379k|        } else {
  108|   379k|            dst->array[newcard] = arrayval;
  109|   379k|            newcard++;
  110|   379k|            arraypos++;
  111|   379k|        }
  112|   405k|    }
  113|  2.34k|    dst->cardinality = newcard;
  114|  2.34k|}
run_bitset_container_intersection:
  122|    590|                                       container_t **dst) {
  123|    590|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (123:9): [True: 0, False: 590]
  ------------------
  124|      0|        if (*dst != src_2) *dst = bitset_container_clone(src_2);
  ------------------
  |  Branch (124:13): [True: 0, False: 0]
  ------------------
  125|      0|        return true;
  126|      0|    }
  127|    590|    int32_t card = run_container_cardinality(src_1);
  128|    590|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (128:9): [True: 590, False: 0]
  ------------------
  129|       |        // result can only be an array (assuming that we never make a
  130|       |        // RunContainer)
  131|    590|        if (card > src_2->cardinality) {
  ------------------
  |  Branch (131:13): [True: 0, False: 590]
  ------------------
  132|      0|            card = src_2->cardinality;
  133|      0|        }
  134|    590|        array_container_t *answer = array_container_create_given_capacity(card);
  135|    590|        *dst = answer;
  136|    590|        if (*dst == NULL) {
  ------------------
  |  Branch (136:13): [True: 0, False: 590]
  ------------------
  137|      0|            return false;
  138|      0|        }
  139|    590|        const rle16_t *runs = src_1->runs;
  140|    590|        const int32_t n_runs = src_1->n_runs;
  141|    590|        const uint64_t *words = src_2->words;
  142|    590|        uint16_t *out = answer->array;
  143|    590|        int32_t newcard = 0;
  144|  47.5k|        for (int32_t rlepos = 0; rlepos < n_runs; ++rlepos) {
  ------------------
  |  Branch (144:34): [True: 46.9k, False: 590]
  ------------------
  145|  46.9k|            rle16_t rle = runs[rlepos];
  146|  46.9k|            uint32_t endofrun = (uint32_t)rle.value + rle.length;
  147|   167k|            for (uint32_t runValue = rle.value; runValue <= endofrun;
  ------------------
  |  Branch (147:49): [True: 120k, False: 46.9k]
  ------------------
  148|   120k|                 ++runValue) {
  149|   120k|                out[newcard] = (uint16_t)runValue;
  150|   120k|                newcard += (words[runValue >> 6] >> (runValue & 63)) & 1;
  151|   120k|            }
  152|  46.9k|        }
  153|    590|        answer->cardinality = newcard;
  154|    590|        return false;
  155|    590|    }
  156|      0|    if (*dst == src_2) {  // we attempt in-place
  ------------------
  |  Branch (156:9): [True: 0, False: 0]
  ------------------
  157|      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)
  |  |  ------------------
  ------------------
  158|      0|        uint32_t start = 0;
  159|      0|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (159:34): [True: 0, False: 0]
  ------------------
  160|      0|            const rle16_t rle = src_1->runs[rlepos];
  161|      0|            uint32_t end = rle.value;
  162|      0|            bitset_reset_range(src_2->words, start, end);
  163|       |
  164|      0|            start = end + rle.length + 1;
  165|      0|        }
  166|      0|        bitset_reset_range(src_2->words, start, UINT32_C(1) << 16);
  167|      0|        answer->cardinality = bitset_container_compute_cardinality(answer);
  168|      0|        if (src_2->cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (168:13): [True: 0, False: 0]
  ------------------
  169|      0|            return true;
  170|      0|        } else {
  171|      0|            array_container_t *newanswer = array_container_from_bitset(src_2);
  172|      0|            if (newanswer == NULL) {
  ------------------
  |  Branch (172:17): [True: 0, False: 0]
  ------------------
  173|      0|                *dst = NULL;
  174|      0|                return false;
  175|      0|            }
  176|      0|            *dst = newanswer;
  177|      0|            return false;
  178|      0|        }
  179|      0|    } else {  // no inplace
  180|       |        // we expect the answer to be a bitmap (if we are lucky)
  181|      0|        bitset_container_t *answer = bitset_container_clone(src_2);
  182|       |
  183|      0|        *dst = answer;
  184|      0|        if (answer == NULL) {
  ------------------
  |  Branch (184:13): [True: 0, False: 0]
  ------------------
  185|      0|            return true;
  186|      0|        }
  187|      0|        uint32_t start = 0;
  188|      0|        for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (188:34): [True: 0, False: 0]
  ------------------
  189|      0|            const rle16_t rle = src_1->runs[rlepos];
  190|      0|            uint32_t end = rle.value;
  191|      0|            bitset_reset_range(answer->words, start, end);
  192|      0|            start = end + rle.length + 1;
  193|      0|        }
  194|      0|        bitset_reset_range(answer->words, start, UINT32_C(1) << 16);
  195|      0|        answer->cardinality = bitset_container_compute_cardinality(answer);
  196|       |
  197|      0|        if (answer->cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (197:13): [True: 0, False: 0]
  ------------------
  198|      0|            return true;
  199|      0|        } else {
  200|      0|            array_container_t *newanswer = array_container_from_bitset(answer);
  201|      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)
  |  |  ------------------
  ------------------
  202|      0|            if (newanswer == NULL) {
  ------------------
  |  Branch (202:17): [True: 0, False: 0]
  ------------------
  203|      0|                *dst = NULL;
  204|      0|                return false;
  205|      0|            }
  206|      0|            *dst = newanswer;
  207|       |            return false;
  208|      0|        }
  209|      0|    }
  210|      0|}
array_run_container_intersection_cardinality:
  214|  7.31k|                                                 const run_container_t *src_2) {
  215|  7.31k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (215:9): [True: 136, False: 7.17k]
  ------------------
  216|    136|        return src_1->cardinality;
  217|    136|    }
  218|  7.17k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (218:9): [True: 0, False: 7.17k]
  ------------------
  219|      0|        return 0;
  220|      0|    }
  221|  7.17k|    int32_t rlepos = 0;
  222|  7.17k|    int32_t arraypos = 0;
  223|  7.17k|    rle16_t rle = src_2->runs[rlepos];
  224|  7.17k|    int32_t newcard = 0;
  225|   666k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (225:12): [True: 661k, False: 5.47k]
  ------------------
  226|   661k|        const uint16_t arrayval = src_1->array[arraypos];
  227|  1.00M|        while (rle.value + rle.length <
  ------------------
  |  Branch (227:16): [True: 340k, False: 659k]
  ------------------
  228|  1.00M|               arrayval) {  // this will frequently be false
  229|   340k|            ++rlepos;
  230|   340k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (230:17): [True: 1.70k, False: 339k]
  ------------------
  231|  1.70k|                return newcard;  // we are done
  232|  1.70k|            }
  233|   339k|            rle = src_2->runs[rlepos];
  234|   339k|        }
  235|   659k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (235:13): [True: 90.1k, False: 569k]
  ------------------
  236|  90.1k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  237|  90.1k|                                    rle.value);
  238|   569k|        } else {
  239|   569k|            newcard++;
  240|   569k|            arraypos++;
  241|   569k|        }
  242|   659k|    }
  243|  5.47k|    return newcard;
  244|  7.17k|}
run_bitset_container_intersection_cardinality:
  249|  2.36k|    const run_container_t *src_1, const bitset_container_t *src_2) {
  250|  2.36k|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (250:9): [True: 0, False: 2.36k]
  ------------------
  251|      0|        return bitset_container_cardinality(src_2);
  252|      0|    }
  253|  2.36k|    int answer = 0;
  254|   190k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (254:30): [True: 187k, False: 2.36k]
  ------------------
  255|   187k|        rle16_t rle = src_1->runs[rlepos];
  256|   187k|        answer +=
  257|   187k|            bitset_lenrange_cardinality(src_2->words, rle.value, rle.length);
  258|   187k|    }
  259|  2.36k|    return answer;
  260|  2.36k|}
array_run_container_intersect:
  263|  1.82k|                                   const run_container_t *src_2) {
  264|  1.82k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (264:9): [True: 34, False: 1.79k]
  ------------------
  265|     34|        return !array_container_empty(src_1);
  266|     34|    }
  267|  1.79k|    if (src_2->n_runs == 0) {
  ------------------
  |  Branch (267:9): [True: 0, False: 1.79k]
  ------------------
  268|      0|        return false;
  269|      0|    }
  270|  1.79k|    int32_t rlepos = 0;
  271|  1.79k|    int32_t arraypos = 0;
  272|  1.79k|    rle16_t rle = src_2->runs[rlepos];
  273|  3.18k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (273:12): [True: 3.14k, False: 43]
  ------------------
  274|  3.14k|        const uint16_t arrayval = src_1->array[arraypos];
  275|  7.80k|        while (rle.value + rle.length <
  ------------------
  |  Branch (275:16): [True: 4.70k, False: 3.10k]
  ------------------
  276|  7.80k|               arrayval) {  // this will frequently be false
  277|  4.70k|            ++rlepos;
  278|  4.70k|            if (rlepos == src_2->n_runs) {
  ------------------
  |  Branch (278:17): [True: 37, False: 4.66k]
  ------------------
  279|     37|                return false;  // we are done
  280|     37|            }
  281|  4.66k|            rle = src_2->runs[rlepos];
  282|  4.66k|        }
  283|  3.10k|        if (rle.value > arrayval) {
  ------------------
  |  Branch (283:13): [True: 1.39k, False: 1.71k]
  ------------------
  284|  1.39k|            arraypos = advanceUntil(src_1->array, arraypos, src_1->cardinality,
  285|  1.39k|                                    rle.value);
  286|  1.71k|        } else {
  287|  1.71k|            return true;
  288|  1.71k|        }
  289|  3.10k|    }
  290|     43|    return false;
  291|  1.79k|}
run_bitset_container_intersect:
  296|    590|                                    const bitset_container_t *src_2) {
  297|    590|    if (run_container_is_full(src_1)) {
  ------------------
  |  Branch (297:9): [True: 0, False: 590]
  ------------------
  298|      0|        return !bitset_container_empty(src_2);
  299|      0|    }
  300|  3.86k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (300:30): [True: 3.85k, False: 12]
  ------------------
  301|  3.85k|        rle16_t rle = src_1->runs[rlepos];
  302|  3.85k|        if (!bitset_lenrange_empty(src_2->words, rle.value, rle.length))
  ------------------
  |  Branch (302:13): [True: 578, False: 3.27k]
  ------------------
  303|    578|            return true;
  304|  3.85k|    }
  305|     12|    return false;
  306|    590|}
bitset_bitset_container_intersection_inplace:
  358|  1.42k|    container_t **dst) {
  359|  1.42k|    const int newCardinality = bitset_container_and_justcard(src_1, src_2);
  360|  1.42k|    if (newCardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (360:9): [True: 1.42k, False: 0]
  ------------------
  361|  1.42k|        *dst = src_1;
  362|  1.42k|        bitset_container_and_nocard(src_1, src_2, src_1);
  363|  1.42k|        CAST_bitset(*dst)->cardinality = newCardinality;
  ------------------
  |  |   52|  1.42k|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  1.42k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  364|  1.42k|        return true;  // it is a bitset
  365|  1.42k|    }
  366|      0|    *dst = array_container_create_given_capacity(newCardinality);
  367|      0|    if (*dst != NULL) {
  ------------------
  |  Branch (367:9): [True: 0, False: 0]
  ------------------
  368|      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)
  |  |  ------------------
  ------------------
  369|      0|        extract_intersection_to_array(src_1, src_2, CAST_array(*dst)->array,
  ------------------
  |  |   54|      0|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|      0|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  370|      0|                                      newCardinality);
  371|      0|    }
  372|       |    return false;  // not a bitset
  373|  1.42k|}

array_container_negation:
   33|     18|                              bitset_container_t *dst) {
   34|     18|    uint64_t card = UINT64_C(1 << 16);
   35|     18|    bitset_container_set_all(dst);
   36|       |
   37|     18|    if (src->cardinality == 0) {
  ------------------
  |  Branch (37:9): [True: 0, False: 18]
  ------------------
   38|      0|        return;
   39|      0|    }
   40|       |
   41|     18|    dst->cardinality = (int32_t)bitset_clear_list(dst->words, card, src->array,
   42|     18|                                                  (uint64_t)src->cardinality);
   43|     18|}
bitset_container_negation_inplace:
   67|     36|                                       container_t **dst) {
   68|     36|    return bitset_container_negation_range_inplace(src, 0, (1 << 16), dst);
   69|     36|}
run_container_negation_inplace:
   88|  6.39k|int run_container_negation_inplace(run_container_t *src, container_t **dst) {
   89|  6.39k|    return run_container_negation_range_inplace(src, 0, (1 << 16), dst);
   90|  6.39k|}
array_container_negation_range:
  100|  4.32k|                                    container_t **dst) {
  101|       |    /* close port of the Java implementation */
  102|  4.32k|    if (range_start >= range_end) {
  ------------------
  |  Branch (102:9): [True: 0, False: 4.32k]
  ------------------
  103|      0|        *dst = array_container_clone(src);
  104|      0|        return false;
  105|      0|    }
  106|       |
  107|  4.32k|    int32_t start_index =
  108|  4.32k|        binarySearch(src->array, src->cardinality, (uint16_t)range_start);
  109|  4.32k|    if (start_index < 0) start_index = -start_index - 1;
  ------------------
  |  Branch (109:9): [True: 4.05k, False: 275]
  ------------------
  110|       |
  111|  4.32k|    int32_t last_index =
  112|  4.32k|        binarySearch(src->array, src->cardinality, (uint16_t)(range_end - 1));
  113|  4.32k|    if (last_index < 0) last_index = -last_index - 2;
  ------------------
  |  Branch (113:9): [True: 4.06k, False: 257]
  ------------------
  114|       |
  115|  4.32k|    const int32_t current_values_in_range = last_index - start_index + 1;
  116|  4.32k|    const int32_t span_to_be_flipped = range_end - range_start;
  117|  4.32k|    const int32_t new_values_in_range =
  118|  4.32k|        span_to_be_flipped - current_values_in_range;
  119|  4.32k|    const int32_t cardinality_change =
  120|  4.32k|        new_values_in_range - current_values_in_range;
  121|  4.32k|    const int32_t new_cardinality = src->cardinality + cardinality_change;
  122|       |
  123|  4.32k|    if (new_cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (123:9): [True: 42, False: 4.28k]
  ------------------
  124|     42|        bitset_container_t *temp = bitset_container_from_array(src);
  125|     42|        bitset_flip_range(temp->words, (uint32_t)range_start,
  126|     42|                          (uint32_t)range_end);
  127|     42|        temp->cardinality = new_cardinality;
  128|     42|        *dst = temp;
  129|     42|        return true;
  130|     42|    }
  131|       |
  132|  4.28k|    array_container_t *arr =
  133|  4.28k|        array_container_create_given_capacity(new_cardinality);
  134|  4.28k|    *dst = (container_t *)arr;
  135|  4.28k|    if (new_cardinality == 0) {
  ------------------
  |  Branch (135:9): [True: 9, False: 4.27k]
  ------------------
  136|      9|        arr->cardinality = new_cardinality;
  137|      9|        return false;  // we are done.
  138|      9|    }
  139|       |    // copy stuff before the active area
  140|  4.27k|    memcpy(arr->array, src->array, start_index * sizeof(uint16_t));
  141|       |
  142|       |    // work on the range
  143|  4.27k|    int32_t out_pos = start_index, in_pos = start_index;
  144|  4.27k|    int32_t val_in_range = range_start;
  145|  33.2k|    for (; val_in_range < range_end && in_pos <= last_index; ++val_in_range) {
  ------------------
  |  Branch (145:12): [True: 33.0k, False: 244]
  |  Branch (145:40): [True: 28.9k, False: 4.03k]
  ------------------
  146|  28.9k|        if ((uint16_t)val_in_range != src->array[in_pos]) {
  ------------------
  |  Branch (146:13): [True: 18.5k, False: 10.4k]
  ------------------
  147|  18.5k|            arr->array[out_pos++] = (uint16_t)val_in_range;
  148|  18.5k|        } else {
  149|  10.4k|            ++in_pos;
  150|  10.4k|        }
  151|  28.9k|    }
  152|  63.6k|    for (; val_in_range < range_end; ++val_in_range)
  ------------------
  |  Branch (152:12): [True: 59.3k, False: 4.27k]
  ------------------
  153|  59.3k|        arr->array[out_pos++] = (uint16_t)val_in_range;
  154|       |
  155|       |    // content after the active range
  156|  4.27k|    memcpy(arr->array + out_pos, src->array + (last_index + 1),
  157|  4.27k|           (src->cardinality - (last_index + 1)) * sizeof(uint16_t));
  158|  4.27k|    arr->cardinality = new_cardinality;
  159|       |    return false;
  160|  4.28k|}
array_container_negation_range_to_any:
  194|  4.67k|                                          container_t **dst) {
  195|       |    // The result has more than DEFAULT_MAX_SIZE values, so it would be a
  196|       |    // bitset, but it has at most cardinality + 1 runs: when these runs take
  197|       |    // less room than a bitset, we build them directly. In the range, the
  198|       |    // runs are the gaps between the values; outside, the values themselves.
  199|  4.67k|    if (range_end - range_start - src->cardinality > DEFAULT_MAX_SIZE &&
  ------------------
  |  Branch (199:9): [True: 362, False: 4.31k]
  ------------------
  200|    362|        run_container_serialized_size_in_bytes(src->cardinality + 1) <
  ------------------
  |  Branch (200:9): [True: 329, False: 33]
  ------------------
  201|    362|            BITSET_CONTAINER_SIZE_IN_WORDS * (int32_t)sizeof(uint64_t)) {
  202|    329|        run_container_t *ans =
  203|    329|            run_container_create_given_capacity(src->cardinality + 1);
  204|    329|        if (ans == NULL) {
  ------------------
  |  Branch (204:13): [True: 0, False: 329]
  ------------------
  205|      0|            *dst = NULL;
  206|      0|            return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  207|      0|        }
  208|    329|        const uint16_t *array = src->array;
  209|    329|        const int32_t card = src->cardinality;
  210|    329|        rle16_t *runs = ans->runs;
  211|    329|        int32_t n = 0, k = 0;
  212|  10.4k|        for (; k < card && array[k] < range_start; k++) {
  ------------------
  |  Branch (212:16): [True: 10.4k, False: 31]
  |  Branch (212:28): [True: 10.1k, False: 298]
  ------------------
  213|  10.1k|            n = append_run(runs, n, array[k], array[k]);
  214|  10.1k|        }
  215|    329|        uint32_t next = (uint32_t)range_start;  // first value not yet decided
  216|  45.0k|        for (; k < card && array[k] < range_end; k++) {
  ------------------
  |  Branch (216:16): [True: 44.7k, False: 298]
  |  Branch (216:28): [True: 44.7k, False: 31]
  ------------------
  217|  44.7k|            if (array[k] > next) n = append_run(runs, n, next, array[k] - 1u);
  ------------------
  |  Branch (217:17): [True: 8.00k, False: 36.7k]
  ------------------
  218|  44.7k|            next = array[k] + 1u;
  219|  44.7k|        }
  220|    329|        if (next < (uint32_t)range_end) {
  ------------------
  |  Branch (220:13): [True: 304, False: 25]
  ------------------
  221|    304|            n = append_run(runs, n, next, (uint32_t)range_end - 1);
  222|    304|        }
  223|  8.37k|        for (; k < card; k++) {
  ------------------
  |  Branch (223:16): [True: 8.04k, False: 329]
  ------------------
  224|  8.04k|            n = append_run(runs, n, array[k], array[k]);
  225|  8.04k|        }
  226|    329|        ans->n_runs = n;
  227|    329|        *dst = ans;
  228|    329|        return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|    329|#define RUN_CONTAINER_TYPE 3
  ------------------
  229|    329|    }
  230|  4.34k|    if (range_start == 0 && range_end == (1 << 16)) {
  ------------------
  |  Branch (230:9): [True: 4.25k, False: 90]
  |  Branch (230:29): [True: 18, False: 4.23k]
  ------------------
  231|       |        // The negation of a whole array is always a bitset, built in one pass.
  232|     18|        bitset_container_t *ans = bitset_container_create();
  233|     18|        if (ans != NULL) array_container_negation(src, ans);
  ------------------
  |  Branch (233:13): [True: 18, False: 0]
  ------------------
  234|     18|        *dst = ans;
  235|     18|        return BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|     18|#define BITSET_CONTAINER_TYPE 1
  ------------------
  236|     18|    }
  237|  4.32k|    return array_container_negation_range(src, range_start, range_end, dst)
  ------------------
  |  Branch (237:12): [True: 42, False: 4.28k]
  ------------------
  238|  4.32k|               ? BITSET_CONTAINER_TYPE
  ------------------
  |  |   48|     42|#define BITSET_CONTAINER_TYPE 1
  ------------------
  239|  4.32k|               : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  4.28k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  240|  4.34k|}
bitset_container_negation_range_inplace:
  284|  1.26k|                                             container_t **dst) {
  285|  1.26k|    bitset_flip_range(src->words, (uint32_t)range_start, (uint32_t)range_end);
  286|  1.26k|    src->cardinality = bitset_container_compute_cardinality(src);
  287|  1.26k|    if (src->cardinality > DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (287:9): [True: 1.22k, False: 35]
  ------------------
  288|  1.22k|        *dst = src;
  289|  1.22k|        return true;
  290|  1.22k|    }
  291|     35|    *dst = array_container_from_bitset(src);
  292|     35|    bitset_container_free(src);
  293|       |    return false;
  294|  1.26k|}
run_container_negation_range:
  305|    160|                                 container_t **dst) {
  306|    160|    uint8_t return_typecode;
  307|       |
  308|       |    // follows the Java implementation
  309|    160|    if (range_end <= range_start) {
  ------------------
  |  Branch (309:9): [True: 0, False: 160]
  ------------------
  310|      0|        *dst = run_container_clone(src);
  311|      0|        return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  312|      0|    }
  313|       |
  314|    160|    run_container_t *ans = run_container_create_given_capacity(
  315|    160|        src->n_runs + 1);  // src->n_runs + 1);
  316|    160|    int k = 0;
  317|  3.25k|    for (; k < src->n_runs && src->runs[k].value < range_start; ++k) {
  ------------------
  |  Branch (317:12): [True: 3.19k, False: 59]
  |  Branch (317:31): [True: 3.09k, False: 101]
  ------------------
  318|  3.09k|        ans->runs[k] = src->runs[k];
  319|  3.09k|        ans->n_runs++;
  320|  3.09k|    }
  321|       |
  322|    160|    run_container_smart_append_exclusive(
  323|    160|        ans, (uint16_t)range_start, (uint16_t)(range_end - range_start - 1));
  324|       |
  325|  3.06k|    for (; k < src->n_runs; ++k) {
  ------------------
  |  Branch (325:12): [True: 2.90k, False: 160]
  ------------------
  326|  2.90k|        run_container_smart_append_exclusive(ans, src->runs[k].value,
  327|  2.90k|                                             src->runs[k].length);
  328|  2.90k|    }
  329|       |
  330|    160|    *dst = convert_run_to_efficient_container(ans, &return_typecode);
  331|    160|    if (return_typecode != RUN_CONTAINER_TYPE) run_container_free(ans);
  ------------------
  |  |   50|    160|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (331:9): [True: 5, False: 155]
  ------------------
  332|       |
  333|    160|    return return_typecode;
  334|    160|}
run_container_negation_range_inplace:
  346|  8.07k|                                         container_t **dst) {
  347|  8.07k|    uint8_t return_typecode;
  348|       |
  349|  8.07k|    if (range_end <= range_start) {
  ------------------
  |  Branch (349:9): [True: 0, False: 8.07k]
  ------------------
  350|      0|        *dst = src;
  351|      0|        return RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  352|      0|    }
  353|       |
  354|       |    // TODO: efficient special case when range is 0 to 65535 inclusive
  355|       |
  356|  8.07k|    if (src->capacity == src->n_runs) {
  ------------------
  |  Branch (356:9): [True: 6.87k, False: 1.19k]
  ------------------
  357|       |        // no excess room.  More checking to see if result can fit
  358|  6.87k|        bool last_val_before_range = false;
  359|  6.87k|        bool first_val_in_range = false;
  360|  6.87k|        bool last_val_in_range = false;
  361|  6.87k|        bool first_val_past_range = false;
  362|       |
  363|  6.87k|        if (range_start > 0)
  ------------------
  |  Branch (363:13): [True: 159, False: 6.72k]
  ------------------
  364|    159|            last_val_before_range =
  365|    159|                run_container_contains(src, (uint16_t)(range_start - 1));
  366|  6.87k|        first_val_in_range = run_container_contains(src, (uint16_t)range_start);
  367|       |
  368|  6.87k|        if (last_val_before_range == first_val_in_range) {
  ------------------
  |  Branch (368:13): [True: 445, False: 6.43k]
  ------------------
  369|    445|            last_val_in_range =
  370|    445|                run_container_contains(src, (uint16_t)(range_end - 1));
  371|    445|            if (range_end != 0x10000)
  ------------------
  |  Branch (371:17): [True: 288, False: 157]
  ------------------
  372|    288|                first_val_past_range =
  373|    288|                    run_container_contains(src, (uint16_t)range_end);
  374|       |
  375|    445|            if (last_val_in_range ==
  ------------------
  |  Branch (375:17): [True: 160, False: 285]
  ------------------
  376|    445|                first_val_past_range) {  // no space for inplace
  377|    160|                int ans = run_container_negation_range(src, range_start,
  378|    160|                                                       range_end, dst);
  379|    160|                run_container_free(src);
  380|    160|                return ans;
  381|    160|            }
  382|    445|        }
  383|  6.87k|    }
  384|       |    // all other cases: result will fit
  385|       |
  386|  7.91k|    run_container_t *ans = src;
  387|  7.91k|    int my_nbr_runs = src->n_runs;
  388|       |
  389|  7.91k|    ans->n_runs = 0;
  390|  7.91k|    int k = 0;
  391|  11.3k|    for (; (k < my_nbr_runs) && (src->runs[k].value < range_start); ++k) {
  ------------------
  |  Branch (391:12): [True: 11.3k, False: 66]
  |  Branch (391:33): [True: 3.47k, False: 7.84k]
  ------------------
  392|       |        // ans->runs[k] = src->runs[k]; (would be self-copy)
  393|  3.47k|        ans->n_runs++;
  394|  3.47k|    }
  395|       |
  396|       |    // as with Java implementation, use locals to give self a buffer of depth 1
  397|  7.91k|    rle16_t buffered = CROARING_MAKE_RLE16(0, 0);
  ------------------
  |  |   60|  7.91k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  398|  7.91k|    rle16_t next = buffered;
  399|  7.91k|    if (k < my_nbr_runs) buffered = src->runs[k];
  ------------------
  |  Branch (399:9): [True: 7.84k, False: 66]
  ------------------
  400|       |
  401|  7.91k|    run_container_smart_append_exclusive(
  402|  7.91k|        ans, (uint16_t)range_start, (uint16_t)(range_end - range_start - 1));
  403|       |
  404|  96.9k|    for (; k < my_nbr_runs; ++k) {
  ------------------
  |  Branch (404:12): [True: 89.0k, False: 7.91k]
  ------------------
  405|  89.0k|        if (k + 1 < my_nbr_runs) next = src->runs[k + 1];
  ------------------
  |  Branch (405:13): [True: 81.1k, False: 7.84k]
  ------------------
  406|       |
  407|  89.0k|        run_container_smart_append_exclusive(ans, buffered.value,
  408|  89.0k|                                             buffered.length);
  409|  89.0k|        buffered = next;
  410|  89.0k|    }
  411|       |
  412|  7.91k|    *dst = convert_run_to_efficient_container(ans, &return_typecode);
  413|  7.91k|    if (return_typecode != RUN_CONTAINER_TYPE) run_container_free(ans);
  ------------------
  |  |   50|  7.91k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (413:9): [True: 6.23k, False: 1.67k]
  ------------------
  414|       |
  415|  7.91k|    return return_typecode;
  416|  8.07k|}
mixed_negation.c:append_run:
  179|  26.4k|                                 uint32_t end) {
  180|  26.4k|    if (n > 0 &&
  ------------------
  |  Branch (180:9): [True: 26.1k, False: 329]
  ------------------
  181|  26.1k|        (uint32_t)runs[n - 1].value + runs[n - 1].length + 1 == start) {
  ------------------
  |  Branch (181:9): [True: 13.0k, False: 13.1k]
  ------------------
  182|  13.0k|        runs[n - 1].length = (uint16_t)(end - runs[n - 1].value);
  183|  13.0k|        return n;
  184|  13.0k|    }
  185|  13.4k|    runs[n].value = (uint16_t)start;
  186|  13.4k|    runs[n].length = (uint16_t)(end - start);
  187|  13.4k|    return n + 1;
  188|  26.4k|}

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

array_bitset_container_union:
   24|  1.18k|                                  bitset_container_t *dst) {
   25|  1.18k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (25:9): [True: 1.18k, False: 0]
  ------------------
   26|  1.18k|    dst->cardinality = (int32_t)bitset_set_list_withcard(
   27|  1.18k|        dst->words, dst->cardinality, src_1->array, src_1->cardinality);
   28|  1.18k|}
run_bitset_container_union:
   43|  1.18k|                                bitset_container_t *dst) {
   44|  1.18k|    assert(!run_container_is_full(src_1));  // catch this case upstream
   45|  1.18k|    if (src_2 != dst) bitset_container_copy(src_2, dst);
  ------------------
  |  Branch (45:9): [True: 1.18k, False: 0]
  ------------------
   46|  95.1k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (46:30): [True: 93.9k, False: 1.18k]
  ------------------
   47|  93.9k|        rle16_t rle = src_1->runs[rlepos];
   48|  93.9k|        bitset_set_lenrange(dst->words, rle.value, rle.length);
   49|  93.9k|    }
   50|  1.18k|    dst->cardinality = bitset_container_compute_cardinality(dst);
   51|  1.18k|}
array_run_container_union:
   68|  2.42k|                               run_container_t *dst) {
   69|  2.42k|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (69:9): [True: 105, False: 2.32k]
  ------------------
   70|    105|        run_container_copy(src_2, dst);
   71|    105|        return;
   72|    105|    }
   73|       |    // TODO: see whether the "2*" is spurious
   74|  2.32k|    run_container_grow(dst, 2 * (src_1->cardinality + src_2->n_runs), false);
   75|  2.32k|    int32_t rlepos = 0;
   76|  2.32k|    int32_t arraypos = 0;
   77|  2.32k|    rle16_t previousrle;
   78|  2.32k|    if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (78:9): [True: 1.76k, False: 557]
  ------------------
   79|  1.76k|        previousrle = run_container_append_first(dst, src_2->runs[rlepos]);
   80|  1.76k|        rlepos++;
   81|  1.76k|    } else {
   82|    557|        previousrle =
   83|    557|            run_container_append_value_first(dst, src_1->array[arraypos]);
   84|    557|        arraypos++;
   85|    557|    }
   86|   403k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (86:12): [True: 402k, False: 1.50k]
  |  Branch (86:40): [True: 401k, False: 819]
  ------------------
   87|   401k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (87:13): [True: 132k, False: 269k]
  ------------------
   88|   132k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
   89|   132k|            rlepos++;
   90|   269k|        } else {
   91|   269k|            run_container_append_value(dst, src_1->array[arraypos],
   92|   269k|                                       &previousrle);
   93|   269k|            arraypos++;
   94|   269k|        }
   95|   401k|    }
   96|  2.32k|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (96:9): [True: 1.50k, False: 819]
  ------------------
   97|   165k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (97:16): [True: 163k, False: 1.50k]
  ------------------
   98|   163k|            run_container_append_value(dst, src_1->array[arraypos],
   99|   163k|                                       &previousrle);
  100|   163k|            arraypos++;
  101|   163k|        }
  102|  1.50k|    } else {
  103|  5.73k|        while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (103:16): [True: 4.91k, False: 819]
  ------------------
  104|  4.91k|            run_container_append(dst, src_2->runs[rlepos], &previousrle);
  105|  4.91k|            rlepos++;
  106|  4.91k|        }
  107|    819|    }
  108|  2.32k|}
array_run_container_inplace_union:
  111|    251|                                       run_container_t *src_2) {
  112|    251|    if (run_container_is_full(src_2)) {
  ------------------
  |  Branch (112:9): [True: 0, False: 251]
  ------------------
  113|      0|        return;
  114|      0|    }
  115|    251|    const int32_t maxoutput = src_1->cardinality + src_2->n_runs;
  116|    251|    const int32_t neededcapacity = maxoutput + src_2->n_runs;
  117|    251|    if (src_2->capacity < neededcapacity)
  ------------------
  |  Branch (117:9): [True: 251, False: 0]
  ------------------
  118|    251|        run_container_grow(src_2, neededcapacity, true);
  119|    251|    memmove(src_2->runs + maxoutput, src_2->runs,
  120|    251|            src_2->n_runs * sizeof(rle16_t));
  121|    251|    rle16_t *inputsrc2 = src_2->runs + maxoutput;
  122|    251|    int32_t rlepos = 0;
  123|    251|    int32_t arraypos = 0;
  124|    251|    int src2nruns = src_2->n_runs;
  125|    251|    src_2->n_runs = 0;
  126|       |
  127|    251|    rle16_t previousrle;
  128|       |
  129|    251|    if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (129:9): [True: 221, False: 30]
  ------------------
  130|    221|        previousrle = run_container_append_first(src_2, inputsrc2[rlepos]);
  131|    221|        rlepos++;
  132|    221|    } else {
  133|     30|        previousrle =
  134|     30|            run_container_append_value_first(src_2, src_1->array[arraypos]);
  135|     30|        arraypos++;
  136|     30|    }
  137|       |
  138|  52.8k|    while ((rlepos < src2nruns) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (138:12): [True: 52.5k, False: 251]
  |  Branch (138:36): [True: 52.5k, False: 0]
  ------------------
  139|  52.5k|        if (inputsrc2[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (139:13): [True: 13.7k, False: 38.8k]
  ------------------
  140|  13.7k|            run_container_append(src_2, inputsrc2[rlepos], &previousrle);
  141|  13.7k|            rlepos++;
  142|  38.8k|        } else {
  143|  38.8k|            run_container_append_value(src_2, src_1->array[arraypos],
  144|  38.8k|                                       &previousrle);
  145|  38.8k|            arraypos++;
  146|  38.8k|        }
  147|  52.5k|    }
  148|    251|    if (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (148:9): [True: 251, False: 0]
  ------------------
  149|  2.17k|        while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (149:16): [True: 1.92k, False: 251]
  ------------------
  150|  1.92k|            run_container_append_value(src_2, src_1->array[arraypos],
  151|  1.92k|                                       &previousrle);
  152|  1.92k|            arraypos++;
  153|  1.92k|        }
  154|    251|    } 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|    251|}
array_array_container_union:
  164|  3.40k|                                 container_t **dst) {
  165|  3.40k|    int totalCardinality = src_1->cardinality + src_2->cardinality;
  166|  3.40k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (166:9): [True: 3.28k, False: 120]
  ------------------
  167|  3.28k|        *dst = array_container_create_given_capacity(totalCardinality);
  168|  3.28k|        if (*dst != NULL) {
  ------------------
  |  Branch (168:13): [True: 3.28k, False: 0]
  ------------------
  169|  3.28k|            array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  3.28k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.28k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  170|  3.28k|        } else {
  171|      0|            return true;  // otherwise failure won't be caught
  172|      0|        }
  173|  3.28k|        return false;  // not a bitset
  174|  3.28k|    }
  175|    120|    *dst = bitset_container_create();
  176|    120|    bool returnval = true;  // expect a bitset
  177|    120|    if (*dst != NULL) {
  ------------------
  |  Branch (177:9): [True: 120, False: 0]
  ------------------
  178|    120|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    120|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    120|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  179|    120|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  180|    120|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  181|    120|            ourbitset->words, src_1->cardinality, src_2->array,
  182|    120|            src_2->cardinality);
  183|    120|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (183:13): [True: 76, False: 44]
  ------------------
  184|       |            // need to convert!
  185|     76|            *dst = array_container_from_bitset(ourbitset);
  186|     76|            bitset_container_free(ourbitset);
  187|       |            returnval = false;  // not going to be a bitset
  188|     76|        }
  189|    120|    }
  190|    120|    return returnval;
  191|  3.40k|}
array_array_container_inplace_union:
  195|  3.56k|                                         container_t **dst) {
  196|  3.56k|    int totalCardinality = src_1->cardinality + src_2->cardinality;
  197|  3.56k|    *dst = NULL;
  198|  3.56k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (198:9): [True: 3.47k, False: 88]
  ------------------
  199|  3.47k|        if (src_1->capacity < totalCardinality) {
  ------------------
  |  Branch (199:13): [True: 3.47k, False: 0]
  ------------------
  200|  3.47k|            *dst = array_container_create_given_capacity(
  201|  3.47k|                2 * totalCardinality);  // be purposefully generous
  202|  3.47k|            if (*dst != NULL) {
  ------------------
  |  Branch (202:17): [True: 3.47k, False: 0]
  ------------------
  203|  3.47k|                array_container_union(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  3.47k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  3.47k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  3.47k|            } else {
  205|      0|                return true;  // otherwise failure won't be caught
  206|      0|            }
  207|  3.47k|            return false;  // not a bitset
  208|  3.47k|        } else {
  209|       |            // fast_union_uint16 cannot work in place: its vectorized stores
  210|       |            // could overwrite values not yet read.
  211|       |            // https://github.com/RoaringBitmap/CRoaring/pull/452
  212|       |            // See report https://github.com/RoaringBitmap/CRoaring/issues/476
  213|       |            // So we copy src_1 aside first, which costs about as much as
  214|       |            // moving it to the end of its array for the scalar union.
  215|      0|            CROARING_INDETERMINATE uint16_t buffer[DEFAULT_MAX_SIZE];
  ------------------
  |  |  285|      0|#define CROARING_INDETERMINATE __attribute__((uninitialized))
  ------------------
  216|      0|            memcpy(buffer, src_1->array, src_1->cardinality * sizeof(uint16_t));
  217|      0|            src_1->cardinality = (int32_t)fast_union_uint16(
  218|      0|                buffer, src_1->cardinality, src_2->array, src_2->cardinality,
  219|      0|                src_1->array);
  220|      0|            return false;  // not a bitset
  221|      0|        }
  222|  3.47k|    }
  223|     88|    *dst = bitset_container_create();
  224|     88|    bool returnval = true;  // expect a bitset
  225|     88|    if (*dst != NULL) {
  ------------------
  |  Branch (225:9): [True: 88, False: 0]
  ------------------
  226|     88|        bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|     88|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|     88|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  227|     88|        bitset_set_list(ourbitset->words, src_1->array, src_1->cardinality);
  228|     88|        ourbitset->cardinality = (int32_t)bitset_set_list_withcard(
  229|     88|            ourbitset->words, src_1->cardinality, src_2->array,
  230|     88|            src_2->cardinality);
  231|     88|        if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (231:13): [True: 88, False: 0]
  ------------------
  232|       |            // need to convert!
  233|     88|            if (src_1->capacity < ourbitset->cardinality) {
  ------------------
  |  Branch (233:17): [True: 88, False: 0]
  ------------------
  234|     88|                array_container_grow(src_1, ourbitset->cardinality, false);
  235|     88|            }
  236|       |
  237|     88|            bitset_extract_setbits_uint16(ourbitset->words,
  238|     88|                                          BITSET_CONTAINER_SIZE_IN_WORDS,
  239|     88|                                          src_1->array, 0);
  240|     88|            src_1->cardinality = ourbitset->cardinality;
  241|     88|            *dst = src_1;
  242|     88|            bitset_container_free(ourbitset);
  243|       |            returnval = false;  // not going to be a bitset
  244|     88|        }
  245|     88|    }
  246|     88|    return returnval;
  247|  3.56k|}

array_bitset_container_xor:
   25|    704|                                container_t **dst) {
   26|    704|    bitset_container_t *result = bitset_container_create();
   27|    704|    bitset_container_copy(src_2, result);
   28|    704|    result->cardinality = (int32_t)bitset_flip_list_withcard(
   29|    704|        result->words, result->cardinality, src_1->array, src_1->cardinality);
   30|       |
   31|       |    // do required type conversions.
   32|    704|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (32:9): [True: 180, False: 524]
  ------------------
   33|    180|        *dst = array_container_from_bitset(result);
   34|    180|        bitset_container_free(result);
   35|    180|        return false;  // not bitset
   36|    180|    }
   37|    524|    *dst = result;
   38|       |    return true;  // bitset
   39|    704|}
run_bitset_container_xor:
   63|    674|                              container_t **dst) {
   64|    674|    bitset_container_t *result = bitset_container_create();
   65|       |
   66|    674|    bitset_container_copy(src_2, result);
   67|  50.3k|    for (int32_t rlepos = 0; rlepos < src_1->n_runs; ++rlepos) {
  ------------------
  |  Branch (67:30): [True: 49.6k, False: 674]
  ------------------
   68|  49.6k|        rle16_t rle = src_1->runs[rlepos];
   69|  49.6k|        bitset_flip_range(result->words, rle.value,
   70|  49.6k|                          rle.value + rle.length + UINT32_C(1));
   71|  49.6k|    }
   72|    674|    result->cardinality = bitset_container_compute_cardinality(result);
   73|       |
   74|    674|    if (result->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (74:9): [True: 129, False: 545]
  ------------------
   75|    129|        *dst = array_container_from_bitset(result);
   76|    129|        bitset_container_free(result);
   77|    129|        return false;  // not bitset
   78|    129|    }
   79|    545|    *dst = result;
   80|       |    return true;  // bitset
   81|    674|}
array_run_container_xor:
  105|  2.13k|                            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.13k|    const int arbitrary_threshold = 32;
  113|  2.13k|    if (src_1->cardinality < arbitrary_threshold) {
  ------------------
  |  Branch (113:9): [True: 856, False: 1.27k]
  ------------------
  114|    856|        run_container_t *ans = run_container_create();
  115|    856|        array_run_container_lazy_xor(src_1, src_2, ans);  // keeps runs.
  116|    856|        uint8_t typecode_after;
  117|    856|        *dst =
  118|    856|            convert_run_to_efficient_container_and_free(ans, &typecode_after);
  119|    856|        return typecode_after;
  120|    856|    }
  121|       |
  122|  1.27k|    int card = run_container_cardinality(src_2);
  123|  1.27k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (123:9): [True: 1.05k, False: 218]
  ------------------
  124|       |        // Java implementation works with the array, xoring the run elements via
  125|       |        // iterator
  126|  1.05k|        array_container_t *temp = array_container_from_run(src_2);
  127|  1.05k|        bool ret_is_bitset = array_array_container_xor(temp, src_1, dst);
  128|  1.05k|        array_container_free(temp);
  129|  1.05k|        return ret_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   48|      4|#define BITSET_CONTAINER_TYPE 1
  ------------------
                      return ret_is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  1.05k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (129:16): [True: 4, False: 1.05k]
  ------------------
  130|       |
  131|  1.05k|    } else {  // guess that it will end up as a bitset
  132|    218|        bitset_container_t *result = bitset_container_from_run(src_2);
  133|    218|        bool is_bitset = bitset_array_container_ixor(result, src_1, dst);
  134|       |        // any necessary type conversion has been done by the ixor
  135|    218|        int retval = (is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   48|    207|#define BITSET_CONTAINER_TYPE 1
  ------------------
                      int retval = (is_bitset ? BITSET_CONTAINER_TYPE : ARRAY_CONTAINER_TYPE);
  ------------------
  |  |   49|     11|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  |  Branch (135:23): [True: 207, False: 11]
  ------------------
  136|    218|        return retval;
  137|    218|    }
  138|  1.27k|}
array_run_container_lazy_xor:
  147|    856|                                  run_container_t *dst) {
  148|    856|    run_container_grow(dst, src_1->cardinality + src_2->n_runs, false);
  149|    856|    int32_t rlepos = 0;
  150|    856|    int32_t arraypos = 0;
  151|    856|    dst->n_runs = 0;
  152|       |
  153|  26.0k|    while ((rlepos < src_2->n_runs) && (arraypos < src_1->cardinality)) {
  ------------------
  |  Branch (153:12): [True: 25.5k, False: 505]
  |  Branch (153:40): [True: 25.1k, False: 351]
  ------------------
  154|  25.1k|        if (src_2->runs[rlepos].value <= src_1->array[arraypos]) {
  ------------------
  |  Branch (154:13): [True: 15.0k, False: 10.1k]
  ------------------
  155|  15.0k|            run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  156|  15.0k|                                                 src_2->runs[rlepos].length);
  157|  15.0k|            rlepos++;
  158|  15.0k|        } else {
  159|  10.1k|            run_container_smart_append_exclusive(dst, src_1->array[arraypos],
  160|  10.1k|                                                 0);
  161|  10.1k|            arraypos++;
  162|  10.1k|        }
  163|  25.1k|    }
  164|  2.94k|    while (arraypos < src_1->cardinality) {
  ------------------
  |  Branch (164:12): [True: 2.08k, False: 856]
  ------------------
  165|  2.08k|        run_container_smart_append_exclusive(dst, src_1->array[arraypos], 0);
  166|  2.08k|        arraypos++;
  167|  2.08k|    }
  168|  7.43k|    while (rlepos < src_2->n_runs) {
  ------------------
  |  Branch (168:12): [True: 6.58k, False: 856]
  ------------------
  169|  6.58k|        run_container_smart_append_exclusive(dst, src_2->runs[rlepos].value,
  170|  6.58k|                                             src_2->runs[rlepos].length);
  171|  6.58k|        rlepos++;
  172|  6.58k|    }
  173|    856|}
run_run_container_xor:
  180|  53.7k|                          const run_container_t *src_2, container_t **dst) {
  181|  53.7k|    run_container_t *ans = run_container_create();
  182|  53.7k|    run_container_xor(src_1, src_2, ans);
  183|  53.7k|    uint8_t typecode_after;
  184|  53.7k|    *dst = convert_run_to_efficient_container_and_free(ans, &typecode_after);
  185|  53.7k|    return typecode_after;
  186|  53.7k|}
array_array_container_xor:
  198|  9.87k|                               container_t **dst) {
  199|  9.87k|    int totalCardinality =
  200|  9.87k|        src_1->cardinality + src_2->cardinality;  // upper bound
  201|  9.87k|    if (totalCardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (201:9): [True: 9.30k, False: 562]
  ------------------
  202|  9.30k|        *dst = array_container_create_given_capacity(totalCardinality);
  203|  9.30k|        array_container_xor(src_1, src_2, CAST_array(*dst));
  ------------------
  |  |   54|  9.30k|#define CAST_array(c) CAST(array_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  9.30k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  204|  9.30k|        return false;  // not a bitset
  205|  9.30k|    }
  206|    562|    *dst = bitset_container_from_array(src_1);
  207|    562|    bool returnval = true;  // expect a bitset
  208|    562|    bitset_container_t *ourbitset = CAST_bitset(*dst);
  ------------------
  |  |   52|    562|#define CAST_bitset(c) CAST(bitset_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|    562|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
  209|    562|    ourbitset->cardinality = (uint32_t)bitset_flip_list_withcard(
  210|    562|        ourbitset->words, src_1->cardinality, src_2->array, src_2->cardinality);
  211|    562|    if (ourbitset->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (211:9): [True: 541, False: 21]
  ------------------
  212|       |        // need to convert!
  213|    541|        *dst = array_container_from_bitset(ourbitset);
  214|    541|        bitset_container_free(ourbitset);
  215|    541|        returnval = false;  // not going to be a bitset
  216|    541|    }
  217|       |
  218|    562|    return returnval;
  219|  9.87k|}
bitset_array_container_ixor:
  284|    218|                                 container_t **dst) {
  285|    218|    *dst = src_1;
  286|    218|    src_1->cardinality = (uint32_t)bitset_flip_list_withcard(
  287|    218|        src_1->words, src_1->cardinality, src_2->array, src_2->cardinality);
  288|       |
  289|    218|    if (src_1->cardinality <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (289:9): [True: 11, False: 207]
  ------------------
  290|     11|        *dst = array_container_from_bitset(src_1);
  291|     11|        bitset_container_free(src_1);
  292|     11|        return false;  // not bitset
  293|     11|    } else
  294|    207|        return true;
  295|    218|}
bitset_bitset_container_ixor:
  304|  1.41k|                                  container_t **dst) {
  305|  1.41k|    int card = bitset_container_xor(src_1, src_2, src_1);
  306|  1.41k|    if (card <= DEFAULT_MAX_SIZE) {
  ------------------
  |  Branch (306:9): [True: 1.41k, False: 0]
  ------------------
  307|  1.41k|        *dst = array_container_from_bitset(src_1);
  308|  1.41k|        bitset_container_free(src_1);
  309|  1.41k|        return false;  // not bitset
  310|  1.41k|    } else {
  311|      0|        *dst = src_1;
  312|       |        return true;
  313|      0|    }
  314|  1.41k|}
array_bitset_container_ixor:
  318|    132|                                 container_t **dst) {
  319|       |    bool ans = array_bitset_container_xor(src_1, src_2, dst);
  320|    132|    array_container_free(src_1);
  321|    132|    return ans;
  322|    132|}
run_bitset_container_ixor:
  333|     16|                               container_t **dst) {
  334|       |    bool ans = run_bitset_container_xor(src_1, src_2, dst);
  335|     16|    run_container_free(src_1);
  336|     16|    return ans;
  337|     16|}
bitset_run_container_ixor:
  341|     68|                               container_t **dst) {
  342|       |    bool ans = run_bitset_container_xor(src_2, src_1, dst);
  343|     68|    bitset_container_free(src_1);
  344|     68|    return ans;
  345|     68|}
array_run_container_ixor:
  352|    257|                             const run_container_t *src_2, container_t **dst) {
  353|    257|    int ans = array_run_container_xor(src_1, src_2, dst);
  354|    257|    array_container_free(src_1);
  355|    257|    return ans;
  356|    257|}
run_array_container_ixor:
  360|     47|                             container_t **dst) {
  361|     47|    int ans = array_run_container_xor(src_2, src_1, dst);
  362|     47|    run_container_free(src_1);
  363|     47|    return ans;
  364|     47|}
array_array_container_ixor:
  368|  5.41k|                                container_t **dst) {
  369|       |    bool ans = array_array_container_xor(src_1, src_2, dst);
  370|  5.41k|    array_container_free(src_1);
  371|  5.41k|    return ans;
  372|  5.41k|}
run_run_container_ixor:
  375|  53.1k|                           container_t **dst) {
  376|  53.1k|    int ans = run_run_container_xor(src_1, src_2, dst);
  377|  53.1k|    run_container_free(src_1);
  378|  53.1k|    return ans;
  379|  53.1k|}

run_container_add:
   39|   371k|bool run_container_add(run_container_t *run, uint16_t pos) {
   40|   371k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
   41|   371k|    if (index >= 0) return false;  // already there
  ------------------
  |  Branch (41:9): [True: 177k, False: 194k]
  ------------------
   42|   194k|    index = -index - 2;            // points to preceding value, possibly -1
   43|   194k|    if (index >= 0) {              // possible match
  ------------------
  |  Branch (43:9): [True: 193k, False: 368]
  ------------------
   44|   193k|        int32_t offset = pos - run->runs[index].value;
   45|   193k|        int32_t le = run->runs[index].length;
   46|   193k|        if (offset <= le) return false;  // already there
  ------------------
  |  Branch (46:13): [True: 114k, False: 79.6k]
  ------------------
   47|  79.6k|        if (offset == le + 1) {
  ------------------
  |  Branch (47:13): [True: 13.0k, False: 66.6k]
  ------------------
   48|       |            // we may need to fuse
   49|  13.0k|            if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (49:17): [True: 12.6k, False: 337]
  ------------------
   50|  12.6k|                if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (50:21): [True: 5.84k, False: 6.83k]
  ------------------
   51|       |                    // indeed fusion is needed
   52|  5.84k|                    run->runs[index].length = run->runs[index + 1].value +
   53|  5.84k|                                              run->runs[index + 1].length -
   54|  5.84k|                                              run->runs[index].value;
   55|  5.84k|                    recoverRoomAtIndex(run, (uint16_t)(index + 1));
   56|  5.84k|                    return true;
   57|  5.84k|                }
   58|  12.6k|            }
   59|  7.17k|            run->runs[index].length++;
   60|  7.17k|            return true;
   61|  13.0k|        }
   62|  66.6k|        if (index + 1 < run->n_runs) {
  ------------------
  |  Branch (62:13): [True: 64.9k, False: 1.65k]
  ------------------
   63|       |            // we may need to fuse
   64|  64.9k|            if (run->runs[index + 1].value == pos + 1) {
  ------------------
  |  Branch (64:17): [True: 28.1k, False: 36.8k]
  ------------------
   65|       |                // indeed fusion is needed
   66|  28.1k|                run->runs[index + 1].value = pos;
   67|  28.1k|                run->runs[index + 1].length = run->runs[index + 1].length + 1;
   68|  28.1k|                return true;
   69|  28.1k|            }
   70|  64.9k|        }
   71|  66.6k|    }
   72|  38.8k|    if (index == -1) {
  ------------------
  |  Branch (72:9): [True: 368, False: 38.5k]
  ------------------
   73|       |        // we may need to extend the first run
   74|    368|        if (0 < run->n_runs) {
  ------------------
  |  Branch (74:13): [True: 368, False: 0]
  ------------------
   75|    368|            if (run->runs[0].value == pos + 1) {
  ------------------
  |  Branch (75:17): [True: 246, False: 122]
  ------------------
   76|    246|                run->runs[0].length++;
   77|    246|                run->runs[0].value--;
   78|    246|                return true;
   79|    246|            }
   80|    368|        }
   81|    368|    }
   82|  38.6k|    makeRoomAtIndex(run, (uint16_t)(index + 1));
   83|  38.6k|    run->runs[index + 1].value = pos;
   84|  38.6k|    run->runs[index + 1].length = 0;
   85|       |    return true;
   86|  38.8k|}
run_container_create_given_capacity:
   89|   361k|run_container_t *run_container_create_given_capacity(int32_t size) {
   90|   361k|    run_container_t *run;
   91|       |    /* Allocate the run container itself. */
   92|   361k|    if ((run = (run_container_t *)roaring_malloc(sizeof(run_container_t))) ==
  ------------------
  |  Branch (92:9): [True: 0, False: 361k]
  ------------------
   93|   361k|        NULL) {
   94|      0|        return NULL;
   95|      0|    }
   96|   361k|    if (size <= 0) {  // we don't want to rely on malloc(0)
  ------------------
  |  Branch (96:9): [True: 113k, False: 247k]
  ------------------
   97|   113k|        run->runs = NULL;
   98|   247k|    } else if ((run->runs = (rle16_t *)roaring_malloc(sizeof(rle16_t) *
  ------------------
  |  Branch (98:16): [True: 0, False: 247k]
  ------------------
   99|   247k|                                                      size)) == NULL) {
  100|      0|        roaring_free(run);
  101|      0|        return NULL;
  102|      0|    }
  103|   361k|    run->capacity = size;
  104|   361k|    run->n_runs = 0;
  105|   361k|    return run;
  106|   361k|}
run_container_shrink_to_fit:
  108|  2.34k|int run_container_shrink_to_fit(run_container_t *src) {
  109|  2.34k|    int32_t n_runs = src->n_runs;
  110|  2.34k|    int32_t capacity = src->capacity;
  111|  2.34k|    if (n_runs == capacity) return 0;  // nothing to do
  ------------------
  |  Branch (111:9): [True: 2.34k, False: 0]
  ------------------
  112|  2.34k|    bool shrunk;
  113|      0|    src->runs = (rle16_t *)croaring_realloc_shrink(
  114|      0|        src->runs, n_runs * sizeof(rle16_t), &shrunk);
  115|      0|    if (!shrunk) return 0;
  ------------------
  |  Branch (115:9): [True: 0, False: 0]
  ------------------
  116|      0|    src->capacity = n_runs;
  117|      0|    return (capacity - n_runs) * (int)sizeof(rle16_t);
  118|      0|}
run_container_create:
  120|   113k|run_container_t *run_container_create(void) {
  121|   113k|    return run_container_create_given_capacity(RUN_DEFAULT_INIT_SIZE);
  122|   113k|}
run_container_clone:
  125|   158k|run_container_t *run_container_clone(const run_container_t *src) {
  126|   158k|    run_container_t *run = run_container_create_given_capacity(src->capacity);
  127|   158k|    if (run == NULL) return NULL;
  ------------------
  |  Branch (127:9): [True: 0, False: 158k]
  ------------------
  128|   158k|    run->capacity = src->capacity;
  129|   158k|    run->n_runs = src->n_runs;
  130|   158k|    memcpy(run->runs, src->runs, src->n_runs * sizeof(rle16_t));
  131|   158k|    return run;
  132|   158k|}
run_container_free:
  194|   361k|void run_container_free(run_container_t *run) {
  195|   361k|    if (run == NULL) return;
  ------------------
  |  Branch (195:9): [True: 0, False: 361k]
  ------------------
  196|   361k|    roaring_free(run->runs);
  197|   361k|    roaring_free(run);
  198|   361k|}
run_container_grow:
  200|   118k|void run_container_grow(run_container_t *run, int32_t min, bool copy) {
  201|   118k|    int32_t newCapacity = (run->capacity == 0)   ? RUN_DEFAULT_INIT_SIZE
  ------------------
  |  Branch (201:27): [True: 113k, False: 4.63k]
  ------------------
  202|   118k|                          : run->capacity < 64   ? run->capacity * 2
  ------------------
  |  Branch (202:29): [True: 3.25k, False: 1.38k]
  ------------------
  203|  4.63k|                          : run->capacity < 1024 ? run->capacity * 3 / 2
  ------------------
  |  Branch (203:29): [True: 1.38k, False: 0]
  ------------------
  204|  1.38k|                                                 : run->capacity * 5 / 4;
  205|   118k|    if (newCapacity < min) newCapacity = min;
  ------------------
  |  Branch (205:9): [True: 115k, False: 2.89k]
  ------------------
  206|   118k|    run->capacity = newCapacity;
  207|   118k|    assert(run->capacity >= min);
  208|   118k|    if (copy) {
  ------------------
  |  Branch (208:9): [True: 4.63k, False: 113k]
  ------------------
  209|  4.63k|        rle16_t *oldruns = run->runs;
  210|  4.63k|        run->runs = (rle16_t *)roaring_realloc(oldruns,
  211|  4.63k|                                               run->capacity * sizeof(rle16_t));
  212|  4.63k|        if (run->runs == NULL) roaring_free(oldruns);
  ------------------
  |  Branch (212:13): [True: 0, False: 4.63k]
  ------------------
  213|   113k|    } else {
  214|   113k|        roaring_free(run->runs);
  215|   113k|        run->runs = (rle16_t *)roaring_malloc(run->capacity * sizeof(rle16_t));
  216|   113k|    }
  217|       |    // We may have run->runs == NULL.
  218|   118k|}
run_container_copy:
  221|  51.5k|void run_container_copy(const run_container_t *src, run_container_t *dst) {
  222|  51.5k|    const int32_t n_runs = src->n_runs;
  223|  51.5k|    if (src->n_runs > dst->capacity) {
  ------------------
  |  Branch (223:9): [True: 51.5k, False: 15]
  ------------------
  224|       |        run_container_grow(dst, n_runs, false);
  225|  51.5k|    }
  226|  51.5k|    dst->n_runs = n_runs;
  227|  51.5k|    memcpy(dst->runs, src->runs, sizeof(rle16_t) * n_runs);
  228|  51.5k|}
run_container_union:
  234|    624|                         const run_container_t *src_2, run_container_t *dst) {
  235|       |    // TODO: this could be a lot more efficient
  236|       |
  237|       |    // we start out with inexpensive checks
  238|    624|    const bool if1 = run_container_is_full(src_1);
  239|    624|    const bool if2 = run_container_is_full(src_2);
  240|    624|    if (if1 || if2) {
  ------------------
  |  Branch (240:9): [True: 0, False: 624]
  |  Branch (240:16): [True: 2, False: 622]
  ------------------
  241|      2|        if (if1) {
  ------------------
  |  Branch (241:13): [True: 0, False: 2]
  ------------------
  242|      0|            run_container_copy(src_1, dst);
  243|      0|            return;
  244|      0|        }
  245|      2|        if (if2) {
  ------------------
  |  Branch (245:13): [True: 2, False: 0]
  ------------------
  246|      2|            run_container_copy(src_2, dst);
  247|      2|            return;
  248|      2|        }
  249|      2|    }
  250|    622|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  251|    622|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (251:9): [True: 622, False: 0]
  ------------------
  252|    622|        run_container_grow(dst, neededcapacity, false);
  253|    622|    dst->n_runs = 0;
  254|    622|    int32_t rlepos = 0;
  255|    622|    int32_t xrlepos = 0;
  256|       |
  257|    622|    rle16_t previousrle;
  258|    622|    if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (258:9): [True: 598, False: 24]
  ------------------
  259|    598|        previousrle = run_container_append_first(dst, src_1->runs[rlepos]);
  260|    598|        rlepos++;
  261|    598|    } else {
  262|     24|        previousrle = run_container_append_first(dst, src_2->runs[xrlepos]);
  263|     24|        xrlepos++;
  264|     24|    }
  265|       |
  266|  73.9k|    while ((xrlepos < src_2->n_runs) && (rlepos < src_1->n_runs)) {
  ------------------
  |  Branch (266:12): [True: 73.6k, False: 276]
  |  Branch (266:41): [True: 73.3k, False: 346]
  ------------------
  267|  73.3k|        rle16_t newrl;
  268|  73.3k|        if (src_1->runs[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (268:13): [True: 39.9k, False: 33.3k]
  ------------------
  269|  39.9k|            newrl = src_1->runs[rlepos];
  270|  39.9k|            rlepos++;
  271|  39.9k|        } else {
  272|  33.3k|            newrl = src_2->runs[xrlepos];
  273|  33.3k|            xrlepos++;
  274|  33.3k|        }
  275|  73.3k|        run_container_append(dst, newrl, &previousrle);
  276|  73.3k|    }
  277|  1.57k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (277:12): [True: 955, False: 622]
  ------------------
  278|    955|        run_container_append(dst, src_2->runs[xrlepos], &previousrle);
  279|    955|        xrlepos++;
  280|    955|    }
  281|  10.5k|    while (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (281:12): [True: 9.97k, False: 622]
  ------------------
  282|  9.97k|        run_container_append(dst, src_1->runs[rlepos], &previousrle);
  283|  9.97k|        rlepos++;
  284|  9.97k|    }
  285|    622|}
run_container_union_inplace:
  291|  1.50k|                                 const run_container_t *src_2) {
  292|       |    // TODO: this could be a lot more efficient
  293|       |
  294|       |    // we start out with inexpensive checks
  295|  1.50k|    const bool if1 = run_container_is_full(src_1);
  296|  1.50k|    const bool if2 = run_container_is_full(src_2);
  297|  1.50k|    if (if1 || if2) {
  ------------------
  |  Branch (297:9): [True: 0, False: 1.50k]
  |  Branch (297:16): [True: 15, False: 1.49k]
  ------------------
  298|     15|        if (if1) {
  ------------------
  |  Branch (298:13): [True: 0, False: 15]
  ------------------
  299|      0|            return;
  300|      0|        }
  301|     15|        if (if2) {
  ------------------
  |  Branch (301:13): [True: 15, False: 0]
  ------------------
  302|     15|            run_container_copy(src_2, src_1);
  303|     15|            return;
  304|     15|        }
  305|     15|    }
  306|       |    // we move the data to the end of the current array
  307|  1.49k|    const int32_t maxoutput = src_1->n_runs + src_2->n_runs;
  308|  1.49k|    const int32_t neededcapacity = maxoutput + src_1->n_runs;
  309|  1.49k|    if (src_1->capacity < neededcapacity)
  ------------------
  |  Branch (309:9): [True: 1.49k, False: 0]
  ------------------
  310|  1.49k|        run_container_grow(src_1, neededcapacity, true);
  311|  1.49k|    memmove(src_1->runs + maxoutput, src_1->runs,
  312|  1.49k|            src_1->n_runs * sizeof(rle16_t));
  313|  1.49k|    rle16_t *inputsrc1 = src_1->runs + maxoutput;
  314|  1.49k|    const int32_t input1nruns = src_1->n_runs;
  315|  1.49k|    src_1->n_runs = 0;
  316|  1.49k|    int32_t rlepos = 0;
  317|  1.49k|    int32_t xrlepos = 0;
  318|       |
  319|  1.49k|    rle16_t previousrle;
  320|  1.49k|    if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (320:9): [True: 1.44k, False: 44]
  ------------------
  321|  1.44k|        previousrle = run_container_append_first(src_1, inputsrc1[rlepos]);
  322|  1.44k|        rlepos++;
  323|  1.44k|    } else {
  324|     44|        previousrle = run_container_append_first(src_1, src_2->runs[xrlepos]);
  325|     44|        xrlepos++;
  326|     44|    }
  327|   164k|    while ((xrlepos < src_2->n_runs) && (rlepos < input1nruns)) {
  ------------------
  |  Branch (327:12): [True: 164k, False: 128]
  |  Branch (327:41): [True: 162k, False: 1.36k]
  ------------------
  328|   162k|        rle16_t newrl;
  329|   162k|        if (inputsrc1[rlepos].value <= src_2->runs[xrlepos].value) {
  ------------------
  |  Branch (329:13): [True: 77.8k, False: 84.7k]
  ------------------
  330|  77.8k|            newrl = inputsrc1[rlepos];
  331|  77.8k|            rlepos++;
  332|  84.7k|        } else {
  333|  84.7k|            newrl = src_2->runs[xrlepos];
  334|  84.7k|            xrlepos++;
  335|  84.7k|        }
  336|   162k|        run_container_append(src_1, newrl, &previousrle);
  337|   162k|    }
  338|  3.90k|    while (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (338:12): [True: 2.41k, False: 1.49k]
  ------------------
  339|  2.41k|        run_container_append(src_1, src_2->runs[xrlepos], &previousrle);
  340|  2.41k|        xrlepos++;
  341|  2.41k|    }
  342|  8.32k|    while (rlepos < input1nruns) {
  ------------------
  |  Branch (342:12): [True: 6.83k, False: 1.49k]
  ------------------
  343|  6.83k|        run_container_append(src_1, inputsrc1[rlepos], &previousrle);
  344|  6.83k|        rlepos++;
  345|  6.83k|    }
  346|  1.49k|}
run_container_xor:
  353|  53.7k|                       const run_container_t *src_2, run_container_t *dst) {
  354|       |    // don't bother to convert xor with full range into negation
  355|       |    // since negation is implemented similarly
  356|       |
  357|  53.7k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  358|  53.7k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (358:9): [True: 53.7k, False: 0]
  ------------------
  359|  53.7k|        run_container_grow(dst, neededcapacity, false);
  360|       |
  361|  53.7k|    rle16_t *out = dst->runs;
  362|  53.7k|    int32_t n_out = 0;
  363|  53.7k|    int32_t pos1 = 0;
  364|  53.7k|    int32_t pos2 = 0;
  365|       |
  366|   209k|    while ((pos1 < src_1->n_runs) && (pos2 < src_2->n_runs)) {
  ------------------
  |  Branch (366:12): [True: 156k, False: 53.4k]
  |  Branch (366:38): [True: 155k, False: 285]
  ------------------
  367|   155k|        if (src_1->runs[pos1].value <= src_2->runs[pos2].value) {
  ------------------
  |  Branch (367:13): [True: 106k, False: 49.3k]
  ------------------
  368|   106k|            n_out = run_append_exclusive(out, n_out, src_1->runs[pos1].value,
  369|   106k|                                         src_1->runs[pos1].length);
  370|   106k|            pos1++;
  371|   106k|        } else {
  372|  49.3k|            n_out = run_append_exclusive(out, n_out, src_2->runs[pos2].value,
  373|  49.3k|                                         src_2->runs[pos2].length);
  374|  49.3k|            pos2++;
  375|  49.3k|        }
  376|   155k|    }
  377|  63.9k|    while (pos1 < src_1->n_runs) {
  ------------------
  |  Branch (377:12): [True: 10.1k, False: 53.7k]
  ------------------
  378|  10.1k|        n_out = run_append_exclusive(out, n_out, src_1->runs[pos1].value,
  379|  10.1k|                                     src_1->runs[pos1].length);
  380|  10.1k|        pos1++;
  381|  10.1k|    }
  382|       |
  383|   108k|    while (pos2 < src_2->n_runs) {
  ------------------
  |  Branch (383:12): [True: 55.1k, False: 53.7k]
  ------------------
  384|  55.1k|        n_out = run_append_exclusive(out, n_out, src_2->runs[pos2].value,
  385|  55.1k|                                     src_2->runs[pos2].length);
  386|  55.1k|        pos2++;
  387|  55.1k|    }
  388|  53.7k|    dst->n_runs = n_out;
  389|  53.7k|}
run_container_intersection:
  396|  54.7k|                                run_container_t *dst) {
  397|  54.7k|    const bool if1 = run_container_is_full(src_1);
  398|  54.7k|    const bool if2 = run_container_is_full(src_2);
  399|  54.7k|    if (if1 || if2) {
  ------------------
  |  Branch (399:9): [True: 51.4k, False: 3.26k]
  |  Branch (399:16): [True: 2, False: 3.26k]
  ------------------
  400|  51.4k|        if (if1) {
  ------------------
  |  Branch (400:13): [True: 51.4k, False: 2]
  ------------------
  401|  51.4k|            run_container_copy(src_2, dst);
  402|  51.4k|            return;
  403|  51.4k|        }
  404|      2|        if (if2) {
  ------------------
  |  Branch (404:13): [True: 2, False: 0]
  ------------------
  405|      2|            run_container_copy(src_1, dst);
  406|      2|            return;
  407|      2|        }
  408|      2|    }
  409|       |    // TODO: this could be a lot more efficient, could use SIMD optimizations
  410|  3.26k|    const int32_t neededcapacity = src_1->n_runs + src_2->n_runs;
  411|  3.26k|    if (dst->capacity < neededcapacity)
  ------------------
  |  Branch (411:9): [True: 3.26k, False: 0]
  ------------------
  412|  3.26k|        run_container_grow(dst, neededcapacity, false);
  413|  3.26k|    dst->n_runs = 0;
  414|  3.26k|    int32_t rlepos = 0;
  415|  3.26k|    int32_t xrlepos = 0;
  416|  3.26k|    int32_t start = src_1->runs[rlepos].value;
  417|  3.26k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  418|  3.26k|    int32_t xstart = src_2->runs[xrlepos].value;
  419|  3.26k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  420|   160k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (420:12): [True: 158k, False: 2.78k]
  |  Branch (420:40): [True: 157k, False: 478]
  ------------------
  421|   157k|        if (end <= xstart) {
  ------------------
  |  Branch (421:13): [True: 39.3k, False: 118k]
  ------------------
  422|  39.3k|            ++rlepos;
  423|  39.3k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (423:17): [True: 39.3k, False: 70]
  ------------------
  424|  39.3k|                start = src_1->runs[rlepos].value;
  425|  39.3k|                end = start + src_1->runs[rlepos].length + 1;
  426|  39.3k|            }
  427|   118k|        } else if (xend <= start) {
  ------------------
  |  Branch (427:20): [True: 10.5k, False: 107k]
  ------------------
  428|  10.5k|            ++xrlepos;
  429|  10.5k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (429:17): [True: 10.5k, False: 40]
  ------------------
  430|  10.5k|                xstart = src_2->runs[xrlepos].value;
  431|  10.5k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  432|  10.5k|            }
  433|   107k|        } else {  // they overlap
  434|   107k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (434:41): [True: 13.1k, False: 94.4k]
  ------------------
  435|   107k|            int32_t earliestend;
  436|   107k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (436:17): [True: 82.4k, False: 25.1k]
  ------------------
  437|  82.4k|                earliestend = end;
  438|  82.4k|                rlepos++;
  439|  82.4k|                xrlepos++;
  440|  82.4k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (440:21): [True: 79.8k, False: 2.58k]
  ------------------
  441|  79.8k|                    start = src_1->runs[rlepos].value;
  442|  79.8k|                    end = start + src_1->runs[rlepos].length + 1;
  443|  79.8k|                }
  444|  82.4k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (444:21): [True: 79.6k, False: 2.82k]
  ------------------
  445|  79.6k|                    xstart = src_2->runs[xrlepos].value;
  446|  79.6k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  447|  79.6k|                }
  448|  82.4k|            } else if (end < xend) {
  ------------------
  |  Branch (448:24): [True: 13.1k, False: 12.0k]
  ------------------
  449|  13.1k|                earliestend = end;
  450|  13.1k|                rlepos++;
  451|  13.1k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (451:21): [True: 13.0k, False: 137]
  ------------------
  452|  13.0k|                    start = src_1->runs[rlepos].value;
  453|  13.0k|                    end = start + src_1->runs[rlepos].length + 1;
  454|  13.0k|                }
  455|       |
  456|  13.1k|            } else {  // end > xend
  457|  12.0k|                earliestend = xend;
  458|  12.0k|                xrlepos++;
  459|  12.0k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (459:21): [True: 11.8k, False: 130]
  ------------------
  460|  11.8k|                    xstart = src_2->runs[xrlepos].value;
  461|  11.8k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  462|  11.8k|                }
  463|  12.0k|            }
  464|   107k|            dst->runs[dst->n_runs].value = (uint16_t)lateststart;
  465|   107k|            dst->runs[dst->n_runs].length =
  466|   107k|                (uint16_t)(earliestend - lateststart - 1);
  467|   107k|            dst->n_runs++;
  468|   107k|        }
  469|   157k|    }
  470|  3.26k|}
run_container_intersection_cardinality:
  475|  2.49k|                                           const run_container_t *src_2) {
  476|  2.49k|    const bool if1 = run_container_is_full(src_1);
  477|  2.49k|    const bool if2 = run_container_is_full(src_2);
  478|  2.49k|    if (if1 || if2) {
  ------------------
  |  Branch (478:9): [True: 0, False: 2.49k]
  |  Branch (478:16): [True: 8, False: 2.48k]
  ------------------
  479|      8|        if (if1) {
  ------------------
  |  Branch (479:13): [True: 0, False: 8]
  ------------------
  480|      0|            return run_container_cardinality(src_2);
  481|      0|        }
  482|      8|        if (if2) {
  ------------------
  |  Branch (482:13): [True: 8, False: 0]
  ------------------
  483|      8|            return run_container_cardinality(src_1);
  484|      8|        }
  485|      8|    }
  486|  2.48k|    int answer = 0;
  487|  2.48k|    int32_t rlepos = 0;
  488|  2.48k|    int32_t xrlepos = 0;
  489|  2.48k|    int32_t start = src_1->runs[rlepos].value;
  490|  2.48k|    int32_t end = start + src_1->runs[rlepos].length + 1;
  491|  2.48k|    int32_t xstart = src_2->runs[xrlepos].value;
  492|  2.48k|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  493|   249k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (493:12): [True: 247k, False: 1.65k]
  |  Branch (493:40): [True: 246k, False: 832]
  ------------------
  494|   246k|        if (end <= xstart) {
  ------------------
  |  Branch (494:13): [True: 59.2k, False: 187k]
  ------------------
  495|  59.2k|            ++rlepos;
  496|  59.2k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (496:17): [True: 59.0k, False: 280]
  ------------------
  497|  59.0k|                start = src_1->runs[rlepos].value;
  498|  59.0k|                end = start + src_1->runs[rlepos].length + 1;
  499|  59.0k|            }
  500|   187k|        } else if (xend <= start) {
  ------------------
  |  Branch (500:20): [True: 42.3k, False: 144k]
  ------------------
  501|  42.3k|            ++xrlepos;
  502|  42.3k|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (502:17): [True: 42.1k, False: 160]
  ------------------
  503|  42.1k|                xstart = src_2->runs[xrlepos].value;
  504|  42.1k|                xend = xstart + src_2->runs[xrlepos].length + 1;
  505|  42.1k|            }
  506|   144k|        } else {  // they overlap
  507|   144k|            const int32_t lateststart = start > xstart ? start : xstart;
  ------------------
  |  Branch (507:41): [True: 52.6k, False: 92.3k]
  ------------------
  508|   144k|            int32_t earliestend;
  509|   144k|            if (end == xend) {  // improbable
  ------------------
  |  Branch (509:17): [True: 76.5k, False: 68.4k]
  ------------------
  510|  76.5k|                earliestend = end;
  511|  76.5k|                rlepos++;
  512|  76.5k|                xrlepos++;
  513|  76.5k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (513:21): [True: 75.6k, False: 828]
  ------------------
  514|  75.6k|                    start = src_1->runs[rlepos].value;
  515|  75.6k|                    end = start + src_1->runs[rlepos].length + 1;
  516|  75.6k|                }
  517|  76.5k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (517:21): [True: 75.4k, False: 1.03k]
  ------------------
  518|  75.4k|                    xstart = src_2->runs[xrlepos].value;
  519|  75.4k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  520|  75.4k|                }
  521|  76.5k|            } else if (end < xend) {
  ------------------
  |  Branch (521:24): [True: 52.6k, False: 15.7k]
  ------------------
  522|  52.6k|                earliestend = end;
  523|  52.6k|                rlepos++;
  524|  52.6k|                if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (524:21): [True: 52.1k, False: 548]
  ------------------
  525|  52.1k|                    start = src_1->runs[rlepos].value;
  526|  52.1k|                    end = start + src_1->runs[rlepos].length + 1;
  527|  52.1k|                }
  528|       |
  529|  52.6k|            } else {  // end > xend
  530|  15.7k|                earliestend = xend;
  531|  15.7k|                xrlepos++;
  532|  15.7k|                if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (532:21): [True: 15.5k, False: 200]
  ------------------
  533|  15.5k|                    xstart = src_2->runs[xrlepos].value;
  534|  15.5k|                    xend = xstart + src_2->runs[xrlepos].length + 1;
  535|  15.5k|                }
  536|  15.7k|            }
  537|   144k|            answer += earliestend - lateststart;
  538|   144k|        }
  539|   246k|    }
  540|  2.48k|    return answer;
  541|  2.49k|}
run_container_intersect:
  545|    624|                             const run_container_t *src_2) {
  546|    624|    const bool if1 = run_container_is_full(src_1);
  547|    624|    const bool if2 = run_container_is_full(src_2);
  548|    624|    if (if1 || if2) {
  ------------------
  |  Branch (548:9): [True: 0, False: 624]
  |  Branch (548:16): [True: 2, False: 622]
  ------------------
  549|      2|        if (if1) {
  ------------------
  |  Branch (549:13): [True: 0, False: 2]
  ------------------
  550|      0|            return !run_container_empty(src_2);
  551|      0|        }
  552|      2|        if (if2) {
  ------------------
  |  Branch (552:13): [True: 2, False: 0]
  ------------------
  553|      2|            return !run_container_empty(src_1);
  554|      2|        }
  555|      2|    }
  556|    622|    int32_t rlepos = 0;
  557|    622|    int32_t xrlepos = 0;
  558|    622|    int32_t start = src_1->runs[rlepos].value;
  559|    622|    int32_t end = start + src_1->runs[rlepos].length + 1;
  560|    622|    int32_t xstart = src_2->runs[xrlepos].value;
  561|    622|    int32_t xend = xstart + src_2->runs[xrlepos].length + 1;
  562|  2.82k|    while ((rlepos < src_1->n_runs) && (xrlepos < src_2->n_runs)) {
  ------------------
  |  Branch (562:12): [True: 2.81k, False: 14]
  |  Branch (562:40): [True: 2.80k, False: 6]
  ------------------
  563|  2.80k|        if (end <= xstart) {
  ------------------
  |  Branch (563:13): [True: 1.80k, False: 1.00k]
  ------------------
  564|  1.80k|            ++rlepos;
  565|  1.80k|            if (rlepos < src_1->n_runs) {
  ------------------
  |  Branch (565:17): [True: 1.79k, False: 14]
  ------------------
  566|  1.79k|                start = src_1->runs[rlepos].value;
  567|  1.79k|                end = start + src_1->runs[rlepos].length + 1;
  568|  1.79k|            }
  569|  1.80k|        } else if (xend <= start) {
  ------------------
  |  Branch (569:20): [True: 399, False: 602]
  ------------------
  570|    399|            ++xrlepos;
  571|    399|            if (xrlepos < src_2->n_runs) {
  ------------------
  |  Branch (571:17): [True: 393, False: 6]
  ------------------
  572|    393|                xstart = src_2->runs[xrlepos].value;
  573|    393|                xend = xstart + src_2->runs[xrlepos].length + 1;
  574|    393|            }
  575|    602|        } else {  // they overlap
  576|    602|            return true;
  577|    602|        }
  578|  2.80k|    }
  579|     20|    return false;
  580|    622|}
run_container_andnot:
  586|  1.02k|                          const run_container_t *src_2, run_container_t *dst) {
  587|       |    // following Java implementation as of June 2016
  588|       |
  589|  1.02k|    if (dst->capacity < src_1->n_runs + src_2->n_runs)
  ------------------
  |  Branch (589:9): [True: 1.02k, False: 0]
  ------------------
  590|  1.02k|        run_container_grow(dst, src_1->n_runs + src_2->n_runs, false);
  591|       |
  592|  1.02k|    int32_t n_out = 0;
  593|       |
  594|  1.02k|    int rlepos1 = 0;
  595|  1.02k|    int rlepos2 = 0;
  596|  1.02k|    int32_t start = src_1->runs[rlepos1].value;
  597|  1.02k|    int32_t end = start + src_1->runs[rlepos1].length + 1;
  598|  1.02k|    int32_t start2 = src_2->runs[rlepos2].value;
  599|  1.02k|    int32_t end2 = start2 + src_2->runs[rlepos2].length + 1;
  600|       |
  601|   133k|    while ((rlepos1 < src_1->n_runs) && (rlepos2 < src_2->n_runs)) {
  ------------------
  |  Branch (601:12): [True: 133k, False: 613]
  |  Branch (601:41): [True: 132k, False: 410]
  ------------------
  602|   132k|        if (end <= start2) {
  ------------------
  |  Branch (602:13): [True: 19.6k, False: 113k]
  ------------------
  603|       |            // output the first run
  604|  19.6k|            dst->runs[n_out++] = CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|  19.6k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  605|  19.6k|            rlepos1++;
  606|  19.6k|            if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (606:17): [True: 19.6k, False: 70]
  ------------------
  607|  19.6k|                start = src_1->runs[rlepos1].value;
  608|  19.6k|                end = start + src_1->runs[rlepos1].length + 1;
  609|  19.6k|            }
  610|   113k|        } else if (end2 <= start) {
  ------------------
  |  Branch (610:20): [True: 55.0k, False: 58.0k]
  ------------------
  611|       |            // exit the second run
  612|  55.0k|            rlepos2++;
  613|  55.0k|            if (rlepos2 < src_2->n_runs) {
  ------------------
  |  Branch (613:17): [True: 54.6k, False: 410]
  ------------------
  614|  54.6k|                start2 = src_2->runs[rlepos2].value;
  615|  54.6k|                end2 = start2 + src_2->runs[rlepos2].length + 1;
  616|  54.6k|            }
  617|  58.0k|        } else {
  618|  58.0k|            if (start < start2) {
  ------------------
  |  Branch (618:17): [True: 14.7k, False: 43.3k]
  ------------------
  619|  14.7k|                dst->runs[n_out++] =
  620|  14.7k|                    CROARING_MAKE_RLE16(start, start2 - start - 1);
  ------------------
  |  |   60|  14.7k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  621|  14.7k|            }
  622|  58.0k|            if (end2 < end) {
  ------------------
  |  Branch (622:17): [True: 14.1k, False: 43.8k]
  ------------------
  623|  14.1k|                start = end2;
  624|  43.8k|            } else {
  625|  43.8k|                rlepos1++;
  626|  43.8k|                if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (626:21): [True: 43.3k, False: 543]
  ------------------
  627|  43.3k|                    start = src_1->runs[rlepos1].value;
  628|  43.3k|                    end = start + src_1->runs[rlepos1].length + 1;
  629|  43.3k|                }
  630|  43.8k|            }
  631|  58.0k|        }
  632|   132k|    }
  633|  1.02k|    if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (633:9): [True: 410, False: 613]
  ------------------
  634|    410|        dst->runs[n_out++] = CROARING_MAKE_RLE16(start, end - start - 1);
  ------------------
  |  |   60|    410|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  635|    410|        rlepos1++;
  636|    410|        if (rlepos1 < src_1->n_runs) {
  ------------------
  |  Branch (636:13): [True: 195, False: 215]
  ------------------
  637|    195|            memcpy(dst->runs + n_out, src_1->runs + rlepos1,
  638|    195|                   sizeof(rle16_t) * (src_1->n_runs - rlepos1));
  639|    195|            n_out += src_1->n_runs - rlepos1;
  640|    195|        }
  641|    410|    }
  642|  1.02k|    dst->n_runs = n_out;
  643|  1.02k|}
run_container_read:
  751|     49|                           const char *buf) {
  752|     49|    (void)cardinality;
  753|     49|    uint16_t cast_16;
  754|     49|    memcpy(&cast_16, buf, sizeof(uint16_t));
  755|     49|    container->n_runs = croaring_letoh16(cast_16);
  ------------------
  |  |  550|     49|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  544|     49|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  756|     49|    if (container->n_runs > container->capacity)
  ------------------
  |  Branch (756:9): [True: 7, False: 42]
  ------------------
  757|      7|        run_container_grow(container, container->n_runs, false);
  758|     49|    if (container->n_runs > 0) {
  ------------------
  |  Branch (758:9): [True: 7, False: 42]
  ------------------
  759|       |#if CROARING_IS_BIG_ENDIAN
  760|       |        const char *in = buf + sizeof(uint16_t);
  761|       |        for (int32_t i = 0; i < container->n_runs; ++i) {
  762|       |            uint16_t v_le, l_le;
  763|       |            memcpy(&v_le, in, sizeof(uint16_t));
  764|       |            memcpy(&l_le, in + sizeof(uint16_t), sizeof(uint16_t));
  765|       |            container->runs[i].value = croaring_letoh16(v_le);
  766|       |            container->runs[i].length = croaring_letoh16(l_le);
  767|       |            in += sizeof(rle16_t);
  768|       |        }
  769|       |#else
  770|      7|        memcpy(container->runs, buf + sizeof(uint16_t),
  771|      7|               container->n_runs * sizeof(rle16_t));
  772|      7|#endif
  773|      7|    }
  774|     49|    return run_container_size_in_bytes(container);
  775|     49|}
run_container_iterate:
  779|  53.6k|                           roaring_iterator iterator, void *ptr) {
  780|   141k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (780:21): [True: 87.8k, False: 53.6k]
  ------------------
  781|  87.8k|        uint32_t run_start = base + cont->runs[i].value;
  782|  87.8k|        uint16_t le = cont->runs[i].length;
  783|       |
  784|  3.43G|        for (int j = 0; j <= le; ++j)
  ------------------
  |  Branch (784:25): [True: 3.43G, False: 87.8k]
  ------------------
  785|  3.43G|            if (!iterator(run_start + j, ptr)) return false;
  ------------------
  |  Branch (785:17): [True: 0, False: 3.43G]
  ------------------
  786|  87.8k|    }
  787|  53.6k|    return true;
  788|  53.6k|}
run_container_is_subset:
  807|    227|                             const run_container_t *container2) {
  808|    227|    int i1 = 0, i2 = 0;
  809|    780|    while (i1 < container1->n_runs && i2 < container2->n_runs) {
  ------------------
  |  Branch (809:12): [True: 780, False: 0]
  |  Branch (809:39): [True: 772, False: 8]
  ------------------
  810|    772|        int start1 = container1->runs[i1].value;
  811|    772|        int stop1 = start1 + container1->runs[i1].length;
  812|    772|        int start2 = container2->runs[i2].value;
  813|    772|        int stop2 = start2 + container2->runs[i2].length;
  814|    772|        if (start1 < start2) {
  ------------------
  |  Branch (814:13): [True: 219, False: 553]
  ------------------
  815|    219|            return false;
  816|    553|        } else {  // start1 >= start2
  817|    553|            if (stop1 < stop2) {
  ------------------
  |  Branch (817:17): [True: 0, False: 553]
  ------------------
  818|      0|                i1++;
  819|    553|            } else if (stop1 == stop2) {
  ------------------
  |  Branch (819:24): [True: 0, False: 553]
  ------------------
  820|      0|                i1++;
  821|      0|                i2++;
  822|    553|            } else {  // stop1 > stop2
  823|    553|                i2++;
  824|    553|            }
  825|    553|        }
  826|    772|    }
  827|      8|    if (i1 == container1->n_runs) {
  ------------------
  |  Branch (827:9): [True: 0, False: 8]
  ------------------
  828|      0|        return true;
  829|      8|    } else {
  830|       |        return false;
  831|      8|    }
  832|      8|}
run_container_smart_append_exclusive:
  839|   133k|                                          const uint16_t length) {
  840|   133k|    src->n_runs = run_append_exclusive(src->runs, src->n_runs, start, length);
  841|   133k|}
run_container_select:
  846|  2.28k|                          uint32_t *element) {
  847|  4.66k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (847:21): [True: 4.66k, False: 0]
  ------------------
  848|  4.66k|        uint16_t length = container->runs[i].length;
  849|  4.66k|        if (rank <= *start_rank + length) {
  ------------------
  |  Branch (849:13): [True: 2.28k, False: 2.37k]
  ------------------
  850|  2.28k|            uint16_t value = container->runs[i].value;
  851|  2.28k|            *element = value + rank - (*start_rank);
  852|  2.28k|            return true;
  853|  2.28k|        } else
  854|  2.37k|            *start_rank += length + 1;
  855|  4.66k|    }
  856|      0|    return false;
  857|  2.28k|}
run_container_rank:
  860|  2.34k|int run_container_rank(const run_container_t *container, uint16_t x) {
  861|  2.34k|    int sum = 0;
  862|  2.34k|    uint32_t x32 = x;
  863|  8.62k|    for (int i = 0; i < container->n_runs; i++) {
  ------------------
  |  Branch (863:21): [True: 8.56k, False: 53]
  ------------------
  864|  8.56k|        uint32_t startpoint = container->runs[i].value;
  865|  8.56k|        uint32_t length = container->runs[i].length;
  866|  8.56k|        uint32_t endpoint = length + startpoint;
  867|  8.56k|        if (x <= endpoint) {
  ------------------
  |  Branch (867:13): [True: 2.29k, False: 6.27k]
  ------------------
  868|  2.29k|            if (x < startpoint) break;
  ------------------
  |  Branch (868:17): [True: 223, False: 2.07k]
  ------------------
  869|  2.07k|            return sum + (x32 - startpoint) + 1;
  870|  6.27k|        } else {
  871|  6.27k|            sum += length + 1;
  872|  6.27k|        }
  873|  8.56k|    }
  874|    276|    return sum;
  875|  2.34k|}
_avx2_run_container_to_uint32_array:
  999|  54.2k|                                        uint32_t base) {
 1000|  54.2k|    int outpos = 0;
 1001|  54.2k|    uint32_t *out = (uint32_t *)vout;
 1002|       |
 1003|   183k|    for (int i = 0; i < cont->n_runs; ++i) {
  ------------------
  |  Branch (1003:21): [True: 129k, False: 54.2k]
  ------------------
 1004|   129k|        uint32_t run_start = base + cont->runs[i].value;
 1005|   129k|        uint16_t le = cont->runs[i].length;
 1006|   129k|        if (le < 8) {
  ------------------
  |  Branch (1006:13): [True: 72.3k, False: 57.3k]
  ------------------
 1007|   187k|            for (int j = 0; j <= le; ++j) {
  ------------------
  |  Branch (1007:29): [True: 115k, False: 72.3k]
  ------------------
 1008|   115k|                uint32_t val = run_start + j;
 1009|   115k|                memcpy(out + outpos, &val,
 1010|   115k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1011|   115k|                outpos++;
 1012|   115k|            }
 1013|  72.3k|        } else {
 1014|  57.3k|            int j = 0;
 1015|  57.3k|            __m256i run_start_v = _mm256_set1_epi32(run_start);
 1016|       |            // [8,8,8,8....]
 1017|  57.3k|            __m256i inc = _mm256_set1_epi32(8);
 1018|       |            // used for generate sequence:
 1019|       |            // [0, 1, 2, 3...], [8, 9, 10,...]
 1020|  57.3k|            __m256i delta = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
 1021|   430M|            for (j = 0; j + 8 <= le; j += 8) {
  ------------------
  |  Branch (1021:25): [True: 430M, False: 57.3k]
  ------------------
 1022|   430M|                __m256i val_v = _mm256_add_epi32(run_start_v, delta);
 1023|   430M|                _mm256_storeu_si256((__m256i *)(out + outpos), val_v);
 1024|   430M|                delta = _mm256_add_epi32(inc, delta);
 1025|   430M|                outpos += 8;
 1026|   430M|            }
 1027|   494k|            for (; j <= le; ++j) {
  ------------------
  |  Branch (1027:20): [True: 437k, False: 57.3k]
  ------------------
 1028|   437k|                uint32_t val = run_start + j;
 1029|   437k|                memcpy(out + outpos, &val,
 1030|   437k|                       sizeof(uint32_t));  // should be compiled as a MOV on x64
 1031|   437k|                outpos++;
 1032|   437k|            }
 1033|  57.3k|        }
 1034|   129k|    }
 1035|  54.2k|    return outpos;
 1036|  54.2k|}
run_container_cardinality:
 1056|   488k|int run_container_cardinality(const run_container_t *run) {
 1057|       |    // Empirically AVX-512 is not always faster than AVX2
 1058|       |#if CROARING_COMPILER_SUPPORTS_AVX512 && \
 1059|       |    CROARING_ENABLE_AVX512_RUN_CONTAINER_CARDINALITY
 1060|       |    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX512) {
 1061|       |        return _avx512_run_container_cardinality(run);
 1062|       |    } else
 1063|       |#endif
 1064|   488k|        if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1064:13): [True: 488k, False: 0]
  ------------------
 1065|   488k|        return _avx2_run_container_cardinality(run);
 1066|   488k|    } else {
 1067|      0|        return _scalar_run_container_cardinality(run);
 1068|      0|    }
 1069|   488k|}
run_container_to_uint32_array:
 1091|  54.2k|                                  uint32_t base) {
 1092|  54.2k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1092:9): [True: 54.2k, False: 0]
  ------------------
 1093|  54.2k|        return _avx2_run_container_to_uint32_array(vout, cont, base);
 1094|  54.2k|    } else {
 1095|      0|        return _scalar_run_container_to_uint32_array(vout, cont, base);
 1096|      0|    }
 1097|  54.2k|}
run.c:_avx2_run_container_cardinality:
  969|   488k|static inline int _avx2_run_container_cardinality(const run_container_t *run) {
  970|   488k|    const int32_t n_runs = run->n_runs;
  971|   488k|    const rle16_t *runs = run->runs;
  972|       |
  973|       |    /* by initializing with n_runs, we omit counting the +1 for each pair. */
  974|   488k|    int sum = n_runs;
  975|   488k|    int32_t k = 0;
  976|   488k|    const int32_t step = sizeof(__m256i) / sizeof(rle16_t);
  977|   488k|    if (n_runs > step) {
  ------------------
  |  Branch (977:9): [True: 32.2k, False: 456k]
  ------------------
  978|  32.2k|        __m256i total = _mm256_setzero_si256();
  979|   352k|        for (; k + step <= n_runs; k += step) {
  ------------------
  |  Branch (979:16): [True: 319k, False: 32.2k]
  ------------------
  980|   319k|            __m256i ymm1 = _mm256_loadu_si256((const __m256i *)(runs + k));
  981|   319k|            __m256i justlengths = _mm256_srli_epi32(ymm1, 16);
  982|   319k|            total = _mm256_add_epi32(total, justlengths);
  983|   319k|        }
  984|       |        // a store might be faster than extract?
  985|  32.2k|        uint32_t buffer[sizeof(__m256i) / sizeof(rle16_t)];
  986|  32.2k|        _mm256_storeu_si256((__m256i *)buffer, total);
  987|  32.2k|        sum += (buffer[0] + buffer[1]) + (buffer[2] + buffer[3]) +
  988|  32.2k|               (buffer[4] + buffer[5]) + (buffer[6] + buffer[7]);
  989|  32.2k|    }
  990|  1.02M|    for (; k < n_runs; ++k) {
  ------------------
  |  Branch (990:12): [True: 534k, False: 488k]
  ------------------
  991|   534k|        sum += runs[k].length;
  992|   534k|    }
  993|       |
  994|   488k|    return sum;
  995|   488k|}

croaring_hardware_support:
  411|   888k|int croaring_hardware_support(void) {
  412|   888k|    static croaring_atomic_int support = CROARING_SUPPORT_UNKNOWN;
  ------------------
  |  |  375|   888k|#define CROARING_SUPPORT_UNKNOWN 0xFFFFFFF
  ------------------
  413|   888k|    if (support == 0xFFFFFFF) {
  ------------------
  |  Branch (413:9): [True: 1, False: 888k]
  ------------------
  414|      1|        bool has_avx2 = (croaring_detect_supported_architectures() &
  415|      1|                         CROARING_AVX2) == CROARING_AVX2;
  416|      1|        bool has_avx512 = false;
  417|      1|#if CROARING_COMPILER_SUPPORTS_AVX512
  418|      1|        has_avx512 = (croaring_detect_supported_architectures() &
  419|      1|                      CROARING_AVX512_REQUIRED) == CROARING_AVX512_REQUIRED;
  420|      1|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
  421|      1|        support = (has_avx2 ? ROARING_SUPPORTS_AVX2 : 0) |
  ------------------
  |  Branch (421:20): [True: 1, False: 0]
  ------------------
  422|      1|                  (has_avx512 ? ROARING_SUPPORTS_AVX512 : 0);
  ------------------
  |  Branch (422:20): [True: 0, False: 1]
  ------------------
  423|      1|    }
  424|   888k|    return support;
  425|   888k|}
isadetection.c:croaring_detect_supported_architectures:
  345|      2|static uint32_t croaring_detect_supported_architectures(void) {
  346|       |    // we use an atomic for thread safety
  347|      2|    static _Atomic uint32_t buffer = CROARING_UNINITIALIZED;
  348|      2|    if (buffer == CROARING_UNINITIALIZED) {
  ------------------
  |  Branch (348:9): [True: 1, False: 1]
  ------------------
  349|       |        // atomicity is sufficient
  350|      1|        buffer = dynamic_croaring_detect_supported_architectures();
  351|      1|    }
  352|      2|    return buffer;
  353|      2|}
isadetection.c:dynamic_croaring_detect_supported_architectures:
  196|      1|static inline uint32_t dynamic_croaring_detect_supported_architectures(void) {
  197|      1|    uint32_t eax, ebx, ecx, edx;
  198|      1|    uint32_t host_isa = 0x0;
  199|       |    // Can be found on Intel ISA Reference for CPUID
  200|      1|    static uint32_t cpuid_avx2_bit =
  201|      1|        1 << 5;  ///< @private Bit 5 of EBX for EAX=0x7
  202|      1|    static uint32_t cpuid_bmi1_bit =
  203|      1|        1 << 3;  ///< @private bit 3 of EBX for EAX=0x7
  204|      1|    static uint32_t cpuid_bmi2_bit =
  205|      1|        1 << 8;  ///< @private bit 8 of EBX for EAX=0x7
  206|      1|    static uint32_t cpuid_avx512f_bit =
  207|      1|        1 << 16;  ///< @private bit 16 of EBX for EAX=0x7
  208|      1|    static uint32_t cpuid_avx512dq_bit =
  209|      1|        1 << 17;  ///< @private bit 17 of EBX for EAX=0x7
  210|      1|    static uint32_t cpuid_avx512bw_bit =
  211|      1|        1 << 30;  ///< @private bit 30 of EBX for EAX=0x7
  212|      1|    static uint32_t cpuid_avx512vbmi2_bit =
  213|      1|        1 << 6;  ///< @private bit 6 of ECX for EAX=0x7
  214|      1|    static uint32_t cpuid_avx512bitalg_bit =
  215|      1|        1 << 12;  ///< @private bit 12 of ECX for EAX=0x7
  216|      1|    static uint32_t cpuid_avx512vpopcntdq_bit =
  217|      1|        1 << 14;  ///< @private bit 14 of ECX for EAX=0x7
  218|      1|    static uint64_t cpuid_avx256_saved = 1 << 2;  ///< @private bit 2 = AVX
  219|      1|    static uint64_t cpuid_avx512_saved =
  220|      1|        7 << 5;  ///< @private bits 5,6,7 = opmask, ZMM_hi256, hi16_ZMM
  221|      1|    static uint32_t cpuid_sse42_bit =
  222|      1|        1 << 20;  ///< @private bit 20 of ECX for EAX=0x1
  223|      1|    static uint32_t cpuid_osxsave =
  224|      1|        (1 << 26) | (1 << 27);  ///< @private bits 26+27 of ECX for EAX=0x1
  225|      1|    static uint32_t cpuid_pclmulqdq_bit =
  226|      1|        1 << 1;  ///< @private bit  1 of ECX for EAX=0x1
  227|       |
  228|       |    // EBX for EAX=0x1
  229|      1|    eax = 0x1;
  230|      1|    ecx = 0x0;
  231|      1|    cpuid(&eax, &ebx, &ecx, &edx);
  232|       |
  233|      1|    if (ecx & cpuid_sse42_bit) {
  ------------------
  |  Branch (233:9): [True: 1, False: 0]
  ------------------
  234|      1|        host_isa |= CROARING_SSE42;
  235|      1|    } else {
  236|      0|        return host_isa;  // everything after is redundant
  237|      0|    }
  238|       |
  239|      1|    if (ecx & cpuid_pclmulqdq_bit) {
  ------------------
  |  Branch (239:9): [True: 1, False: 0]
  ------------------
  240|      1|        host_isa |= CROARING_PCLMULQDQ;
  241|      1|    }
  242|       |
  243|      1|    if ((ecx & cpuid_osxsave) != cpuid_osxsave) {
  ------------------
  |  Branch (243:9): [True: 0, False: 1]
  ------------------
  244|      0|        return host_isa;
  245|      0|    }
  246|       |
  247|       |    // xgetbv for checking if the OS saves registers
  248|      1|    uint64_t xcr0 = xgetbv();
  249|       |
  250|      1|    if ((xcr0 & cpuid_avx256_saved) == 0) {
  ------------------
  |  Branch (250:9): [True: 0, False: 1]
  ------------------
  251|      0|        return host_isa;
  252|      0|    }
  253|       |
  254|       |    // ECX for EAX=0x7
  255|      1|    eax = 0x7;
  256|      1|    ecx = 0x0;
  257|      1|    cpuid(&eax, &ebx, &ecx, &edx);
  258|      1|    if (ebx & cpuid_avx2_bit) {
  ------------------
  |  Branch (258:9): [True: 1, False: 0]
  ------------------
  259|      1|        host_isa |= CROARING_AVX2;
  260|      1|    }
  261|      1|    if (ebx & cpuid_bmi1_bit) {
  ------------------
  |  Branch (261:9): [True: 1, False: 0]
  ------------------
  262|      1|        host_isa |= CROARING_BMI1;
  263|      1|    }
  264|       |
  265|      1|    if (ebx & cpuid_bmi2_bit) {
  ------------------
  |  Branch (265:9): [True: 1, False: 0]
  ------------------
  266|      1|        host_isa |= CROARING_BMI2;
  267|      1|    }
  268|       |
  269|      1|    if (!((xcr0 & cpuid_avx512_saved) == cpuid_avx512_saved)) {
  ------------------
  |  Branch (269:9): [True: 1, False: 0]
  ------------------
  270|      1|        return host_isa;
  271|      1|    }
  272|       |
  273|      0|    if (ebx & cpuid_avx512f_bit) {
  ------------------
  |  Branch (273:9): [True: 0, False: 0]
  ------------------
  274|      0|        host_isa |= CROARING_AVX512F;
  275|      0|    }
  276|       |
  277|      0|    if (ebx & cpuid_avx512bw_bit) {
  ------------------
  |  Branch (277:9): [True: 0, False: 0]
  ------------------
  278|      0|        host_isa |= CROARING_AVX512BW;
  279|      0|    }
  280|       |
  281|      0|    if (ebx & cpuid_avx512dq_bit) {
  ------------------
  |  Branch (281:9): [True: 0, False: 0]
  ------------------
  282|      0|        host_isa |= CROARING_AVX512DQ;
  283|      0|    }
  284|       |
  285|      0|    if (ecx & cpuid_avx512vbmi2_bit) {
  ------------------
  |  Branch (285:9): [True: 0, False: 0]
  ------------------
  286|      0|        host_isa |= CROARING_AVX512VBMI2;
  287|      0|    }
  288|       |
  289|      0|    if (ecx & cpuid_avx512bitalg_bit) {
  ------------------
  |  Branch (289:9): [True: 0, False: 0]
  ------------------
  290|      0|        host_isa |= CROARING_AVX512BITALG;
  291|      0|    }
  292|       |
  293|      0|    if (ecx & cpuid_avx512vpopcntdq_bit) {
  ------------------
  |  Branch (293:9): [True: 0, False: 0]
  ------------------
  294|      0|        host_isa |= CROARING_AVX512VPOPCNTDQ;
  295|      0|    }
  296|       |
  297|      0|    return host_isa;
  298|      1|}
isadetection.c:cpuid:
  157|      2|                         uint32_t *edx) {
  158|       |#if CROARING_REGULAR_VISUAL_STUDIO
  159|       |    int cpu_info[4];
  160|       |    __cpuidex(cpu_info, *eax, *ecx);
  161|       |    *eax = cpu_info[0];
  162|       |    *ebx = cpu_info[1];
  163|       |    *ecx = cpu_info[2];
  164|       |    *edx = cpu_info[3];
  165|       |#elif (defined(HAVE_GCC_GET_CPUID) && defined(USE_GCC_GET_CPUID)) || \
  166|       |    defined(__FILC__)
  167|       |    uint32_t level = *eax;
  168|       |    __get_cpuid(level, eax, ebx, ecx, edx);
  169|       |#else
  170|      2|    uint32_t a = *eax, b, c = *ecx, d;
  171|      2|    __asm__("cpuid\n\t" : "+a"(a), "=b"(b), "+c"(c), "=d"(d));
  172|      2|    *eax = a;
  173|      2|    *ebx = b;
  174|      2|    *ecx = c;
  175|      2|    *edx = d;
  176|      2|#endif
  177|      2|}
isadetection.c:xgetbv:
  179|      1|static inline uint64_t xgetbv(void) {
  180|       |#if defined(_MSC_VER)
  181|       |    return _xgetbv(0);
  182|       |#elif defined(__FILC__)
  183|       |    return zxgetbv();
  184|       |#else
  185|      1|    uint32_t xcr0_lo, xcr0_hi;
  186|      1|    __asm__("xgetbv\n\t" : "=a"(xcr0_lo), "=d"(xcr0_hi) : "c"(0));
  187|      1|    return xcr0_lo | ((uint64_t)xcr0_hi << 32);
  188|      1|#endif
  189|      1|}

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

roaring_bitmap_create_with_capacity:
   86|  28.3k|roaring_bitmap_t *roaring_bitmap_create_with_capacity(uint32_t cap) {
   87|  28.3k|    roaring_bitmap_t *ans =
   88|  28.3k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
   89|  28.3k|    if (!ans) {
  ------------------
  |  Branch (89:9): [True: 0, False: 28.3k]
  ------------------
   90|      0|        return NULL;
   91|      0|    }
   92|  28.3k|    bool is_ok = ra_init_with_capacity(&ans->high_low_container, cap);
   93|  28.3k|    if (!is_ok) {
  ------------------
  |  Branch (93:9): [True: 0, False: 28.3k]
  ------------------
   94|      0|        roaring_free(ans);
   95|      0|        return NULL;
   96|      0|    }
   97|  28.3k|    return ans;
   98|  28.3k|}
roaring_bitmap_init_with_capacity:
  100|  35.6k|bool roaring_bitmap_init_with_capacity(roaring_bitmap_t *r, uint32_t cap) {
  101|  35.6k|    return ra_init_with_capacity(&r->high_low_container, cap);
  102|  35.6k|}
roaring_bitmap_add_many:
  135|  21.3k|                             const uint32_t *vals) {
  136|  21.3k|    uint32_t val;
  137|  21.3k|    const uint32_t *start = vals;
  138|  21.3k|    const uint32_t *end = vals + n_args;
  139|  21.3k|    const uint32_t *current_val = start;
  140|       |
  141|  21.3k|    if (n_args == 0) {
  ------------------
  |  Branch (141:9): [True: 0, False: 21.3k]
  ------------------
  142|      0|        return;
  143|      0|    }
  144|       |
  145|  21.3k|    uint8_t typecode;
  146|  21.3k|    int idx;
  147|  21.3k|    container_t *container;
  148|  21.3k|    val = *current_val;
  149|  21.3k|    container = containerptr_roaring_bitmap_add(r, val, &typecode, &idx);
  150|  21.3k|    roaring_bulk_context_t context = {container, idx, (uint16_t)(val >> 16),
  151|  21.3k|                                      typecode};
  152|       |
  153|  8.93M|    for (; current_val != end; current_val++) {
  ------------------
  |  Branch (153:12): [True: 8.91M, False: 21.3k]
  ------------------
  154|  8.91M|        memcpy(&val, current_val, sizeof(val));
  155|  8.91M|        add_bulk_impl(r, &context, val);
  156|  8.91M|    }
  157|  21.3k|}
roaring_bitmap_add_range_closed:
  253|  2.73k|                                     uint32_t max) {
  254|  2.73k|    if (min > max) {
  ------------------
  |  Branch (254:9): [True: 0, False: 2.73k]
  ------------------
  255|      0|        return;
  256|      0|    }
  257|       |
  258|  2.73k|    roaring_array_t *ra = &r->high_low_container;
  259|       |
  260|  2.73k|    uint32_t min_key = min >> 16;
  261|  2.73k|    uint32_t max_key = max >> 16;
  262|       |
  263|  2.73k|    int32_t num_required_containers = max_key - min_key + 1;
  264|  2.73k|    int32_t suffix_length =
  265|  2.73k|        count_greater(ra->keys, ra->size, (uint16_t)max_key);
  266|  2.73k|    int32_t prefix_length =
  267|  2.73k|        count_less(ra->keys, ra->size - suffix_length, (uint16_t)min_key);
  268|  2.73k|    int32_t common_length = ra->size - prefix_length - suffix_length;
  269|       |
  270|  2.73k|    if (num_required_containers > common_length) {
  ------------------
  |  Branch (270:9): [True: 1.27k, False: 1.45k]
  ------------------
  271|  1.27k|        ra_shift_tail(ra, suffix_length,
  272|  1.27k|                      num_required_containers - common_length);
  273|  1.27k|    }
  274|       |
  275|  2.73k|    int32_t src = prefix_length + common_length - 1;
  276|  2.73k|    int32_t dst = ra->size - suffix_length - 1;
  277|  71.5k|    for (uint32_t key = max_key; key != min_key - 1;
  ------------------
  |  Branch (277:34): [True: 68.7k, False: 2.73k]
  ------------------
  278|  68.7k|         key--) {  // beware of min_key==0
  279|  68.7k|        uint32_t container_min = (min_key == key) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (279:34): [True: 2.73k, False: 66.0k]
  ------------------
  280|  68.7k|        uint32_t container_max = (max_key == key) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (280:34): [True: 2.73k, False: 66.0k]
  ------------------
  281|  68.7k|        container_t *new_container;
  282|  68.7k|        uint8_t new_type;
  283|       |
  284|  68.7k|        if (src >= 0 && ra->keys[src] == key) {
  ------------------
  |  Branch (284:13): [True: 68.7k, False: 0]
  |  Branch (284:25): [True: 3.13k, False: 65.6k]
  ------------------
  285|  3.13k|            ra_unshare_container_at_index(ra, (uint16_t)src);
  286|  3.13k|            new_container =
  287|  3.13k|                container_add_range(ra->containers[src], ra->typecodes[src],
  288|  3.13k|                                    container_min, container_max, &new_type);
  289|  3.13k|            if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (289:17): [True: 2.10k, False: 1.02k]
  ------------------
  290|  2.10k|                container_free(ra->containers[src], ra->typecodes[src]);
  291|  2.10k|            }
  292|  3.13k|            src--;
  293|  65.6k|        } else {
  294|  65.6k|            new_container = container_from_range(&new_type, container_min,
  295|  65.6k|                                                 container_max + 1, 1);
  296|  65.6k|        }
  297|  68.7k|        ra_replace_key_and_container_at_index(ra, dst, (uint16_t)key,
  298|  68.7k|                                              new_container, new_type);
  299|  68.7k|        dst--;
  300|  68.7k|    }
  301|  2.73k|}
roaring_bitmap_remove_range_closed:
  304|  8.05k|                                        uint32_t max) {
  305|  8.05k|    if (min > max) {
  ------------------
  |  Branch (305:9): [True: 787, False: 7.26k]
  ------------------
  306|    787|        return;
  307|    787|    }
  308|       |
  309|  7.26k|    roaring_array_t *ra = &r->high_low_container;
  310|       |
  311|  7.26k|    uint32_t min_key = min >> 16;
  312|  7.26k|    uint32_t max_key = max >> 16;
  313|       |
  314|  7.26k|    int32_t src = count_less(ra->keys, ra->size, (uint16_t)min_key);
  315|  7.26k|    int32_t dst = src;
  316|  27.8k|    while (src < ra->size && ra->keys[src] <= max_key) {
  ------------------
  |  Branch (316:12): [True: 22.7k, False: 5.10k]
  |  Branch (316:30): [True: 20.5k, False: 2.16k]
  ------------------
  317|  20.5k|        uint32_t container_min =
  318|  20.5k|            (min_key == ra->keys[src]) ? (min & 0xffff) : 0;
  ------------------
  |  Branch (318:13): [True: 6.92k, False: 13.6k]
  ------------------
  319|  20.5k|        uint32_t container_max =
  320|  20.5k|            (max_key == ra->keys[src]) ? (max & 0xffff) : 0xffff;
  ------------------
  |  Branch (320:13): [True: 6.53k, False: 14.0k]
  ------------------
  321|  20.5k|        ra_unshare_container_at_index(ra, (uint16_t)src);
  322|  20.5k|        container_t *new_container;
  323|  20.5k|        uint8_t new_type;
  324|  20.5k|        new_container =
  325|  20.5k|            container_remove_range(ra->containers[src], ra->typecodes[src],
  326|  20.5k|                                   container_min, container_max, &new_type);
  327|  20.5k|        if (new_container != ra->containers[src]) {
  ------------------
  |  Branch (327:13): [True: 13.7k, False: 6.81k]
  ------------------
  328|  13.7k|            container_free(ra->containers[src], ra->typecodes[src]);
  329|  13.7k|        }
  330|  20.5k|        if (new_container) {
  ------------------
  |  Branch (330:13): [True: 7.08k, False: 13.4k]
  ------------------
  331|  7.08k|            ra_replace_key_and_container_at_index(ra, dst, ra->keys[src],
  332|  7.08k|                                                  new_container, new_type);
  333|  7.08k|            dst++;
  334|  7.08k|        }
  335|  20.5k|        src++;
  336|  20.5k|    }
  337|  7.26k|    if (src > dst) {
  ------------------
  |  Branch (337:9): [True: 628, False: 6.64k]
  ------------------
  338|    628|        ra_shift_tail(ra, ra->size - src, dst - src);
  339|    628|    }
  340|  7.26k|}
roaring_bitmap_copy:
  526|    120|roaring_bitmap_t *roaring_bitmap_copy(const roaring_bitmap_t *r) {
  527|    120|    roaring_bitmap_t *ans =
  528|    120|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
  529|    120|    if (!ans) {
  ------------------
  |  Branch (529:9): [True: 0, False: 120]
  ------------------
  530|      0|        return NULL;
  531|      0|    }
  532|    120|    if (!ra_init_with_capacity(  // allocation of list of containers can fail
  ------------------
  |  Branch (532:9): [True: 0, False: 120]
  ------------------
  533|    120|            &ans->high_low_container, r->high_low_container.size)) {
  534|      0|        roaring_free(ans);
  535|      0|        return NULL;
  536|      0|    }
  537|    120|    if (!ra_overwrite(  // memory allocation of individual containers may fail
  ------------------
  |  Branch (537:9): [True: 0, False: 120]
  ------------------
  538|    120|            &r->high_low_container, &ans->high_low_container, is_cow(r))) {
  539|      0|        roaring_bitmap_free(ans);  // overwrite should leave in freeable state
  540|      0|        return NULL;
  541|      0|    }
  542|    120|    roaring_bitmap_set_copy_on_write(ans, is_cow(r));
  543|    120|    return ans;
  544|    120|}
roaring_bitmap_overwrite:
  547|  16.1k|                              const roaring_bitmap_t *src) {
  548|  16.1k|    if (dest == src) return true;
  ------------------
  |  Branch (548:9): [True: 0, False: 16.1k]
  ------------------
  549|       |    // ra_overwrite() frees dest's containers, shared or not. Setting the flag
  550|       |    // with roaring_bitmap_set_copy_on_write() would first copy the shared ones.
  551|  16.1k|    if (is_cow(src)) {
  ------------------
  |  Branch (551:9): [True: 0, False: 16.1k]
  ------------------
  552|      0|        dest->high_low_container.flags |= ROARING_FLAG_COW;
  ------------------
  |  |   46|      0|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  553|  16.1k|    } else {
  554|       |        dest->high_low_container.flags &= ~ROARING_FLAG_COW;
  ------------------
  |  |   46|  16.1k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
  555|  16.1k|    }
  556|  16.1k|    return ra_overwrite(&src->high_low_container, &dest->high_low_container,
  557|  16.1k|                        is_cow(src));
  558|  16.1k|}
roaring_bitmap_clear:
  570|  71.2k|void roaring_bitmap_clear(roaring_bitmap_t *r) {
  571|  71.2k|    ra_reset(&r->high_low_container);
  572|  71.2k|}
roaring_bitmap_add:
  574|  7.12k|void roaring_bitmap_add(roaring_bitmap_t *r, uint32_t val) {
  575|  7.12k|    roaring_array_t *ra = &r->high_low_container;
  576|       |
  577|  7.12k|    const uint16_t hb = val >> 16;
  578|  7.12k|    const int i = ra_get_index(ra, hb);
  579|  7.12k|    uint8_t typecode;
  580|  7.12k|    if (i >= 0) {
  ------------------
  |  Branch (580:9): [True: 5.52k, False: 1.60k]
  ------------------
  581|  5.52k|        ra_unshare_container_at_index(ra, (uint16_t)i);
  582|  5.52k|        container_t *container =
  583|  5.52k|            ra_get_container_at_index(ra, (uint16_t)i, &typecode);
  584|  5.52k|        uint8_t newtypecode = typecode;
  585|  5.52k|        container_t *container2 =
  586|  5.52k|            container_add(container, val & 0xFFFF, typecode, &newtypecode);
  587|  5.52k|        if (container2 != container) {
  ------------------
  |  Branch (587:13): [True: 0, False: 5.52k]
  ------------------
  588|      0|            container_free(container, typecode);
  589|      0|            ra_set_container_at_index(&r->high_low_container, i, container2,
  590|      0|                                      newtypecode);
  591|      0|        }
  592|  5.52k|    } else {
  593|  1.60k|        array_container_t *newac = array_container_create();
  594|  1.60k|        container_t *container =
  595|  1.60k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.60k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  596|       |        // we could just assume that it stays an array container
  597|  1.60k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  598|  1.60k|                                   container, typecode);
  599|  1.60k|    }
  600|  7.12k|}
roaring_bitmap_add_checked:
  602|  7.12k|bool roaring_bitmap_add_checked(roaring_bitmap_t *r, uint32_t val) {
  603|  7.12k|    const uint16_t hb = val >> 16;
  604|  7.12k|    const int i = ra_get_index(&r->high_low_container, hb);
  605|  7.12k|    uint8_t typecode;
  606|  7.12k|    bool result = false;
  607|  7.12k|    if (i >= 0) {
  ------------------
  |  Branch (607:9): [True: 5.56k, False: 1.56k]
  ------------------
  608|  5.56k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  609|  5.56k|        container_t *container = ra_get_container_at_index(
  610|  5.56k|            &r->high_low_container, (uint16_t)i, &typecode);
  611|       |
  612|  5.56k|        const int oldCardinality =
  613|  5.56k|            container_get_cardinality(container, typecode);
  614|       |
  615|  5.56k|        uint8_t newtypecode = typecode;
  616|  5.56k|        container_t *container2 =
  617|  5.56k|            container_add(container, val & 0xFFFF, typecode, &newtypecode);
  618|  5.56k|        if (container2 != container) {
  ------------------
  |  Branch (618:13): [True: 0, False: 5.56k]
  ------------------
  619|      0|            container_free(container, typecode);
  620|      0|            ra_set_container_at_index(&r->high_low_container, i, container2,
  621|      0|                                      newtypecode);
  622|      0|            result = true;
  623|  5.56k|        } else {
  624|  5.56k|            const int newCardinality =
  625|  5.56k|                container_get_cardinality(container, newtypecode);
  626|       |
  627|  5.56k|            result = oldCardinality != newCardinality;
  628|  5.56k|        }
  629|  5.56k|    } else {
  630|  1.56k|        array_container_t *newac = array_container_create();
  631|  1.56k|        container_t *container =
  632|  1.56k|            container_add(newac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, &typecode);
  ------------------
  |  |   49|  1.56k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  633|       |        // we could just assume that it stays an array container
  634|  1.56k|        ra_insert_new_key_value_at(&r->high_low_container, -i - 1, hb,
  635|  1.56k|                                   container, typecode);
  636|  1.56k|        result = true;
  637|  1.56k|    }
  638|       |
  639|  7.12k|    return result;
  640|  7.12k|}
roaring_bitmap_remove:
  642|  7.12k|void roaring_bitmap_remove(roaring_bitmap_t *r, uint32_t val) {
  643|  7.12k|    const uint16_t hb = val >> 16;
  644|  7.12k|    const int i = ra_get_index(&r->high_low_container, hb);
  645|  7.12k|    uint8_t typecode;
  646|  7.12k|    if (i >= 0) {
  ------------------
  |  Branch (646:9): [True: 6.48k, False: 640]
  ------------------
  647|  6.48k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  648|  6.48k|        container_t *container = ra_get_container_at_index(
  649|  6.48k|            &r->high_low_container, (uint16_t)i, &typecode);
  650|  6.48k|        uint8_t newtypecode = typecode;
  651|  6.48k|        container_t *container2 =
  652|  6.48k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  653|  6.48k|        if (container2 != container) {
  ------------------
  |  Branch (653:13): [True: 9, False: 6.47k]
  ------------------
  654|      9|            container_free(container, typecode);
  655|      9|            ra_set_container_at_index(&r->high_low_container, i, container2,
  656|      9|                                      newtypecode);
  657|      9|        }
  658|  6.48k|        if (container_nonzero_cardinality(container2, newtypecode)) {
  ------------------
  |  Branch (658:13): [True: 6.43k, False: 56]
  ------------------
  659|  6.43k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  660|  6.43k|                                      newtypecode);
  661|  6.43k|        } else {
  662|     56|            ra_remove_at_index_and_free(&r->high_low_container, i);
  663|     56|        }
  664|  6.48k|    }
  665|  7.12k|}
roaring_bitmap_remove_checked:
  667|  7.12k|bool roaring_bitmap_remove_checked(roaring_bitmap_t *r, uint32_t val) {
  668|  7.12k|    const uint16_t hb = val >> 16;
  669|  7.12k|    const int i = ra_get_index(&r->high_low_container, hb);
  670|  7.12k|    uint8_t typecode;
  671|  7.12k|    bool result = false;
  672|  7.12k|    if (i >= 0) {
  ------------------
  |  Branch (672:9): [True: 6.57k, False: 556]
  ------------------
  673|  6.57k|        ra_unshare_container_at_index(&r->high_low_container, (uint16_t)i);
  674|  6.57k|        container_t *container = ra_get_container_at_index(
  675|  6.57k|            &r->high_low_container, (uint16_t)i, &typecode);
  676|       |
  677|  6.57k|        const int oldCardinality =
  678|  6.57k|            container_get_cardinality(container, typecode);
  679|       |
  680|  6.57k|        uint8_t newtypecode = typecode;
  681|  6.57k|        container_t *container2 =
  682|  6.57k|            container_remove(container, val & 0xFFFF, typecode, &newtypecode);
  683|  6.57k|        if (container2 != container) {
  ------------------
  |  Branch (683:13): [True: 6, False: 6.56k]
  ------------------
  684|      6|            container_free(container, typecode);
  685|      6|            ra_set_container_at_index(&r->high_low_container, i, container2,
  686|      6|                                      newtypecode);
  687|      6|        }
  688|       |
  689|  6.57k|        const int newCardinality =
  690|  6.57k|            container_get_cardinality(container2, newtypecode);
  691|       |
  692|  6.57k|        if (newCardinality != 0) {
  ------------------
  |  Branch (692:13): [True: 6.55k, False: 16]
  ------------------
  693|  6.55k|            ra_set_container_at_index(&r->high_low_container, i, container2,
  694|  6.55k|                                      newtypecode);
  695|  6.55k|        } else {
  696|     16|            ra_remove_at_index_and_free(&r->high_low_container, i);
  697|     16|        }
  698|       |
  699|  6.57k|        result = oldCardinality != newCardinality;
  700|  6.57k|    }
  701|  7.12k|    return result;
  702|  7.12k|}
roaring_bitmap_and:
  744|  7.12k|                                     const roaring_bitmap_t *x2) {
  745|  7.12k|    uint8_t result_type = 0;
  746|  7.12k|    const int length1 = x1->high_low_container.size,
  747|  7.12k|              length2 = x2->high_low_container.size;
  748|  7.12k|    uint32_t neededcap = length1 > length2 ? length2 : length1;
  ------------------
  |  Branch (748:26): [True: 40, False: 7.08k]
  ------------------
  749|  7.12k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(neededcap);
  750|  7.12k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (750:46): [True: 0, False: 7.12k]
  |  Branch (750:60): [True: 0, False: 7.12k]
  ------------------
  751|       |
  752|  7.12k|    int pos1 = 0, pos2 = 0;
  753|       |
  754|  14.2k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (754:12): [True: 7.12k, False: 7.08k]
  |  Branch (754:30): [True: 7.08k, False: 40]
  ------------------
  755|  7.08k|        const uint16_t s1 =
  756|  7.08k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  757|  7.08k|        const uint16_t s2 =
  758|  7.08k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  759|       |
  760|  7.08k|        if (s1 == s2) {
  ------------------
  |  Branch (760:13): [True: 7.01k, False: 74]
  ------------------
  761|  7.01k|            uint8_t type1, type2;
  762|  7.01k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  763|  7.01k|                                                        (uint16_t)pos1, &type1);
  764|  7.01k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  765|  7.01k|                                                        (uint16_t)pos2, &type2);
  766|  7.01k|            container_t *c = container_and(c1, type1, c2, type2, &result_type);
  767|       |
  768|  7.01k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (768:17): [True: 6.70k, False: 311]
  ------------------
  769|  6.70k|                ra_append(&answer->high_low_container, s1, c, result_type);
  770|  6.70k|            } else {
  771|    311|                container_free(c, result_type);  // otherwise: memory leak!
  772|    311|            }
  773|  7.01k|            ++pos1;
  774|  7.01k|            ++pos2;
  775|  7.01k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (775:20): [True: 74, False: 0]
  ------------------
  776|     74|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
  777|     74|        } else {  // s1 > s2
  778|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  779|      0|        }
  780|  7.08k|    }
  781|  7.12k|    return answer;
  782|  7.12k|}
roaring_bitmap_and_inplace:
  826|  7.12k|                                const roaring_bitmap_t *x2) {
  827|  7.12k|    if (x1 == x2) return;
  ------------------
  |  Branch (827:9): [True: 0, False: 7.12k]
  ------------------
  828|  7.12k|    int pos1 = 0, pos2 = 0, intersection_size = 0;
  829|  7.12k|    const int length1 = ra_get_size(&x1->high_low_container);
  830|  7.12k|    const int length2 = ra_get_size(&x2->high_low_container);
  831|       |
  832|       |    // any skipped-over or newly emptied containers in x1
  833|       |    // have to be freed.
  834|  69.5k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (834:12): [True: 62.4k, False: 7.08k]
  |  Branch (834:30): [True: 62.4k, False: 40]
  ------------------
  835|  62.4k|        const uint16_t s1 =
  836|  62.4k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  837|  62.4k|        const uint16_t s2 =
  838|  62.4k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  839|       |
  840|  62.4k|        if (s1 == s2) {
  ------------------
  |  Branch (840:13): [True: 62.3k, False: 74]
  ------------------
  841|  62.3k|            uint8_t type1, type2, result_type;
  842|  62.3k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  843|  62.3k|                                                        (uint16_t)pos1, &type1);
  844|  62.3k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  845|  62.3k|                                                        (uint16_t)pos2, &type2);
  846|       |
  847|       |            // We do the computation "in place" only when c1 is not a shared
  848|       |            // container. Rationale: using a shared container safely with in
  849|       |            // place computation would require making a copy and then doing the
  850|       |            // computation in place which is likely less efficient than avoiding
  851|       |            // in place entirely and always generating a new container.
  852|  62.3k|            container_t *c =
  853|  62.3k|                (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  62.3k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (853:17): [True: 0, False: 62.3k]
  ------------------
  854|  62.3k|                    ? container_and(c1, type1, c2, type2, &result_type)
  855|  62.3k|                    : container_iand(c1, type1, c2, type2, &result_type);
  856|       |
  857|  62.3k|            if (c != c1) {  // in this instance a new container was created, and
  ------------------
  |  Branch (857:17): [True: 55.1k, False: 7.18k]
  ------------------
  858|       |                            // we need to free the old one
  859|  55.1k|                container_free(c1, type1);
  860|  55.1k|            }
  861|  62.3k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (861:17): [True: 62.3k, False: 0]
  ------------------
  862|  62.3k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
  863|  62.3k|                                                      intersection_size, s1, c,
  864|  62.3k|                                                      result_type);
  865|  62.3k|                intersection_size++;
  866|  62.3k|            } else {
  867|      0|                container_free(c, result_type);
  868|      0|            }
  869|  62.3k|            ++pos1;
  870|  62.3k|            ++pos2;
  871|  62.3k|        } else if (s1 < s2) {
  ------------------
  |  Branch (871:20): [True: 74, False: 0]
  ------------------
  872|     74|            pos1 = ra_advance_until_freeing(&x1->high_low_container, s2, pos1);
  873|     74|        } else {  // s1 > s2
  874|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
  875|      0|        }
  876|  62.4k|    }
  877|       |
  878|       |    // if we ended early because x2 ran out, then all remaining in x1 should be
  879|       |    // freed
  880|  7.16k|    while (pos1 < length1) {
  ------------------
  |  Branch (880:12): [True: 40, False: 7.12k]
  ------------------
  881|     40|        container_free(x1->high_low_container.containers[pos1],
  882|     40|                       x1->high_low_container.typecodes[pos1]);
  883|     40|        ++pos1;
  884|     40|    }
  885|       |
  886|       |    // all containers after this have either been copied or freed
  887|  7.12k|    ra_downsize(&x1->high_low_container, intersection_size);
  888|  7.12k|}
roaring_bitmap_or:
  891|  7.12k|                                    const roaring_bitmap_t *x2) {
  892|  7.12k|    uint8_t result_type = 0;
  893|  7.12k|    const int length1 = x1->high_low_container.size,
  894|  7.12k|              length2 = x2->high_low_container.size;
  895|  7.12k|    if (0 == length1) {
  ------------------
  |  Branch (895:9): [True: 0, False: 7.12k]
  ------------------
  896|      0|        return roaring_bitmap_copy(x2);
  897|      0|    }
  898|  7.12k|    if (0 == length2) {
  ------------------
  |  Branch (898:9): [True: 40, False: 7.08k]
  ------------------
  899|     40|        return roaring_bitmap_copy(x1);
  900|     40|    }
  901|  7.08k|    roaring_bitmap_t *answer =
  902|  7.08k|        roaring_bitmap_create_with_capacity(length1 + length2);
  903|  7.08k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (903:46): [True: 0, False: 7.08k]
  |  Branch (903:60): [True: 0, False: 7.08k]
  ------------------
  904|  7.08k|    int pos1 = 0, pos2 = 0;
  905|  7.08k|    uint8_t type1, type2;
  906|  7.08k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  907|  7.08k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  908|  7.08k|    while (true) {
  ------------------
  |  Branch (908:12): [True: 7.08k, Folded]
  ------------------
  909|  7.08k|        if (s1 == s2) {
  ------------------
  |  Branch (909:13): [True: 7.01k, False: 74]
  ------------------
  910|  7.01k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  911|  7.01k|                                                        (uint16_t)pos1, &type1);
  912|  7.01k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  913|  7.01k|                                                        (uint16_t)pos2, &type2);
  914|  7.01k|            container_t *c = container_or(c1, type1, c2, type2, &result_type);
  915|       |
  916|       |            // since we assume that the initial containers are non-empty, the
  917|       |            // result here
  918|       |            // can only be non-empty
  919|  7.01k|            ra_append(&answer->high_low_container, s1, c, result_type);
  920|  7.01k|            ++pos1;
  921|  7.01k|            ++pos2;
  922|  7.01k|            if (pos1 == length1) break;
  ------------------
  |  Branch (922:17): [True: 7.01k, False: 0]
  ------------------
  923|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (923:17): [True: 0, False: 0]
  ------------------
  924|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  925|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  926|       |
  927|     74|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (927:20): [True: 74, False: 0]
  ------------------
  928|     74|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
  929|     74|                                                        (uint16_t)pos1, &type1);
  930|       |            // c1 = container_clone(c1, type1);
  931|     74|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
  932|     74|            if (is_cow(x1)) {
  ------------------
  |  Branch (932:17): [True: 0, False: 74]
  ------------------
  933|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
  934|      0|                                          type1);
  935|      0|            }
  936|     74|            ra_append(&answer->high_low_container, s1, c1, type1);
  937|     74|            pos1++;
  938|     74|            if (pos1 == length1) break;
  ------------------
  |  Branch (938:17): [True: 74, False: 0]
  ------------------
  939|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
  940|       |
  941|      0|        } else {  // s1 > s2
  942|      0|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
  943|      0|                                                        (uint16_t)pos2, &type2);
  944|       |            // c2 = container_clone(c2, type2);
  945|      0|            c2 = get_copy_of_container(c2, &type2, is_cow(x2));
  946|      0|            if (is_cow(x2)) {
  ------------------
  |  Branch (946:17): [True: 0, False: 0]
  ------------------
  947|      0|                ra_set_container_at_index(&x2->high_low_container, pos2, c2,
  948|      0|                                          type2);
  949|      0|            }
  950|      0|            ra_append(&answer->high_low_container, s2, c2, type2);
  951|      0|            pos2++;
  952|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (952:17): [True: 0, False: 0]
  ------------------
  953|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
  954|      0|        }
  955|  7.08k|    }
  956|  7.08k|    if (pos1 == length1) {
  ------------------
  |  Branch (956:9): [True: 7.08k, False: 0]
  ------------------
  957|  7.08k|        ra_append_copy_range(&answer->high_low_container,
  958|  7.08k|                             &x2->high_low_container, pos2, length2,
  959|  7.08k|                             is_cow(x2));
  960|  7.08k|    } else if (pos2 == length2) {
  ------------------
  |  Branch (960:16): [True: 0, False: 0]
  ------------------
  961|      0|        ra_append_copy_range(&answer->high_low_container,
  962|      0|                             &x1->high_low_container, pos1, length1,
  963|      0|                             is_cow(x1));
  964|      0|    }
  965|  7.08k|    return answer;
  966|  7.12k|}
roaring_bitmap_or_inplace:
 1147|  7.12k|                               const roaring_bitmap_t *x2) {
 1148|  7.12k|    if (x1 == x2) return;
  ------------------
  |  Branch (1148:9): [True: 0, False: 7.12k]
  ------------------
 1149|  7.12k|    uint8_t result_type = 0;
 1150|  7.12k|    int length1 = x1->high_low_container.size;
 1151|  7.12k|    const int length2 = x2->high_low_container.size;
 1152|       |
 1153|  7.12k|    if (0 == length2) return;
  ------------------
  |  Branch (1153:9): [True: 0, False: 7.12k]
  ------------------
 1154|       |
 1155|  7.12k|    if (0 == length1) {
  ------------------
  |  Branch (1155:9): [True: 0, False: 7.12k]
  ------------------
 1156|      0|        roaring_bitmap_overwrite(x1, x2);
 1157|      0|        return;
 1158|      0|    }
 1159|       |    // Merging would visit all the containers of x1.
 1160|  7.12k|    if ((int64_t)length2 * 32 < length1) {
  ------------------
  |  Branch (1160:9): [True: 0, False: 7.12k]
  ------------------
 1161|      0|        roaring_inplace_union_few(x1, x2);
 1162|      0|        return;
 1163|      0|    }
 1164|  7.12k|    int pos1 = 0, pos2 = 0;
 1165|  7.12k|    uint8_t type1, type2;
 1166|  7.12k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1167|  7.12k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1168|  7.12k|    while (true) {
  ------------------
  |  Branch (1168:12): [True: 7.12k, Folded]
  ------------------
 1169|  7.12k|        if (s1 == s2) {
  ------------------
  |  Branch (1169:13): [True: 7.12k, False: 0]
  ------------------
 1170|  7.12k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1171|  7.12k|                                                        (uint16_t)pos1, &type1);
 1172|  7.12k|            if (!container_is_full(c1, type1)) {
  ------------------
  |  Branch (1172:17): [True: 7.12k, False: 0]
  ------------------
 1173|  7.12k|                container_t *c2 = ra_get_container_at_index(
 1174|  7.12k|                    &x2->high_low_container, (uint16_t)pos2, &type2);
 1175|  7.12k|                container_t *c =
 1176|  7.12k|                    (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|  7.12k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1176:21): [True: 0, False: 7.12k]
  ------------------
 1177|  7.12k|                        ? container_or(c1, type1, c2, type2, &result_type)
 1178|  7.12k|                        : container_ior(c1, type1, c2, type2, &result_type);
 1179|       |
 1180|  7.12k|                if (c != c1) {  // in this instance a new container was created,
  ------------------
  |  Branch (1180:21): [True: 5.53k, False: 1.59k]
  ------------------
 1181|       |                                // and we need to free the old one
 1182|  5.53k|                    container_free(c1, type1);
 1183|  5.53k|                }
 1184|  7.12k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
 1185|  7.12k|                                          result_type);
 1186|  7.12k|            }
 1187|  7.12k|            ++pos1;
 1188|  7.12k|            ++pos2;
 1189|  7.12k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1189:17): [True: 7.12k, False: 0]
  ------------------
 1190|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1190:17): [True: 0, False: 0]
  ------------------
 1191|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1192|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1193|       |
 1194|      0|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1194:20): [True: 0, False: 0]
  ------------------
 1195|      0|            pos1++;
 1196|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1196:17): [True: 0, False: 0]
  ------------------
 1197|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1198|       |
 1199|      0|        } else {  // s1 > s2
 1200|      0|            roaring_inplace_merge_bulk(x1, x2, pos1, pos1, pos2, false);
 1201|      0|            return;
 1202|      0|        }
 1203|  7.12k|    }
 1204|  7.12k|    if (pos1 == length1) {
  ------------------
  |  Branch (1204:9): [True: 7.12k, False: 0]
  ------------------
 1205|  7.12k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1206|  7.12k|                             pos2, length2, is_cow(x2));
 1207|  7.12k|    }
 1208|  7.12k|}
roaring_bitmap_xor:
 1211|  7.12k|                                     const roaring_bitmap_t *x2) {
 1212|  7.12k|    uint8_t result_type = 0;
 1213|  7.12k|    const int length1 = x1->high_low_container.size,
 1214|  7.12k|              length2 = x2->high_low_container.size;
 1215|  7.12k|    if (0 == length1) {
  ------------------
  |  Branch (1215:9): [True: 0, False: 7.12k]
  ------------------
 1216|      0|        return roaring_bitmap_copy(x2);
 1217|      0|    }
 1218|  7.12k|    if (0 == length2) {
  ------------------
  |  Branch (1218:9): [True: 40, False: 7.08k]
  ------------------
 1219|     40|        return roaring_bitmap_copy(x1);
 1220|     40|    }
 1221|  7.08k|    roaring_bitmap_t *answer =
 1222|  7.08k|        roaring_bitmap_create_with_capacity(length1 + length2);
 1223|  7.08k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1223:46): [True: 0, False: 7.08k]
  |  Branch (1223:60): [True: 0, False: 7.08k]
  ------------------
 1224|  7.08k|    int pos1 = 0, pos2 = 0;
 1225|  7.08k|    uint8_t type1, type2;
 1226|  7.08k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1227|  7.08k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1228|  7.08k|    while (true) {
  ------------------
  |  Branch (1228:12): [True: 7.08k, Folded]
  ------------------
 1229|  7.08k|        if (s1 == s2) {
  ------------------
  |  Branch (1229:13): [True: 7.01k, False: 74]
  ------------------
 1230|  7.01k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1231|  7.01k|                                                        (uint16_t)pos1, &type1);
 1232|  7.01k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1233|  7.01k|                                                        (uint16_t)pos2, &type2);
 1234|  7.01k|            container_t *c = container_xor(c1, type1, c2, type2, &result_type);
 1235|       |
 1236|  7.01k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1236:17): [True: 7.00k, False: 14]
  ------------------
 1237|  7.00k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1238|  7.00k|            } else {
 1239|     14|                container_free(c, result_type);
 1240|     14|            }
 1241|  7.01k|            ++pos1;
 1242|  7.01k|            ++pos2;
 1243|  7.01k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1243:17): [True: 7.01k, False: 0]
  ------------------
 1244|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1244:17): [True: 0, False: 0]
  ------------------
 1245|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1246|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1247|       |
 1248|     74|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1248:20): [True: 74, False: 0]
  ------------------
 1249|     74|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1250|     74|                                                        (uint16_t)pos1, &type1);
 1251|     74|            c1 = get_copy_of_container(c1, &type1, is_cow(x1));
 1252|     74|            if (is_cow(x1)) {
  ------------------
  |  Branch (1252:17): [True: 0, False: 74]
  ------------------
 1253|      0|                ra_set_container_at_index(&x1->high_low_container, pos1, c1,
 1254|      0|                                          type1);
 1255|      0|            }
 1256|     74|            ra_append(&answer->high_low_container, s1, c1, type1);
 1257|     74|            pos1++;
 1258|     74|            if (pos1 == length1) break;
  ------------------
  |  Branch (1258:17): [True: 74, False: 0]
  ------------------
 1259|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1260|       |
 1261|      0|        } else {  // s1 > s2
 1262|      0|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1263|      0|                                                        (uint16_t)pos2, &type2);
 1264|      0|            c2 = get_copy_of_container(c2, &type2, is_cow(x2));
 1265|      0|            if (is_cow(x2)) {
  ------------------
  |  Branch (1265:17): [True: 0, False: 0]
  ------------------
 1266|      0|                ra_set_container_at_index(&x2->high_low_container, pos2, c2,
 1267|      0|                                          type2);
 1268|      0|            }
 1269|      0|            ra_append(&answer->high_low_container, s2, c2, type2);
 1270|      0|            pos2++;
 1271|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1271:17): [True: 0, False: 0]
  ------------------
 1272|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1273|      0|        }
 1274|  7.08k|    }
 1275|  7.08k|    if (pos1 == length1) {
  ------------------
  |  Branch (1275:9): [True: 7.08k, False: 0]
  ------------------
 1276|  7.08k|        ra_append_copy_range(&answer->high_low_container,
 1277|  7.08k|                             &x2->high_low_container, pos2, length2,
 1278|  7.08k|                             is_cow(x2));
 1279|  7.08k|    } else if (pos2 == length2) {
  ------------------
  |  Branch (1279:16): [True: 0, False: 0]
  ------------------
 1280|      0|        ra_append_copy_range(&answer->high_low_container,
 1281|      0|                             &x1->high_low_container, pos1, length1,
 1282|      0|                             is_cow(x1));
 1283|      0|    }
 1284|  7.08k|    return answer;
 1285|  7.12k|}
roaring_bitmap_xor_inplace:
 1290|  7.12k|                                const roaring_bitmap_t *x2) {
 1291|  7.12k|    if (x1 == x2) {  // empty, keeping the capacity
  ------------------
  |  Branch (1291:9): [True: 0, False: 7.12k]
  ------------------
 1292|      0|        ra_clear_containers(&x1->high_low_container);
 1293|      0|        x1->high_low_container.size = 0;
 1294|      0|        return;
 1295|      0|    }
 1296|  7.12k|    uint8_t result_type = 0;
 1297|  7.12k|    int length1 = x1->high_low_container.size;
 1298|  7.12k|    const int length2 = x2->high_low_container.size;
 1299|       |
 1300|  7.12k|    if (0 == length2) return;
  ------------------
  |  Branch (1300:9): [True: 12, False: 7.11k]
  ------------------
 1301|       |
 1302|  7.11k|    if (0 == length1) {
  ------------------
  |  Branch (1302:9): [True: 1.90k, False: 5.21k]
  ------------------
 1303|  1.90k|        roaring_bitmap_overwrite(x1, x2);
 1304|  1.90k|        return;
 1305|  1.90k|    }
 1306|       |
 1307|       |    // XOR can have new containers inserted from x2, but can also
 1308|       |    // lose containers when x1 and x2 are nonempty and identical.
 1309|       |
 1310|  5.21k|    int pos1 = 0, pos2 = 0;
 1311|  5.21k|    uint8_t type1, type2;
 1312|  5.21k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1313|  5.21k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1314|  7.32k|    while (true) {
  ------------------
  |  Branch (1314:12): [True: 7.32k, Folded]
  ------------------
 1315|  7.32k|        if (s1 == s2) {
  ------------------
  |  Branch (1315:13): [True: 7.22k, False: 97]
  ------------------
 1316|  7.22k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1317|  7.22k|                                                        (uint16_t)pos1, &type1);
 1318|  7.22k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1319|  7.22k|                                                        (uint16_t)pos2, &type2);
 1320|       |
 1321|       |            // We do the computation "in place" only when c1 is not a shared
 1322|       |            // container. Rationale: using a shared container safely with in
 1323|       |            // place computation would require making a copy and then doing the
 1324|       |            // computation in place which is likely less efficient than avoiding
 1325|       |            // in place entirely and always generating a new container.
 1326|       |
 1327|  7.22k|            container_t *c;
 1328|  7.22k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  7.22k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1328:17): [True: 0, False: 7.22k]
  ------------------
 1329|      0|                c = container_xor(c1, type1, c2, type2, &result_type);
 1330|      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)
  |  |  ------------------
  ------------------
 1331|  7.22k|            } else {
 1332|  7.22k|                c = container_ixor(c1, type1, c2, type2, &result_type);
 1333|  7.22k|            }
 1334|       |
 1335|  7.22k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1335:17): [True: 4.89k, False: 2.32k]
  ------------------
 1336|  4.89k|                ra_set_container_at_index(&x1->high_low_container, pos1, c,
 1337|  4.89k|                                          result_type);
 1338|  4.89k|                ++pos1;
 1339|  4.89k|            } else {
 1340|  2.32k|                container_free(c, result_type);
 1341|  2.32k|                roaring_inplace_merge_bulk(x1, x2, pos1, pos1 + 1, pos2 + 1,
 1342|  2.32k|                                           true);
 1343|  2.32k|                return;
 1344|  2.32k|            }
 1345|       |
 1346|  4.89k|            ++pos2;
 1347|  4.89k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1347:17): [True: 2.79k, False: 2.10k]
  ------------------
 1348|  2.10k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1348:17): [True: 0, False: 2.10k]
  ------------------
 1349|  2.10k|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1350|  2.10k|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1351|       |
 1352|  2.10k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1352:20): [True: 0, False: 97]
  ------------------
 1353|      0|            pos1++;
 1354|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1354:17): [True: 0, False: 0]
  ------------------
 1355|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1356|       |
 1357|     97|        } else {  // s1 > s2
 1358|     97|            roaring_inplace_merge_bulk(x1, x2, pos1, pos1, pos2, true);
 1359|     97|            return;
 1360|     97|        }
 1361|  7.32k|    }
 1362|  2.79k|    if (pos1 == length1) {
  ------------------
  |  Branch (1362:9): [True: 2.79k, False: 0]
  ------------------
 1363|  2.79k|        ra_append_copy_range(&x1->high_low_container, &x2->high_low_container,
 1364|  2.79k|                             pos2, length2, is_cow(x2));
 1365|  2.79k|    }
 1366|  2.79k|}
roaring_bitmap_andnot:
 1369|  7.12k|                                        const roaring_bitmap_t *x2) {
 1370|  7.12k|    uint8_t result_type = 0;
 1371|  7.12k|    const int length1 = x1->high_low_container.size,
 1372|  7.12k|              length2 = x2->high_low_container.size;
 1373|  7.12k|    if (0 == length1) {
  ------------------
  |  Branch (1373:9): [True: 0, False: 7.12k]
  ------------------
 1374|      0|        roaring_bitmap_t *empty_bitmap = roaring_bitmap_create();
 1375|      0|        roaring_bitmap_set_copy_on_write(empty_bitmap,
 1376|      0|                                         is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1376:42): [True: 0, False: 0]
  |  Branch (1376:56): [True: 0, False: 0]
  ------------------
 1377|      0|        return empty_bitmap;
 1378|      0|    }
 1379|  7.12k|    if (0 == length2) {
  ------------------
  |  Branch (1379:9): [True: 40, False: 7.08k]
  ------------------
 1380|     40|        return roaring_bitmap_copy(x1);
 1381|     40|    }
 1382|  7.08k|    roaring_bitmap_t *answer = roaring_bitmap_create_with_capacity(length1);
 1383|  7.08k|    roaring_bitmap_set_copy_on_write(answer, is_cow(x1) || is_cow(x2));
  ------------------
  |  Branch (1383:46): [True: 0, False: 7.08k]
  |  Branch (1383:60): [True: 0, False: 7.08k]
  ------------------
 1384|       |
 1385|  7.08k|    int pos1 = 0, pos2 = 0;
 1386|  7.08k|    uint8_t type1, type2;
 1387|  7.08k|    uint16_t s1 = 0;
 1388|  7.08k|    uint16_t s2 = 0;
 1389|  7.08k|    while (true) {
  ------------------
  |  Branch (1389:12): [True: 7.08k, Folded]
  ------------------
 1390|  7.08k|        s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1391|  7.08k|        s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1392|       |
 1393|  7.08k|        if (s1 == s2) {
  ------------------
  |  Branch (1393:13): [True: 7.01k, False: 74]
  ------------------
 1394|  7.01k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1395|  7.01k|                                                        (uint16_t)pos1, &type1);
 1396|  7.01k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1397|  7.01k|                                                        (uint16_t)pos2, &type2);
 1398|  7.01k|            container_t *c =
 1399|  7.01k|                container_andnot(c1, type1, c2, type2, &result_type);
 1400|       |
 1401|  7.01k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1401:17): [True: 6.78k, False: 232]
  ------------------
 1402|  6.78k|                ra_append(&answer->high_low_container, s1, c, result_type);
 1403|  6.78k|            } else {
 1404|    232|                container_free(c, result_type);
 1405|    232|            }
 1406|  7.01k|            ++pos1;
 1407|  7.01k|            ++pos2;
 1408|  7.01k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1408:17): [True: 7.01k, False: 0]
  ------------------
 1409|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1409:17): [True: 0, False: 0]
  ------------------
 1410|     74|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1410:20): [True: 74, False: 0]
  ------------------
 1411|     74|            const int next_pos1 =
 1412|     74|                ra_advance_until(&x1->high_low_container, s2, pos1);
 1413|     74|            ra_append_copy_range(&answer->high_low_container,
 1414|     74|                                 &x1->high_low_container, pos1, next_pos1,
 1415|     74|                                 is_cow(x1));
 1416|       |            // TODO : perhaps some of the copy_on_write should be based on
 1417|       |            // answer rather than x1 (more stringent?).  Many similar cases
 1418|     74|            pos1 = next_pos1;
 1419|     74|            if (pos1 == length1) break;
  ------------------
  |  Branch (1419:17): [True: 74, False: 0]
  ------------------
 1420|     74|        } else {  // s1 > s2
 1421|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 1422|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1422:17): [True: 0, False: 0]
  ------------------
 1423|      0|        }
 1424|  7.08k|    }
 1425|  7.08k|    if (pos2 == length2) {
  ------------------
  |  Branch (1425:9): [True: 4.76k, False: 2.32k]
  ------------------
 1426|  4.76k|        ra_append_copy_range(&answer->high_low_container,
 1427|  4.76k|                             &x1->high_low_container, pos1, length1,
 1428|  4.76k|                             is_cow(x1));
 1429|  4.76k|    }
 1430|  7.08k|    return answer;
 1431|  7.12k|}
roaring_bitmap_andnot_inplace:
 1436|  7.12k|                                   const roaring_bitmap_t *x2) {
 1437|  7.12k|    if (x1 == x2) {  // empty, keeping the capacity
  ------------------
  |  Branch (1437:9): [True: 0, False: 7.12k]
  ------------------
 1438|      0|        ra_clear_containers(&x1->high_low_container);
 1439|      0|        x1->high_low_container.size = 0;
 1440|      0|        return;
 1441|      0|    }
 1442|       |
 1443|  7.12k|    uint8_t result_type = 0;
 1444|  7.12k|    int length1 = x1->high_low_container.size;
 1445|  7.12k|    const int length2 = x2->high_low_container.size;
 1446|  7.12k|    int intersection_size = 0;
 1447|       |
 1448|  7.12k|    if (0 == length2) return;
  ------------------
  |  Branch (1448:9): [True: 425, False: 6.70k]
  ------------------
 1449|       |
 1450|  6.70k|    if (0 == length1) {
  ------------------
  |  Branch (1450:9): [True: 0, False: 6.70k]
  ------------------
 1451|      0|        roaring_bitmap_clear(x1);
 1452|      0|        return;
 1453|      0|    }
 1454|       |
 1455|  6.70k|    int pos1 = 0, pos2 = 0;
 1456|  6.70k|    uint8_t type1, type2;
 1457|  6.70k|    uint16_t s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1458|  6.70k|    uint16_t s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1459|  6.70k|    while (true) {
  ------------------
  |  Branch (1459:12): [True: 6.70k, Folded]
  ------------------
 1460|  6.70k|        if (s1 == s2) {
  ------------------
  |  Branch (1460:13): [True: 6.70k, False: 0]
  ------------------
 1461|  6.70k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 1462|  6.70k|                                                        (uint16_t)pos1, &type1);
 1463|  6.70k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 1464|  6.70k|                                                        (uint16_t)pos2, &type2);
 1465|       |
 1466|       |            // We do the computation "in place" only when c1 is not a shared
 1467|       |            // container. Rationale: using a shared container safely with in
 1468|       |            // place computation would require making a copy and then doing the
 1469|       |            // computation in place which is likely less efficient than avoiding
 1470|       |            // in place entirely and always generating a new container.
 1471|       |
 1472|  6.70k|            container_t *c;
 1473|  6.70k|            if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  6.70k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1473:17): [True: 0, False: 6.70k]
  ------------------
 1474|      0|                c = container_andnot(c1, type1, c2, type2, &result_type);
 1475|      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)
  |  |  ------------------
  ------------------
 1476|  6.70k|            } else {
 1477|  6.70k|                c = container_iandnot(c1, type1, c2, type2, &result_type);
 1478|  6.70k|            }
 1479|       |
 1480|  6.70k|            if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1480:17): [True: 4.80k, False: 1.89k]
  ------------------
 1481|  4.80k|                ra_replace_key_and_container_at_index(&x1->high_low_container,
 1482|  4.80k|                                                      intersection_size++, s1,
 1483|  4.80k|                                                      c, result_type);
 1484|  4.80k|            } else {
 1485|  1.89k|                container_free(c, result_type);
 1486|  1.89k|            }
 1487|       |
 1488|  6.70k|            ++pos1;
 1489|  6.70k|            ++pos2;
 1490|  6.70k|            if (pos1 == length1) break;
  ------------------
  |  Branch (1490:17): [True: 4.54k, False: 2.15k]
  ------------------
 1491|  2.15k|            if (pos2 == length2) break;
  ------------------
  |  Branch (1491:17): [True: 2.15k, False: 0]
  ------------------
 1492|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1493|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1494|       |
 1495|      0|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (1495:20): [True: 0, False: 0]
  ------------------
 1496|      0|            if (pos1 != intersection_size) {
  ------------------
  |  Branch (1496:17): [True: 0, False: 0]
  ------------------
 1497|      0|                container_t *c1 = ra_get_container_at_index(
 1498|      0|                    &x1->high_low_container, (uint16_t)pos1, &type1);
 1499|       |
 1500|      0|                ra_replace_key_and_container_at_index(
 1501|      0|                    &x1->high_low_container, intersection_size, s1, c1, type1);
 1502|      0|            }
 1503|      0|            intersection_size++;
 1504|      0|            pos1++;
 1505|      0|            if (pos1 == length1) break;
  ------------------
  |  Branch (1505:17): [True: 0, False: 0]
  ------------------
 1506|      0|            s1 = ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 1507|       |
 1508|      0|        } else {  // s1 > s2
 1509|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 1510|      0|            if (pos2 == length2) break;
  ------------------
  |  Branch (1510:17): [True: 0, False: 0]
  ------------------
 1511|      0|            s2 = ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 1512|      0|        }
 1513|  6.70k|    }
 1514|       |
 1515|  6.70k|    if (pos1 < length1) {
  ------------------
  |  Branch (1515:9): [True: 2.15k, False: 4.54k]
  ------------------
 1516|       |        // all containers between intersection_size and
 1517|       |        // pos1 are junk.  However, they have either been moved
 1518|       |        // (thus still referenced) or involved in an iandnot
 1519|       |        // that will clean up all containers that could not be reused.
 1520|       |        // Thus we should not free the junk containers between
 1521|       |        // intersection_size and pos1.
 1522|  2.15k|        if (pos1 > intersection_size) {
  ------------------
  |  Branch (1522:13): [True: 25, False: 2.13k]
  ------------------
 1523|       |            // left slide of remaining items
 1524|     25|            ra_copy_range(&x1->high_low_container, pos1, length1,
 1525|     25|                          intersection_size);
 1526|     25|        }
 1527|       |        // else current placement is fine
 1528|  2.15k|        intersection_size += (length1 - pos1);
 1529|  2.15k|    }
 1530|  6.70k|    ra_downsize(&x1->high_low_container, intersection_size);
 1531|  6.70k|}
roaring_bitmap_get_cardinality:
 1533|  71.2k|uint64_t roaring_bitmap_get_cardinality(const roaring_bitmap_t *r) {
 1534|  71.2k|    const roaring_array_t *ra = &r->high_low_container;
 1535|       |
 1536|  71.2k|    uint64_t card = 0;
 1537|   418k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1537:21): [True: 347k, False: 71.2k]
  ------------------
 1538|   347k|        card += container_get_cardinality(ra->containers[i], ra->typecodes[i]);
 1539|  71.2k|    return card;
 1540|  71.2k|}
roaring_bitmap_is_empty:
 1611|  14.2k|bool roaring_bitmap_is_empty(const roaring_bitmap_t *r) {
 1612|  14.2k|    return r->high_low_container.size == 0;
 1613|  14.2k|}
roaring_bitmap_to_uint32_array:
 1615|  7.12k|void roaring_bitmap_to_uint32_array(const roaring_bitmap_t *r, uint32_t *ans) {
 1616|  7.12k|    ra_to_uint32_array(&r->high_low_container, ans);
 1617|  7.12k|}
roaring_bitmap_run_optimize:
 1635|  14.2k|bool roaring_bitmap_run_optimize(roaring_bitmap_t *r) {
 1636|  14.2k|    bool answer = false;
 1637|  28.5k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1637:21): [True: 14.2k, False: 14.2k]
  ------------------
 1638|  14.2k|        uint8_t type_original, type_after;
 1639|  14.2k|        ra_unshare_container_at_index(
 1640|  14.2k|            &r->high_low_container,
 1641|  14.2k|            (uint16_t)i);  // TODO: this introduces extra cloning!
 1642|  14.2k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1643|  14.2k|                                                   (uint16_t)i, &type_original);
 1644|  14.2k|        container_t *c1 = convert_run_optimize(c, type_original, &type_after);
 1645|  14.2k|        if (type_after == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  14.2k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1645:13): [True: 3.64k, False: 10.6k]
  ------------------
 1646|       |            answer = true;
 1647|  3.64k|        }
 1648|  14.2k|        ra_set_container_at_index(&r->high_low_container, i, c1, type_after);
 1649|  14.2k|    }
 1650|  14.2k|    return answer;
 1651|  14.2k|}
roaring_bitmap_shrink_to_fit:
 1653|  7.12k|size_t roaring_bitmap_shrink_to_fit(roaring_bitmap_t *r) {
 1654|  7.12k|    size_t answer = 0;
 1655|  14.2k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1655:21): [True: 7.12k, False: 7.12k]
  ------------------
 1656|  7.12k|        uint8_t type_original;
 1657|  7.12k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1658|  7.12k|                                                   (uint16_t)i, &type_original);
 1659|  7.12k|        answer += container_shrink_to_fit(c, type_original);
 1660|  7.12k|    }
 1661|  7.12k|    answer += ra_shrink_to_fit(&r->high_low_container);
 1662|  7.12k|    return answer;
 1663|  7.12k|}
roaring_bitmap_remove_run_compression:
 1669|  7.12k|bool roaring_bitmap_remove_run_compression(roaring_bitmap_t *r) {
 1670|  7.12k|    bool answer = false;
 1671|  81.5k|    for (int i = 0; i < r->high_low_container.size; i++) {
  ------------------
  |  Branch (1671:21): [True: 74.3k, False: 7.12k]
  ------------------
 1672|  74.3k|        uint8_t type_original, type_after;
 1673|  74.3k|        container_t *c = ra_get_container_at_index(&r->high_low_container,
 1674|  74.3k|                                                   (uint16_t)i, &type_original);
 1675|  74.3k|        if (get_container_type(c, type_original) == RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|  74.3k|#define RUN_CONTAINER_TYPE 3
  ------------------
  |  Branch (1675:13): [True: 66.3k, False: 8.01k]
  ------------------
 1676|  66.3k|            answer = true;
 1677|  66.3k|            if (type_original == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  66.3k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1677:17): [True: 0, False: 66.3k]
  ------------------
 1678|      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)
  |  |  ------------------
  ------------------
 1679|      0|                int32_t card = run_container_cardinality(truec);
 1680|      0|                container_t *c1 = convert_to_bitset_or_array_container(
 1681|      0|                    truec, card, &type_after);
 1682|      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)
  |  |  ------------------
  ------------------
 1683|      0|                ra_set_container_at_index(&r->high_low_container, i, c1,
 1684|      0|                                          type_after);
 1685|       |
 1686|  66.3k|            } else {
 1687|  66.3k|                int32_t card = run_container_cardinality(CAST_run(c));
  ------------------
  |  |   77|  66.3k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  66.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1688|  66.3k|                container_t *c1 = convert_to_bitset_or_array_container(
 1689|  66.3k|                    CAST_run(c), card, &type_after);
  ------------------
  |  |   77|  66.3k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  66.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1690|  66.3k|                run_container_free(CAST_run(c));
  ------------------
  |  |   77|  66.3k|#define CAST_run(c) CAST(run_container_t *, c)  // safer downcast
  |  |  ------------------
  |  |  |  |   86|  66.3k|#define CAST(type, value) ((type)value)
  |  |  ------------------
  ------------------
 1691|  66.3k|                ra_set_container_at_index(&r->high_low_container, i, c1,
 1692|  66.3k|                                          type_after);
 1693|  66.3k|            }
 1694|  66.3k|        }
 1695|  74.3k|    }
 1696|  7.12k|    return answer;
 1697|  7.12k|}
roaring_bitmap_portable_size_in_bytes:
 1732|  14.2k|size_t roaring_bitmap_portable_size_in_bytes(const roaring_bitmap_t *r) {
 1733|  14.2k|    return ra_portable_size_in_bytes(&r->high_low_container);
 1734|  14.2k|}
roaring_bitmap_portable_deserialize_safe:
 1737|  14.2k|                                                           size_t maxbytes) {
 1738|  14.2k|    roaring_bitmap_t *ans =
 1739|  14.2k|        (roaring_bitmap_t *)roaring_malloc(sizeof(roaring_bitmap_t));
 1740|  14.2k|    if (ans == NULL) {
  ------------------
  |  Branch (1740:9): [True: 0, False: 14.2k]
  ------------------
 1741|      0|        return NULL;
 1742|      0|    }
 1743|  14.2k|    size_t bytesread;
 1744|  14.2k|    bool is_ok = ra_portable_deserialize(&ans->high_low_container, buf,
 1745|  14.2k|                                         maxbytes, &bytesread);
 1746|  14.2k|    if (!is_ok) {
  ------------------
  |  Branch (1746:9): [True: 7.11k, False: 7.14k]
  ------------------
 1747|  7.11k|        roaring_free(ans);
 1748|  7.11k|        return NULL;
 1749|  7.11k|    }
 1750|  7.14k|    roaring_bitmap_set_copy_on_write(ans, false);
 1751|  7.14k|    if (!is_ok) {
  ------------------
  |  Branch (1751:9): [True: 0, False: 7.14k]
  ------------------
 1752|      0|        roaring_free(ans);
 1753|      0|        return NULL;
 1754|      0|    }
 1755|  7.14k|    return ans;
 1756|  7.14k|}
roaring_bitmap_portable_serialize:
 1767|  7.12k|size_t roaring_bitmap_portable_serialize(const roaring_bitmap_t *r, char *buf) {
 1768|  7.12k|    return ra_portable_serialize(&r->high_low_container, buf);
 1769|  7.12k|}
roaring_iterate:
 1850|  7.11k|                     void *ptr) {
 1851|  7.11k|    const roaring_array_t *ra = &r->high_low_container;
 1852|       |
 1853|  69.5k|    for (int i = 0; i < ra->size; ++i)
  ------------------
  |  Branch (1853:21): [True: 62.4k, False: 7.11k]
  ------------------
 1854|  62.4k|        if (!container_iterate(ra->containers[i], ra->typecodes[i],
  ------------------
  |  Branch (1854:13): [True: 0, False: 62.4k]
  ------------------
 1855|  62.4k|                               ((uint32_t)ra->keys[i]) << 16, iterator, ptr)) {
 1856|      0|            return false;
 1857|      0|        }
 1858|  7.11k|    return true;
 1859|  7.11k|}
roaring_iterator_init:
 1966|  14.2k|                           roaring_uint32_iterator_t *newit) {
 1967|  14.2k|    newit->parent = r;
 1968|  14.2k|    newit->container_index = 0;
 1969|  14.2k|    newit->has_value = loadfirstvalue(newit);
 1970|  14.2k|}
roaring_uint32_iterator_move_equalorlarger:
 1998|  7.12k|                                                uint32_t val) {
 1999|  7.12k|    uint16_t hb = val >> 16;
 2000|  7.12k|    const int i = ra_get_index(&it->parent->high_low_container, hb);
 2001|  7.12k|    if (i >= 0) {
  ------------------
  |  Branch (2001:9): [True: 7.07k, False: 51]
  ------------------
 2002|  7.07k|        uint32_t lowvalue =
 2003|  7.07k|            container_maximum(it->parent->high_low_container.containers[i],
 2004|  7.07k|                              it->parent->high_low_container.typecodes[i]);
 2005|  7.07k|        uint16_t lb = val & 0xFFFF;
 2006|  7.07k|        if (lowvalue < lb) {
  ------------------
  |  Branch (2006:13): [True: 6, False: 7.07k]
  ------------------
 2007|       |            // will have to load first value of next container
 2008|      6|            it->container_index = i + 1;
 2009|  7.07k|        } else {
 2010|       |            // the value is necessarily within the range of the container
 2011|  7.07k|            it->container_index = i;
 2012|  7.07k|            it->has_value = loadfirstvalue_largeorequal(it, val);
 2013|  7.07k|            return it->has_value;
 2014|  7.07k|        }
 2015|  7.07k|    } else {
 2016|       |        // there is no matching, so we are going for the next container
 2017|     51|        it->container_index = -i - 1;
 2018|     51|    }
 2019|     57|    it->has_value = loadfirstvalue(it);
 2020|     57|    return it->has_value;
 2021|  7.12k|}
roaring_uint32_iterator_advance:
 2023|   330k|bool roaring_uint32_iterator_advance(roaring_uint32_iterator_t *it) {
 2024|   330k|    if (it->container_index >= it->parent->high_low_container.size) {
  ------------------
  |  Branch (2024:9): [True: 0, False: 330k]
  ------------------
 2025|      0|        return (it->has_value = false);
 2026|      0|    }
 2027|   330k|    if (it->container_index < 0) {
  ------------------
  |  Branch (2027:9): [True: 0, False: 330k]
  ------------------
 2028|      0|        it->container_index = 0;
 2029|      0|        return (it->has_value = loadfirstvalue(it));
 2030|      0|    }
 2031|   330k|    uint16_t low16 = (uint16_t)it->current_value;
 2032|   330k|    if (container_iterator_next(it->container, it->typecode, &it->container_it,
  ------------------
  |  Branch (2032:9): [True: 323k, False: 6.89k]
  ------------------
 2033|   330k|                                &low16)) {
 2034|   323k|        it->current_value = it->highbits | low16;
 2035|   323k|        return (it->has_value = true);
 2036|   323k|    }
 2037|  6.89k|    it->container_index++;
 2038|  6.89k|    return (it->has_value = loadfirstvalue(it));
 2039|   330k|}
roaring_bitmap_equals:
 2234|  14.2k|                           const roaring_bitmap_t *r2) {
 2235|  14.2k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2236|  14.2k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2237|       |
 2238|  14.2k|    if (ra1->size != ra2->size) {
  ------------------
  |  Branch (2238:9): [True: 2.45k, False: 11.8k]
  ------------------
 2239|  2.45k|        return false;
 2240|  2.45k|    }
 2241|  90.8k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2241:21): [True: 79.0k, False: 11.7k]
  ------------------
 2242|  79.0k|        if (ra1->keys[i] != ra2->keys[i]) {
  ------------------
  |  Branch (2242:13): [True: 23, False: 79.0k]
  ------------------
 2243|     23|            return false;
 2244|     23|        }
 2245|  79.0k|    }
 2246|  86.1k|    for (int i = 0; i < ra1->size; ++i) {
  ------------------
  |  Branch (2246:21): [True: 79.0k, False: 7.12k]
  ------------------
 2247|  79.0k|        bool areequal = container_equals(ra1->containers[i], ra1->typecodes[i],
 2248|  79.0k|                                         ra2->containers[i], ra2->typecodes[i]);
 2249|  79.0k|        if (!areequal) {
  ------------------
  |  Branch (2249:13): [True: 4.65k, False: 74.3k]
  ------------------
 2250|  4.65k|            return false;
 2251|  4.65k|        }
 2252|  79.0k|    }
 2253|  7.12k|    return true;
 2254|  11.7k|}
roaring_bitmap_is_subset:
 2257|  12.6k|                              const roaring_bitmap_t *r2) {
 2258|  12.6k|    const roaring_array_t *ra1 = &r1->high_low_container;
 2259|  12.6k|    const roaring_array_t *ra2 = &r2->high_low_container;
 2260|       |
 2261|  12.6k|    const int length1 = ra1->size, length2 = ra2->size;
 2262|       |
 2263|  12.6k|    int pos1 = 0, pos2 = 0;
 2264|       |
 2265|  12.6k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (2265:12): [True: 12.1k, False: 464]
  |  Branch (2265:30): [True: 12.1k, False: 40]
  ------------------
 2266|  12.1k|        const uint16_t s1 = ra_get_key_at_index(ra1, (uint16_t)pos1);
 2267|  12.1k|        const uint16_t s2 = ra_get_key_at_index(ra2, (uint16_t)pos2);
 2268|       |
 2269|  12.1k|        if (s1 == s2) {
  ------------------
  |  Branch (2269:13): [True: 11.9k, False: 116]
  ------------------
 2270|  11.9k|            uint8_t type1, type2;
 2271|  11.9k|            container_t *c1 =
 2272|  11.9k|                ra_get_container_at_index(ra1, (uint16_t)pos1, &type1);
 2273|  11.9k|            container_t *c2 =
 2274|  11.9k|                ra_get_container_at_index(ra2, (uint16_t)pos2, &type2);
 2275|  11.9k|            if (!container_is_subset(c1, type1, c2, type2)) return false;
  ------------------
  |  Branch (2275:17): [True: 11.9k, False: 0]
  ------------------
 2276|      0|            ++pos1;
 2277|      0|            ++pos2;
 2278|    116|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (2278:20): [True: 116, False: 0]
  ------------------
 2279|    116|            return false;
 2280|    116|        } else {  // s1 > s2
 2281|      0|            pos2 = ra_advance_until(ra2, s1, pos2);
 2282|      0|        }
 2283|  12.1k|    }
 2284|    504|    if (pos1 == length1)
  ------------------
  |  Branch (2284:9): [True: 464, False: 40]
  ------------------
 2285|    464|        return true;
 2286|     40|    else
 2287|     40|        return false;
 2288|    504|}
roaring_bitmap_flip_inplace:
 2405|  7.12k|                                 uint64_t range_end) {
 2406|  7.12k|    if (range_end > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (2406:9): [True: 0, False: 7.12k]
  ------------------
 2407|      0|        range_end = (uint64_t)UINT32_MAX + 1;
 2408|      0|    }
 2409|  7.12k|    if (range_start >= range_end) {
  ------------------
  |  Branch (2409:9): [True: 6.55k, False: 574]
  ------------------
 2410|  6.55k|        return;
 2411|  6.55k|    }
 2412|    574|    roaring_bitmap_flip_inplace_closed(x1, (uint32_t)range_start,
 2413|    574|                                       (uint32_t)(range_end - 1));
 2414|    574|}
roaring_bitmap_flip_inplace_closed:
 2418|  7.70k|                                        uint32_t range_end) {
 2419|  7.70k|    if (range_start > range_end) {
  ------------------
  |  Branch (2419:9): [True: 131, False: 7.57k]
  ------------------
 2420|    131|        return;  // empty range
 2421|    131|    }
 2422|       |
 2423|  7.57k|    uint16_t hb_start = (uint16_t)(range_start >> 16);
 2424|  7.57k|    const uint16_t lb_start = (uint16_t)range_start;
 2425|  7.57k|    uint16_t hb_end = (uint16_t)(range_end >> 16);
 2426|  7.57k|    const uint16_t lb_end = (uint16_t)range_end;
 2427|       |
 2428|  7.57k|    if (hb_start == hb_end) {
  ------------------
  |  Branch (2428:9): [True: 7.13k, False: 432]
  ------------------
 2429|  7.13k|        inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2430|  7.13k|                               lb_end);
 2431|  7.13k|    } else {
 2432|       |        // start and end containers are distinct
 2433|    432|        if (lb_start > 0) {
  ------------------
  |  Branch (2433:13): [True: 345, False: 87]
  ------------------
 2434|       |            // handle first (partial) container
 2435|    345|            inplace_flip_container(&x1->high_low_container, hb_start, lb_start,
 2436|    345|                                   0xFFFF);
 2437|    345|            ++hb_start;  // for the full containers.  Can't wrap.
 2438|    345|        }
 2439|       |
 2440|    432|        if (lb_end != 0xFFFF) --hb_end;
  ------------------
  |  Branch (2440:13): [True: 410, False: 22]
  ------------------
 2441|       |
 2442|  24.6k|        for (uint32_t hb = hb_start; hb <= hb_end; ++hb) {
  ------------------
  |  Branch (2442:38): [True: 24.2k, False: 432]
  ------------------
 2443|  24.2k|            inplace_fully_flip_container(&x1->high_low_container, (uint16_t)hb);
 2444|  24.2k|        }
 2445|       |        // handle a partial final container
 2446|    432|        if (lb_end != 0xFFFF) {
  ------------------
  |  Branch (2446:13): [True: 410, False: 22]
  ------------------
 2447|    410|            inplace_flip_container(&x1->high_low_container, hb_end + 1, 0,
 2448|    410|                                   lb_end);
 2449|    410|            ++hb_end;
 2450|    410|        }
 2451|    432|    }
 2452|  7.57k|}
roaring_bitmap_rank:
 2923|  7.12k|uint64_t roaring_bitmap_rank(const roaring_bitmap_t *bm, uint32_t x) {
 2924|  7.12k|    uint64_t size = 0;
 2925|  7.12k|    uint32_t xhigh = x >> 16;
 2926|  7.12k|    for (int i = 0; i < bm->high_low_container.size; i++) {
  ------------------
  |  Branch (2926:21): [True: 7.12k, False: 0]
  ------------------
 2927|  7.12k|        uint32_t key = bm->high_low_container.keys[i];
 2928|  7.12k|        if (xhigh > key) {
  ------------------
  |  Branch (2928:13): [True: 0, False: 7.12k]
  ------------------
 2929|      0|            size +=
 2930|      0|                container_get_cardinality(bm->high_low_container.containers[i],
 2931|      0|                                          bm->high_low_container.typecodes[i]);
 2932|  7.12k|        } else if (xhigh == key) {
  ------------------
  |  Branch (2932:20): [True: 7.12k, False: 0]
  ------------------
 2933|  7.12k|            return size + container_rank(bm->high_low_container.containers[i],
 2934|  7.12k|                                         bm->high_low_container.typecodes[i],
 2935|  7.12k|                                         x & 0xFFFF);
 2936|  7.12k|        } else {
 2937|      0|            return size;
 2938|      0|        }
 2939|  7.12k|    }
 2940|      0|    return size;
 2941|  7.12k|}
roaring_bitmap_minimum:
 3006|  7.12k|uint32_t roaring_bitmap_minimum(const roaring_bitmap_t *bm) {
 3007|  7.12k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (3007:9): [True: 7.08k, False: 40]
  ------------------
 3008|  7.08k|        container_t *c = bm->high_low_container.containers[0];
 3009|  7.08k|        uint8_t type = bm->high_low_container.typecodes[0];
 3010|  7.08k|        uint32_t key = bm->high_low_container.keys[0];
 3011|  7.08k|        uint32_t lowvalue = container_minimum(c, type);
 3012|  7.08k|        return lowvalue | (key << 16);
 3013|  7.08k|    }
 3014|     40|    return UINT32_MAX;
 3015|  7.12k|}
roaring_bitmap_maximum:
 3021|  7.12k|uint32_t roaring_bitmap_maximum(const roaring_bitmap_t *bm) {
 3022|  7.12k|    if (bm->high_low_container.size > 0) {
  ------------------
  |  Branch (3022:9): [True: 7.08k, False: 40]
  ------------------
 3023|  7.08k|        container_t *container =
 3024|  7.08k|            bm->high_low_container.containers[bm->high_low_container.size - 1];
 3025|  7.08k|        uint8_t typecode =
 3026|  7.08k|            bm->high_low_container.typecodes[bm->high_low_container.size - 1];
 3027|  7.08k|        uint32_t key =
 3028|  7.08k|            bm->high_low_container.keys[bm->high_low_container.size - 1];
 3029|  7.08k|        uint32_t lowvalue = container_maximum(container, typecode);
 3030|  7.08k|        return lowvalue | (key << 16);
 3031|  7.08k|    }
 3032|     40|    return 0;
 3033|  7.12k|}
roaring_bitmap_select:
 3036|  7.12k|                           uint32_t *element) {
 3037|  7.12k|    const roaring_array_t *ra = &bm->high_low_container;
 3038|  7.12k|    uint32_t start_rank = 0;
 3039|  7.55k|    for (int32_t i = 0; i < ra->size; i++) {
  ------------------
  |  Branch (3039:25): [True: 7.12k, False: 426]
  ------------------
 3040|  7.12k|        uint8_t typecode = ra->typecodes[i];
 3041|  7.12k|        const container_t *c =
 3042|  7.12k|            container_unwrap_shared(ra->containers[i], &typecode);
 3043|  7.12k|        uint32_t card = (uint32_t)container_get_cardinality(c, typecode);
 3044|  7.12k|        if (rank - start_rank < card) {  // rank >= start_rank always holds
  ------------------
  |  Branch (3044:13): [True: 6.70k, False: 426]
  ------------------
 3045|  6.70k|            if (!container_select(c, typecode, &start_rank, rank, element)) {
  ------------------
  |  Branch (3045:17): [True: 0, False: 6.70k]
  ------------------
 3046|      0|                return false;
 3047|      0|            }
 3048|       |            // w/o cast, key promotes signed
 3049|  6.70k|            *element |= (((uint32_t)ra->keys[i]) << 16);
 3050|  6.70k|            return true;
 3051|  6.70k|        }
 3052|    426|        start_rank += card;
 3053|    426|    }
 3054|    426|    return false;
 3055|  7.12k|}
roaring_bitmap_intersect:
 3058|  7.12k|                              const roaring_bitmap_t *x2) {
 3059|  7.12k|    const int length1 = x1->high_low_container.size,
 3060|  7.12k|              length2 = x2->high_low_container.size;
 3061|  7.12k|    uint64_t answer = 0;
 3062|  7.12k|    int pos1 = 0, pos2 = 0;
 3063|       |
 3064|  7.51k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (3064:12): [True: 7.12k, False: 385]
  |  Branch (3064:30): [True: 7.08k, False: 40]
  ------------------
 3065|  7.08k|        const uint16_t s1 =
 3066|  7.08k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 3067|  7.08k|        const uint16_t s2 =
 3068|  7.08k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 3069|       |
 3070|  7.08k|        if (s1 == s2) {
  ------------------
  |  Branch (3070:13): [True: 7.01k, False: 74]
  ------------------
 3071|  7.01k|            uint8_t type1, type2;
 3072|  7.01k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 3073|  7.01k|                                                        (uint16_t)pos1, &type1);
 3074|  7.01k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 3075|  7.01k|                                                        (uint16_t)pos2, &type2);
 3076|  7.01k|            if (container_intersect(c1, type1, c2, type2)) return true;
  ------------------
  |  Branch (3076:17): [True: 6.70k, False: 311]
  ------------------
 3077|    311|            ++pos1;
 3078|    311|            ++pos2;
 3079|    311|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (3079:20): [True: 74, False: 0]
  ------------------
 3080|     74|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 3081|     74|        } else {  // s1 > s2
 3082|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 3083|      0|        }
 3084|  7.08k|    }
 3085|    425|    return answer != 0;
 3086|  7.12k|}
roaring_bitmap_and_cardinality:
 3111|  28.5k|                                        const roaring_bitmap_t *x2) {
 3112|  28.5k|    const int length1 = x1->high_low_container.size,
 3113|  28.5k|              length2 = x2->high_low_container.size;
 3114|  28.5k|    uint64_t answer = 0;
 3115|  28.5k|    int pos1 = 0, pos2 = 0;
 3116|  56.8k|    while (pos1 < length1 && pos2 < length2) {
  ------------------
  |  Branch (3116:12): [True: 28.5k, False: 28.3k]
  |  Branch (3116:30): [True: 28.3k, False: 160]
  ------------------
 3117|  28.3k|        const uint16_t s1 =
 3118|  28.3k|            ra_get_key_at_index(&x1->high_low_container, (uint16_t)pos1);
 3119|  28.3k|        const uint16_t s2 =
 3120|  28.3k|            ra_get_key_at_index(&x2->high_low_container, (uint16_t)pos2);
 3121|       |
 3122|  28.3k|        if (s1 == s2) {
  ------------------
  |  Branch (3122:13): [True: 28.0k, False: 296]
  ------------------
 3123|  28.0k|            uint8_t type1, type2;
 3124|  28.0k|            container_t *c1 = ra_get_container_at_index(&x1->high_low_container,
 3125|  28.0k|                                                        (uint16_t)pos1, &type1);
 3126|  28.0k|            container_t *c2 = ra_get_container_at_index(&x2->high_low_container,
 3127|  28.0k|                                                        (uint16_t)pos2, &type2);
 3128|  28.0k|            answer += container_and_cardinality(c1, type1, c2, type2);
 3129|  28.0k|            ++pos1;
 3130|  28.0k|            ++pos2;
 3131|  28.0k|        } else if (s1 < s2) {  // s1 < s2
  ------------------
  |  Branch (3131:20): [True: 296, False: 0]
  ------------------
 3132|    296|            pos1 = ra_advance_until(&x1->high_low_container, s2, pos1);
 3133|    296|        } else {  // s1 > s2
 3134|      0|            pos2 = ra_advance_until(&x2->high_low_container, s1, pos2);
 3135|      0|        }
 3136|  28.3k|    }
 3137|  28.5k|    return answer;
 3138|  28.5k|}
roaring_bitmap_jaccard_index:
 3141|  7.12k|                                    const roaring_bitmap_t *x2) {
 3142|  7.12k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3143|  7.12k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3144|  7.12k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3145|  7.12k|    return (double)inter / (double)(c1 + c2 - inter);
 3146|  7.12k|}
roaring_bitmap_or_cardinality:
 3149|  7.12k|                                       const roaring_bitmap_t *x2) {
 3150|  7.12k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3151|  7.12k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3152|  7.12k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3153|  7.12k|    return c1 + c2 - inter;
 3154|  7.12k|}
roaring_bitmap_andnot_cardinality:
 3157|  7.12k|                                           const roaring_bitmap_t *x2) {
 3158|  7.12k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3159|  7.12k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3160|  7.12k|    return c1 - inter;
 3161|  7.12k|}
roaring_bitmap_xor_cardinality:
 3164|  7.12k|                                        const roaring_bitmap_t *x2) {
 3165|  7.12k|    const uint64_t c1 = roaring_bitmap_get_cardinality(x1);
 3166|  7.12k|    const uint64_t c2 = roaring_bitmap_get_cardinality(x2);
 3167|  7.12k|    const uint64_t inter = roaring_bitmap_and_cardinality(x1, x2);
 3168|  7.12k|    return c1 + c2 - 2 * inter;
 3169|  7.12k|}
roaring_bitmap_contains_range:
 3176|  7.12k|                                   uint64_t range_start, uint64_t range_end) {
 3177|  7.12k|    if (range_end > (uint64_t)UINT32_MAX + 1) {
  ------------------
  |  Branch (3177:9): [True: 0, False: 7.12k]
  ------------------
 3178|      0|        range_end = (uint64_t)UINT32_MAX + 1;
 3179|      0|    }
 3180|  7.12k|    if (range_start >= range_end) {
  ------------------
  |  Branch (3180:9): [True: 6.28k, False: 843]
  ------------------
 3181|  6.28k|        return true;
 3182|  6.28k|    }
 3183|    843|    return roaring_bitmap_contains_range_closed(r, (uint32_t)range_start,
 3184|    843|                                                (uint32_t)(range_end - 1));
 3185|  7.12k|}
roaring_bitmap_contains_range_closed:
 3193|    843|                                          uint32_t range_end) {
 3194|    843|    if (range_start > range_end) {
  ------------------
  |  Branch (3194:9): [True: 0, False: 843]
  ------------------
 3195|      0|        return true;
 3196|      0|    }  // empty range are always contained!
 3197|    843|    if (range_end == range_start) {
  ------------------
  |  Branch (3197:9): [True: 57, False: 786]
  ------------------
 3198|     57|        return roaring_bitmap_contains(r, (uint32_t)range_start);
 3199|     57|    }
 3200|    786|    uint16_t hb_rs = (uint16_t)(range_start >> 16);
 3201|    786|    uint16_t hb_re = (uint16_t)(range_end >> 16);
 3202|    786|    const int32_t span = hb_re - hb_rs;
 3203|    786|    const int32_t hlc_sz = ra_get_size(&r->high_low_container);
 3204|    786|    if (hlc_sz < span + 1) {
  ------------------
  |  Branch (3204:9): [True: 231, False: 555]
  ------------------
 3205|    231|        return false;
 3206|    231|    }
 3207|    555|    int32_t is = ra_get_index(&r->high_low_container, hb_rs);
 3208|    555|    int32_t ie = ra_get_index(&r->high_low_container, hb_re);
 3209|    555|    if ((ie < 0) || (is < 0) || ((ie - is) != span) || ie >= hlc_sz) {
  ------------------
  |  Branch (3209:9): [True: 46, False: 509]
  |  Branch (3209:21): [True: 14, False: 495]
  |  Branch (3209:33): [True: 7, False: 488]
  |  Branch (3209:56): [True: 0, False: 488]
  ------------------
 3210|     67|        return false;
 3211|     67|    }
 3212|    488|    const uint32_t lb_rs = range_start & 0xFFFF;
 3213|    488|    const uint32_t lb_re = (range_end & 0xFFFF) + 1;
 3214|    488|    uint8_t type;
 3215|    488|    container_t *c =
 3216|    488|        ra_get_container_at_index(&r->high_low_container, (uint16_t)is, &type);
 3217|    488|    if (hb_rs == hb_re) {
  ------------------
  |  Branch (3217:9): [True: 419, False: 69]
  ------------------
 3218|    419|        return container_contains_range(c, lb_rs, lb_re, type);
 3219|    419|    }
 3220|     69|    if (!container_contains_range(c, lb_rs, 1 << 16, type)) {
  ------------------
  |  Branch (3220:9): [True: 17, False: 52]
  ------------------
 3221|     17|        return false;
 3222|     17|    }
 3223|     52|    c = ra_get_container_at_index(&r->high_low_container, (uint16_t)ie, &type);
 3224|     52|    if (!container_contains_range(c, 0, lb_re, type)) {
  ------------------
  |  Branch (3224:9): [True: 6, False: 46]
  ------------------
 3225|      6|        return false;
 3226|      6|    }
 3227|    727|    for (int32_t i = is + 1; i < ie; ++i) {
  ------------------
  |  Branch (3227:30): [True: 708, False: 19]
  ------------------
 3228|    708|        c = ra_get_container_at_index(&r->high_low_container, (uint16_t)i,
 3229|    708|                                      &type);
 3230|    708|        if (!container_is_full(c, type)) {
  ------------------
  |  Branch (3230:13): [True: 27, False: 681]
  ------------------
 3231|     27|            return false;
 3232|     27|        }
 3233|    708|    }
 3234|     19|    return true;
 3235|     46|}
roaring_bitmap_is_strict_subset:
 3238|  7.12k|                                     const roaring_bitmap_t *r2) {
 3239|  7.12k|    return (roaring_bitmap_get_cardinality(r2) >
  ------------------
  |  Branch (3239:13): [True: 5.47k, False: 1.64k]
  ------------------
 3240|  7.12k|                roaring_bitmap_get_cardinality(r1) &&
 3241|  5.47k|            roaring_bitmap_is_subset(r1, r2));
  ------------------
  |  Branch (3241:13): [True: 232, False: 5.24k]
  ------------------
 3242|  7.12k|}
roaring.c:containerptr_roaring_bitmap_add:
   56|  21.3k|                                                           int *index) {
   57|  21.3k|    roaring_array_t *ra = &r->high_low_container;
   58|       |
   59|  21.3k|    uint16_t hb = val >> 16;
   60|  21.3k|    const int i = ra_get_index(ra, hb);
   61|  21.3k|    if (i >= 0) {
  ------------------
  |  Branch (61:9): [True: 7.12k, False: 14.2k]
  ------------------
   62|  7.12k|        ra_unshare_container_at_index(ra, (uint16_t)i);
   63|  7.12k|        container_t *c = ra_get_container_at_index(ra, (uint16_t)i, type);
   64|  7.12k|        uint8_t new_type = *type;
   65|  7.12k|        container_t *c2 = container_add(c, val & 0xFFFF, *type, &new_type);
   66|  7.12k|        *index = i;
   67|  7.12k|        if (c2 != c) {
  ------------------
  |  Branch (67:13): [True: 2, False: 7.12k]
  ------------------
   68|      2|            container_free(c, *type);
   69|      2|            ra_set_container_at_index(ra, i, c2, new_type);
   70|      2|            *type = new_type;
   71|      2|            return c2;
   72|  7.12k|        } else {
   73|  7.12k|            return c;
   74|  7.12k|        }
   75|  14.2k|    } else {
   76|  14.2k|        array_container_t *new_ac = array_container_create();
   77|  14.2k|        container_t *c =
   78|  14.2k|            container_add(new_ac, val & 0xFFFF, ARRAY_CONTAINER_TYPE, type);
  ------------------
  |  |   49|  14.2k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
   79|       |        // we could just assume that it stays an array container
   80|  14.2k|        ra_insert_new_key_value_at(ra, -i - 1, hb, c, *type);
   81|  14.2k|        *index = -i - 1;
   82|  14.2k|        return c;
   83|  14.2k|    }
   84|  21.3k|}
roaring.c:add_bulk_impl:
  106|  8.91M|                                 uint32_t val) {
  107|  8.91M|    uint16_t key = val >> 16;
  108|  8.91M|    if (context->container == NULL || context->key != key) {
  ------------------
  |  Branch (108:9): [True: 0, False: 8.91M]
  |  Branch (108:39): [True: 0, False: 8.91M]
  ------------------
  109|      0|        uint8_t typecode;
  110|      0|        int idx;
  111|      0|        context->container =
  112|      0|            containerptr_roaring_bitmap_add(r, val, &typecode, &idx);
  113|      0|        context->typecode = typecode;
  114|      0|        context->idx = idx;
  115|      0|        context->key = key;
  116|  8.91M|    } else {
  117|       |        // no need to seek the container, it is at hand
  118|       |        // because we already have the container at hand, we can do the
  119|       |        // insertion directly, bypassing the roaring_bitmap_add call
  120|  8.91M|        uint8_t new_typecode;
  121|  8.91M|        container_t *container2 = container_add(
  122|  8.91M|            context->container, val & 0xFFFF, context->typecode, &new_typecode);
  123|  8.91M|        if (container2 != context->container) {
  ------------------
  |  Branch (123:13): [True: 121, False: 8.90M]
  ------------------
  124|       |            // rare instance when we need to change the container type
  125|    121|            container_free(context->container, context->typecode);
  126|    121|            ra_set_container_at_index(&r->high_low_container, context->idx,
  127|    121|                                      container2, new_typecode);
  128|    121|            context->typecode = new_typecode;
  129|    121|            context->container = container2;
  130|    121|        }
  131|  8.91M|    }
  132|  8.91M|}
roaring.c:is_cow:
   41|   120k|static inline bool is_cow(const roaring_bitmap_t *r) {
   42|       |    return r->high_low_container.flags & ROARING_FLAG_COW;
  ------------------
  |  |   46|   120k|#define ROARING_FLAG_COW UINT8_C(0x1)
  ------------------
   43|   120k|}
roaring.c:roaring_inplace_merge_bulk:
  970|  2.42k|                                       int left, int right, bool is_xor) {
  971|  2.42k|    roaring_array_t *ra1 = &x1->high_low_container;
  972|  2.42k|    const roaring_array_t *ra2 = &x2->high_low_container;
  973|  2.42k|    const bool cow2 = is_cow(x2);
  974|  2.42k|    const int length1 = ra1->size;
  975|  2.42k|    const int length2 = ra2->size;
  976|       |
  977|  2.42k|    int distinct = 0;
  978|  2.42k|    {
  979|  2.42k|        int l = left, r = right;
  980|  55.7k|        while (l < length1 && r < length2) {
  ------------------
  |  Branch (980:16): [True: 53.3k, False: 2.42k]
  |  Branch (980:31): [True: 53.3k, False: 0]
  ------------------
  981|  53.3k|            uint16_t k1 = ra1->keys[l];
  982|  53.3k|            uint16_t k2 = ra2->keys[r];
  983|  53.3k|            if (k1 < k2) {
  ------------------
  |  Branch (983:17): [True: 0, False: 53.3k]
  ------------------
  984|      0|                l++;
  985|  53.3k|            } else if (k1 > k2) {
  ------------------
  |  Branch (985:24): [True: 97, False: 53.2k]
  ------------------
  986|     97|                r++;
  987|  53.2k|            } else {
  988|  53.2k|                l++;
  989|  53.2k|                r++;
  990|  53.2k|            }
  991|  53.3k|            distinct++;
  992|  53.3k|        }
  993|  2.42k|        distinct += (length1 - l) + (length2 - r);
  994|  2.42k|    }
  995|  2.42k|    const int total = dst + distinct;
  996|       |
  997|  2.42k|    roaring_array_t merged;
  998|  2.42k|    ra_init_with_capacity(&merged, total > 0 ? (uint32_t)total : 1);
  ------------------
  |  Branch (998:36): [True: 2.32k, False: 100]
  ------------------
  999|       |
 1000|  4.52k|    for (int i = 0; i < dst; i++) {
  ------------------
  |  Branch (1000:21): [True: 2.10k, False: 2.42k]
  ------------------
 1001|  2.10k|        ra_append(&merged, ra1->keys[i], ra1->containers[i], ra1->typecodes[i]);
 1002|  2.10k|    }
 1003|       |
 1004|  2.42k|    uint8_t result_type = 0;
 1005|  55.7k|    while (left < length1 && right < length2) {
  ------------------
  |  Branch (1005:12): [True: 53.3k, False: 2.42k]
  |  Branch (1005:30): [True: 53.3k, False: 0]
  ------------------
 1006|  53.3k|        uint16_t k1 = ra1->keys[left];
 1007|  53.3k|        uint16_t k2 = ra2->keys[right];
 1008|  53.3k|        if (k1 < k2) {
  ------------------
  |  Branch (1008:13): [True: 0, False: 53.3k]
  ------------------
 1009|      0|            ra_append(&merged, k1, ra1->containers[left], ra1->typecodes[left]);
 1010|      0|            left++;
 1011|  53.3k|        } else if (k1 > k2) {
  ------------------
  |  Branch (1011:20): [True: 97, False: 53.2k]
  ------------------
 1012|     97|            uint8_t type2 = ra2->typecodes[right];
 1013|     97|            container_t *c2 =
 1014|     97|                get_copy_of_container(ra2->containers[right], &type2, cow2);
 1015|     97|            if (cow2) {
  ------------------
  |  Branch (1015:17): [True: 0, False: 97]
  ------------------
 1016|      0|                ra_set_container_at_index(ra2, right, c2, type2);
 1017|      0|            }
 1018|     97|            ra_append(&merged, k2, c2, type2);
 1019|     97|            right++;
 1020|  53.2k|        } else {
 1021|  53.2k|            uint8_t type1 = ra1->typecodes[left];
 1022|  53.2k|            container_t *c1 = ra1->containers[left];
 1023|  53.2k|            uint8_t type2 = ra2->typecodes[right];
 1024|  53.2k|            container_t *c2 = ra2->containers[right];
 1025|  53.2k|            if (is_xor) {
  ------------------
  |  Branch (1025:17): [True: 53.2k, False: 0]
  ------------------
 1026|  53.2k|                container_t *c;
 1027|  53.2k|                if (type1 == SHARED_CONTAINER_TYPE) {
  ------------------
  |  |   51|  53.2k|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1027:21): [True: 0, False: 53.2k]
  ------------------
 1028|      0|                    c = container_xor(c1, type1, c2, type2, &result_type);
 1029|      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)
  |  |  ------------------
  ------------------
 1030|  53.2k|                } else {
 1031|  53.2k|                    c = container_ixor(c1, type1, c2, type2, &result_type);
 1032|  53.2k|                }
 1033|  53.2k|                if (container_nonzero_cardinality(c, result_type)) {
  ------------------
  |  Branch (1033:21): [True: 0, False: 53.2k]
  ------------------
 1034|      0|                    ra_append(&merged, k1, c, result_type);
 1035|  53.2k|                } else {
 1036|  53.2k|                    container_free(c, result_type);
 1037|  53.2k|                }
 1038|  53.2k|            } else {
 1039|      0|                if (container_is_full(c1, type1)) {
  ------------------
  |  Branch (1039:21): [True: 0, False: 0]
  ------------------
 1040|      0|                    ra_append(&merged, k1, c1, type1);
 1041|      0|                } else {
 1042|      0|                    container_t *c =
 1043|      0|                        (type1 == SHARED_CONTAINER_TYPE)
  ------------------
  |  |   51|      0|#define SHARED_CONTAINER_TYPE 4
  ------------------
  |  Branch (1043:25): [True: 0, False: 0]
  ------------------
 1044|      0|                            ? container_or(c1, type1, c2, type2, &result_type)
 1045|      0|                            : container_ior(c1, type1, c2, type2, &result_type);
 1046|      0|                    if (c != c1) {
  ------------------
  |  Branch (1046:25): [True: 0, False: 0]
  ------------------
 1047|      0|                        container_free(c1, type1);
 1048|      0|                    }
 1049|      0|                    ra_append(&merged, k1, c, result_type);
 1050|      0|                }
 1051|      0|            }
 1052|  53.2k|            left++;
 1053|  53.2k|            right++;
 1054|  53.2k|        }
 1055|  53.3k|    }
 1056|  2.42k|    for (; left < length1; left++) {
  ------------------
  |  Branch (1056:12): [True: 0, False: 2.42k]
  ------------------
 1057|      0|        ra_append(&merged, ra1->keys[left], ra1->containers[left],
 1058|      0|                  ra1->typecodes[left]);
 1059|      0|    }
 1060|  2.42k|    for (; right < length2; right++) {
  ------------------
  |  Branch (1060:12): [True: 0, False: 2.42k]
  ------------------
 1061|      0|        uint8_t type2 = ra2->typecodes[right];
 1062|      0|        container_t *c2 =
 1063|      0|            get_copy_of_container(ra2->containers[right], &type2, cow2);
 1064|      0|        if (cow2) {
  ------------------
  |  Branch (1064:13): [True: 0, False: 0]
  ------------------
 1065|      0|            ra_set_container_at_index(ra2, right, c2, type2);
 1066|      0|        }
 1067|      0|        ra_append(&merged, ra2->keys[right], c2, type2);
 1068|      0|    }
 1069|       |
 1070|  2.42k|    merged.flags = ra1->flags;
 1071|  2.42k|    ra_clear_without_containers(ra1);
 1072|  2.42k|    *ra1 = merged;
 1073|  2.42k|}
roaring.c:loadfirstvalue:
 1914|  21.2k|    roaring_uint32_iterator_t *newit) {
 1915|  21.2k|    if (iter_new_container_partial_init(newit)) {
  ------------------
  |  Branch (1915:9): [True: 14.0k, False: 7.15k]
  ------------------
 1916|  14.0k|        uint16_t value = 0;
 1917|  14.0k|        newit->container_it =
 1918|  14.0k|            container_init_iterator(newit->container, newit->typecode, &value);
 1919|  14.0k|        newit->current_value = newit->highbits | value;
 1920|  14.0k|    }
 1921|  21.2k|    return newit->has_value;
 1922|  21.2k|}
roaring.c:iter_new_container_partial_init:
 1884|  28.2k|    roaring_uint32_iterator_t *newit) {
 1885|  28.2k|    newit->current_value = 0;
 1886|  28.2k|    if (newit->container_index >= newit->parent->high_low_container.size ||
  ------------------
  |  Branch (1886:9): [True: 7.15k, False: 21.1k]
  ------------------
 1887|  21.1k|        newit->container_index < 0) {
  ------------------
  |  Branch (1887:9): [True: 0, False: 21.1k]
  ------------------
 1888|  7.15k|        newit->current_value = UINT32_MAX;
 1889|  7.15k|        return (newit->has_value = false);
 1890|  7.15k|    }
 1891|  21.1k|    newit->has_value = true;
 1892|       |    // we precompute container, typecode and highbits so that successive
 1893|       |    // iterators do not have to grab them from odd memory locations
 1894|       |    // and have to worry about the (easily predicted) container_unwrap_shared
 1895|       |    // call.
 1896|  21.1k|    newit->container =
 1897|  21.1k|        newit->parent->high_low_container.containers[newit->container_index];
 1898|  21.1k|    newit->typecode =
 1899|  21.1k|        newit->parent->high_low_container.typecodes[newit->container_index];
 1900|  21.1k|    newit->highbits =
 1901|  21.1k|        ((uint32_t)
 1902|  21.1k|             newit->parent->high_low_container.keys[newit->container_index])
 1903|  21.1k|        << 16;
 1904|  21.1k|    newit->container =
 1905|  21.1k|        container_unwrap_shared(newit->container, &(newit->typecode));
 1906|       |    return true;
 1907|  28.2k|}
roaring.c:loadfirstvalue_largeorequal:
 1945|  7.07k|    roaring_uint32_iterator_t *newit, uint32_t val) {
 1946|  7.07k|    bool partial_init = iter_new_container_partial_init(newit);
 1947|  7.07k|    assert(partial_init);
 1948|  7.07k|    if (!partial_init) {
  ------------------
  |  Branch (1948:9): [True: 0, False: 7.07k]
  ------------------
 1949|      0|        return false;
 1950|      0|    }
 1951|  7.07k|    uint16_t value = 0;
 1952|  7.07k|    newit->container_it =
 1953|  7.07k|        container_init_iterator(newit->container, newit->typecode, &value);
 1954|  7.07k|    bool found = container_iterator_lower_bound(
 1955|  7.07k|        newit->container, newit->typecode, &newit->container_it, &value,
 1956|  7.07k|        val & 0xFFFF);
 1957|  7.07k|    assert(found);
 1958|  7.07k|    if (!found) {
  ------------------
  |  Branch (1958:9): [True: 0, False: 7.07k]
  ------------------
 1959|      0|        return false;
 1960|      0|    }
 1961|  7.07k|    newit->current_value = newit->highbits | value;
 1962|       |    return true;
 1963|  7.07k|}
roaring.c:inplace_flip_container:
 2291|  7.89k|                                   uint16_t lb_start, uint16_t lb_end) {
 2292|  7.89k|    const int i = ra_get_index(x1_arr, hb);
 2293|  7.89k|    uint8_t ctype_in, ctype_out;
 2294|  7.89k|    container_t *flipped_container = NULL;
 2295|  7.89k|    if (i >= 0) {
  ------------------
  |  Branch (2295:9): [True: 7.40k, False: 493]
  ------------------
 2296|  7.40k|        container_t *container_to_flip =
 2297|  7.40k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2298|  7.40k|        flipped_container = container_inot_range(
 2299|  7.40k|            container_to_flip, ctype_in, (uint32_t)lb_start,
 2300|  7.40k|            (uint32_t)(lb_end + 1), &ctype_out);
 2301|       |        // if a new container was created, the old one was already freed
 2302|  7.40k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2302:13): [True: 7.38k, False: 18]
  ------------------
 2303|  7.38k|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2304|  7.38k|        } else {
 2305|     18|            container_free(flipped_container, ctype_out);
 2306|     18|            ra_remove_at_index(x1_arr, i);
 2307|     18|        }
 2308|       |
 2309|  7.40k|    } else {
 2310|    493|        flipped_container = container_range_of_ones(
 2311|    493|            (uint32_t)lb_start, (uint32_t)(lb_end + 1), &ctype_out);
 2312|    493|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2313|    493|                                   ctype_out);
 2314|    493|    }
 2315|  7.89k|}
roaring.c:inplace_fully_flip_container:
 2317|  24.2k|static void inplace_fully_flip_container(roaring_array_t *x1_arr, uint16_t hb) {
 2318|  24.2k|    const int i = ra_get_index(x1_arr, hb);
 2319|  24.2k|    uint8_t ctype_in, ctype_out;
 2320|  24.2k|    container_t *flipped_container = NULL;
 2321|  24.2k|    if (i >= 0) {
  ------------------
  |  Branch (2321:9): [True: 6.60k, False: 17.6k]
  ------------------
 2322|  6.60k|        container_t *container_to_flip =
 2323|  6.60k|            ra_get_container_at_index(x1_arr, (uint16_t)i, &ctype_in);
 2324|  6.60k|        flipped_container =
 2325|  6.60k|            container_inot(container_to_flip, ctype_in, &ctype_out);
 2326|       |
 2327|  6.60k|        if (container_nonzero_cardinality(flipped_container, ctype_out)) {
  ------------------
  |  Branch (2327:13): [True: 497, False: 6.10k]
  ------------------
 2328|    497|            ra_set_container_at_index(x1_arr, i, flipped_container, ctype_out);
 2329|  6.10k|        } else {
 2330|  6.10k|            container_free(flipped_container, ctype_out);
 2331|  6.10k|            ra_remove_at_index(x1_arr, i);
 2332|  6.10k|        }
 2333|       |
 2334|  17.6k|    } else {
 2335|  17.6k|        flipped_container = container_range_of_ones(0U, 0x10000U, &ctype_out);
 2336|  17.6k|        ra_insert_new_key_value_at(x1_arr, -i - 1, hb, flipped_container,
 2337|  17.6k|                                   ctype_out);
 2338|  17.6k|    }
 2339|  24.2k|}

ra_init_with_capacity:
   80|  73.7k|bool ra_init_with_capacity(roaring_array_t *new_ra, uint32_t cap) {
   81|  73.7k|    if (!new_ra) return false;
  ------------------
  |  Branch (81:9): [True: 0, False: 73.7k]
  ------------------
   82|  73.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|  73.7k|    if (cap > 0x10000) {
  ------------------
  |  Branch (86:9): [True: 0, False: 73.7k]
  ------------------
   87|      0|        cap = 0x10000;
   88|      0|    }
   89|       |
   90|  73.7k|    if (cap > 0) {
  ------------------
  |  Branch (90:9): [True: 38.0k, False: 35.6k]
  ------------------
   91|  38.0k|        void *bigalloc = roaring_malloc(
   92|  38.0k|            cap * (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t)));
   93|  38.0k|        if (bigalloc == NULL) return false;
  ------------------
  |  Branch (93:13): [True: 0, False: 38.0k]
  ------------------
   94|  38.0k|        new_ra->containers = (container_t **)bigalloc;
   95|  38.0k|        new_ra->keys = (uint16_t *)(new_ra->containers + cap);
   96|  38.0k|        new_ra->typecodes = (uint8_t *)(new_ra->keys + cap);
   97|       |        // Narrowing is safe because of above check
   98|  38.0k|        new_ra->allocation_size = (int32_t)cap;
   99|  38.0k|    }
  100|  73.7k|    return true;
  101|  73.7k|}
ra_shrink_to_fit:
  103|  78.4k|int ra_shrink_to_fit(roaring_array_t *ra) {
  104|  78.4k|    int32_t size = ra->size;
  105|  78.4k|    int32_t allocation_size = ra->allocation_size;
  106|  78.4k|    if (allocation_size == size) return 0;  // nothing to do
  ------------------
  |  Branch (106:9): [True: 7.19k, False: 71.2k]
  ------------------
  107|  71.2k|    if (!realloc_array(ra, size)) {
  ------------------
  |  Branch (107:9): [True: 0, False: 71.2k]
  ------------------
  108|      0|        return 0;
  109|      0|    }
  110|  71.2k|    return (allocation_size - size) *
  111|  71.2k|           (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
  112|  71.2k|}
ra_init:
  114|  73.7k|void ra_init(roaring_array_t *new_ra) {
  115|  73.7k|    if (!new_ra) {
  ------------------
  |  Branch (115:9): [True: 0, False: 73.7k]
  ------------------
  116|      0|        return;
  117|      0|    }
  118|  73.7k|    new_ra->keys = NULL;
  119|  73.7k|    new_ra->containers = NULL;
  120|  73.7k|    new_ra->typecodes = NULL;
  121|       |
  122|  73.7k|    new_ra->allocation_size = 0;
  123|  73.7k|    new_ra->size = 0;
  124|  73.7k|    new_ra->flags = 0;
  125|  73.7k|}
ra_overwrite:
  128|  16.2k|                  bool copy_on_write) {
  129|  16.2k|    ra_clear_containers(dest);  // we are going to overwrite them
  130|  16.2k|    if (source->size == 0) {    // Note: can't call memcpy(NULL), even w/size
  ------------------
  |  Branch (130:9): [True: 14, False: 16.2k]
  ------------------
  131|     14|        dest->size = 0;         // <--- This is important.
  132|     14|        return true;            // output was just cleared, so they match
  133|     14|    }
  134|  16.2k|    if (dest->allocation_size < source->size) {
  ------------------
  |  Branch (134:9): [True: 14.2k, False: 2.02k]
  ------------------
  135|  14.2k|        if (!realloc_array(dest, source->size)) {
  ------------------
  |  Branch (135:13): [True: 0, False: 14.2k]
  ------------------
  136|      0|            return false;
  137|      0|        }
  138|  14.2k|    }
  139|  16.2k|    dest->size = source->size;
  140|  16.2k|    memcpy(dest->keys, source->keys, dest->size * sizeof(uint16_t));
  141|       |    // we go through the containers, turning them into shared containers...
  142|  16.2k|    if (copy_on_write) {
  ------------------
  |  Branch (142:9): [True: 0, False: 16.2k]
  ------------------
  143|      0|        for (int32_t i = 0; i < dest->size; ++i) {
  ------------------
  |  Branch (143:29): [True: 0, False: 0]
  ------------------
  144|      0|            source->containers[i] = get_copy_of_container(
  145|      0|                source->containers[i], &source->typecodes[i], copy_on_write);
  146|      0|        }
  147|       |        // we do a shallow copy to the other bitmap
  148|      0|        memcpy(dest->containers, source->containers,
  149|      0|               dest->size * sizeof(container_t *));
  150|      0|        memcpy(dest->typecodes, source->typecodes,
  151|      0|               dest->size * sizeof(uint8_t));
  152|  16.2k|    } else {
  153|  16.2k|        memcpy(dest->typecodes, source->typecodes,
  154|  16.2k|               dest->size * sizeof(uint8_t));
  155|   167k|        for (int32_t i = 0; i < dest->size; i++) {
  ------------------
  |  Branch (155:29): [True: 150k, False: 16.2k]
  ------------------
  156|   150k|            dest->containers[i] =
  157|   150k|                container_clone(source->containers[i], source->typecodes[i]);
  158|   150k|            if (dest->containers[i] == NULL) {
  ------------------
  |  Branch (158:17): [True: 0, False: 150k]
  ------------------
  159|      0|                for (int32_t j = 0; j < i; j++) {
  ------------------
  |  Branch (159:37): [True: 0, False: 0]
  ------------------
  160|      0|                    container_free(dest->containers[j], dest->typecodes[j]);
  161|      0|                }
  162|      0|                ra_clear_without_containers(dest);
  163|      0|                return false;
  164|      0|            }
  165|   150k|        }
  166|  16.2k|    }
  167|  16.2k|    return true;
  168|  16.2k|}
ra_clear_containers:
  170|  87.6k|void ra_clear_containers(roaring_array_t *ra) {
  171|   530k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (171:25): [True: 443k, False: 87.6k]
  ------------------
  172|   443k|        container_free(ra->containers[i], ra->typecodes[i]);
  173|   443k|    }
  174|  87.6k|}
ra_reset:
  176|  71.2k|void ra_reset(roaring_array_t *ra) {
  177|  71.2k|    ra_clear_containers(ra);
  178|  71.2k|    ra->size = 0;
  179|  71.2k|    ra_shrink_to_fit(ra);
  180|  71.2k|}
ra_clear_without_containers:
  182|  2.47k|void ra_clear_without_containers(roaring_array_t *ra) {
  183|  2.47k|    roaring_free(
  184|  2.47k|        ra->containers);  // keys and typecodes are allocated with containers
  185|  2.47k|    ra->size = 0;
  186|  2.47k|    ra->allocation_size = 0;
  187|  2.47k|    ra->containers = NULL;
  188|  2.47k|    ra->keys = NULL;
  189|       |    ra->typecodes = NULL;
  190|  2.47k|}
ra_clear:
  192|     53|void ra_clear(roaring_array_t *ra) {
  193|     53|    ra_clear_containers(ra);
  194|     53|    ra_clear_without_containers(ra);
  195|     53|}
extend_array:
  197|  95.6k|bool extend_array(roaring_array_t *ra, int32_t k) {
  198|  95.6k|    int32_t desired_size = ra->size + k;
  199|  95.6k|    const int32_t max_containers = 65536;
  200|  95.6k|    assert(desired_size <= max_containers);
  201|  95.6k|    if (desired_size > ra->allocation_size) {
  ------------------
  |  Branch (201:9): [True: 19.4k, False: 76.1k]
  ------------------
  202|  19.4k|        int32_t new_capacity =
  203|  19.4k|            (ra->size < 1024) ? 2 * desired_size : 5 * desired_size / 4;
  ------------------
  |  Branch (203:13): [True: 19.4k, False: 0]
  ------------------
  204|  19.4k|        if (new_capacity > max_containers) {
  ------------------
  |  Branch (204:13): [True: 0, False: 19.4k]
  ------------------
  205|      0|            new_capacity = max_containers;
  206|      0|        }
  207|       |
  208|  19.4k|        return realloc_array(ra, new_capacity);
  209|  19.4k|    }
  210|  76.1k|    return true;
  211|  95.6k|}
ra_append:
  214|  29.8k|               uint8_t typecode) {
  215|  29.8k|    extend_array(ra, 1);
  216|  29.8k|    const int32_t pos = ra->size;
  217|       |
  218|  29.8k|    ra->keys[pos] = key;
  219|  29.8k|    ra->containers[pos] = c;
  220|  29.8k|    ra->typecodes[pos] = typecode;
  221|  29.8k|    ra->size++;
  222|  29.8k|}
ra_append_copy_range:
  255|  28.9k|                          bool copy_on_write) {
  256|  28.9k|    extend_array(ra, end_index - start_index);
  257|   195k|    for (int32_t i = start_index; i < end_index; ++i) {
  ------------------
  |  Branch (257:35): [True: 166k, False: 28.9k]
  ------------------
  258|   166k|        const int32_t pos = ra->size;
  259|   166k|        ra->keys[pos] = sa->keys[i];
  260|   166k|        if (copy_on_write) {
  ------------------
  |  Branch (260:13): [True: 0, False: 166k]
  ------------------
  261|      0|            sa->containers[i] = get_copy_of_container(
  262|      0|                sa->containers[i], &sa->typecodes[i], copy_on_write);
  263|      0|            ra->containers[pos] = sa->containers[i];
  264|      0|            ra->typecodes[pos] = sa->typecodes[i];
  265|   166k|        } else {
  266|   166k|            ra->containers[pos] =
  267|   166k|                container_clone(sa->containers[i], sa->typecodes[i]);
  268|   166k|            ra->typecodes[pos] = sa->typecodes[i];
  269|   166k|        }
  270|   166k|        ra->size++;
  271|   166k|    }
  272|  28.9k|}
ra_advance_until_freeing:
  341|     74|int32_t ra_advance_until_freeing(roaring_array_t *ra, uint16_t x, int32_t pos) {
  342|    148|    while (pos < ra->size && ra->keys[pos] < x) {
  ------------------
  |  Branch (342:12): [True: 148, False: 0]
  |  Branch (342:30): [True: 74, False: 74]
  ------------------
  343|     74|        container_free(ra->containers[pos], ra->typecodes[pos]);
  344|     74|        ++pos;
  345|     74|    }
  346|     74|    return pos;
  347|     74|}
ra_insert_new_key_value_at:
  350|  35.5k|                                container_t *c, uint8_t typecode) {
  351|  35.5k|    extend_array(ra, 1);
  352|       |    // May be an optimization opportunity with DIY memmove
  353|  35.5k|    memmove(&(ra->keys[i + 1]), &(ra->keys[i]),
  354|  35.5k|            sizeof(uint16_t) * (ra->size - i));
  355|  35.5k|    memmove(&(ra->containers[i + 1]), &(ra->containers[i]),
  356|  35.5k|            sizeof(container_t *) * (ra->size - i));
  357|  35.5k|    memmove(&(ra->typecodes[i + 1]), &(ra->typecodes[i]),
  358|  35.5k|            sizeof(uint8_t) * (ra->size - i));
  359|  35.5k|    ra->keys[i] = key;
  360|  35.5k|    ra->containers[i] = c;
  361|  35.5k|    ra->typecodes[i] = typecode;
  362|  35.5k|    ra->size++;
  363|  35.5k|}
ra_downsize:
  370|  13.8k|void ra_downsize(roaring_array_t *ra, int32_t new_length) {
  371|       |    assert(new_length <= ra->size);
  372|  13.8k|    ra->size = new_length;
  373|  13.8k|}
ra_remove_at_index:
  375|  6.19k|void ra_remove_at_index(roaring_array_t *ra, int32_t i) {
  376|  6.19k|    memmove(&(ra->containers[i]), &(ra->containers[i + 1]),
  377|  6.19k|            sizeof(container_t *) * (ra->size - i - 1));
  378|  6.19k|    memmove(&(ra->keys[i]), &(ra->keys[i + 1]),
  379|  6.19k|            sizeof(uint16_t) * (ra->size - i - 1));
  380|  6.19k|    memmove(&(ra->typecodes[i]), &(ra->typecodes[i + 1]),
  381|  6.19k|            sizeof(uint8_t) * (ra->size - i - 1));
  382|  6.19k|    ra->size--;
  383|  6.19k|}
ra_remove_at_index_and_free:
  385|     72|void ra_remove_at_index_and_free(roaring_array_t *ra, int32_t i) {
  386|     72|    container_free(ra->containers[i], ra->typecodes[i]);
  387|     72|    ra_remove_at_index(ra, i);
  388|     72|}
ra_copy_range:
  396|     25|                   uint32_t new_begin) {
  397|     25|    assert(begin <= end);
  398|     25|    assert(new_begin < begin);
  399|       |
  400|     25|    const int range = end - begin;
  401|       |
  402|       |    // We ensure to previously have freed overwritten containers
  403|       |    // that are not copied elsewhere
  404|       |
  405|     25|    memmove(&(ra->containers[new_begin]), &(ra->containers[begin]),
  406|     25|            sizeof(container_t *) * range);
  407|     25|    memmove(&(ra->keys[new_begin]), &(ra->keys[begin]),
  408|     25|            sizeof(uint16_t) * range);
  409|     25|    memmove(&(ra->typecodes[new_begin]), &(ra->typecodes[begin]),
  410|     25|            sizeof(uint8_t) * range);
  411|     25|}
ra_shift_tail:
  413|  1.90k|void ra_shift_tail(roaring_array_t *ra, int32_t count, int32_t distance) {
  414|  1.90k|    if (distance > 0) {
  ------------------
  |  Branch (414:9): [True: 1.27k, False: 628]
  ------------------
  415|  1.27k|        extend_array(ra, distance);
  416|  1.27k|    }
  417|  1.90k|    int32_t srcpos = ra->size - count;
  418|  1.90k|    int32_t dstpos = srcpos + distance;
  419|  1.90k|    memmove(&(ra->keys[dstpos]), &(ra->keys[srcpos]), sizeof(uint16_t) * count);
  420|  1.90k|    memmove(&(ra->containers[dstpos]), &(ra->containers[srcpos]),
  421|  1.90k|            sizeof(container_t *) * count);
  422|  1.90k|    memmove(&(ra->typecodes[dstpos]), &(ra->typecodes[srcpos]),
  423|  1.90k|            sizeof(uint8_t) * count);
  424|  1.90k|    ra->size += distance;
  425|  1.90k|}
ra_to_uint32_array:
  427|  7.12k|void ra_to_uint32_array(const roaring_array_t *ra, uint32_t *ans) {
  428|  7.12k|    size_t ctr = 0;
  429|  69.5k|    for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (429:25): [True: 62.3k, False: 7.12k]
  ------------------
  430|  62.3k|        int num_added = container_to_uint32_array(
  431|  62.3k|            ans + ctr, ra->containers[i], ra->typecodes[i],
  432|  62.3k|            ((uint32_t)ra->keys[i]) << 16);
  433|  62.3k|        ctr += num_added;
  434|  62.3k|    }
  435|  7.12k|}
ra_has_run_container:
  437|  21.3k|bool ra_has_run_container(const roaring_array_t *ra) {
  438|   174k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (438:25): [True: 155k, False: 19.0k]
  ------------------
  439|   155k|        if (get_container_type(ra->containers[k], ra->typecodes[k]) ==
  ------------------
  |  Branch (439:13): [True: 2.34k, False: 153k]
  ------------------
  440|   155k|            RUN_CONTAINER_TYPE)
  ------------------
  |  |   50|   155k|#define RUN_CONTAINER_TYPE 3
  ------------------
  441|  2.34k|            return true;
  442|   155k|    }
  443|  19.0k|    return false;
  444|  21.3k|}
ra_portable_header_size:
  446|  14.2k|uint32_t ra_portable_header_size(const roaring_array_t *ra) {
  447|  14.2k|    return ra_portable_header_size_from_counts(ra->size,
  448|  14.2k|                                               ra_has_run_container(ra));
  449|  14.2k|}
ra_portable_header_size_from_counts:
  452|  14.2k|                                             bool hasrun) {
  453|  14.2k|    if (hasrun) {
  ------------------
  |  Branch (453:9): [True: 2.34k, False: 11.9k]
  ------------------
  454|       |        // for small bitmaps, we omit the offsets
  455|  2.34k|        if (num_containers < NO_OFFSET_THRESHOLD) {
  ------------------
  |  Branch (455:13): [True: 2.34k, False: 0]
  ------------------
  456|  2.34k|            return 4 + (num_containers + 7) / 8 + 4 * num_containers;
  457|  2.34k|        }
  458|       |        // - 4 because we pack the size with the cookie
  459|      0|        return 4 + (num_containers + 7) / 8 + 8 * num_containers;
  460|  11.9k|    } else {
  461|  11.9k|        return 4 + 4 + 8 * num_containers;
  462|  11.9k|    }
  463|  14.2k|}
ra_portable_size_in_bytes:
  465|  14.2k|size_t ra_portable_size_in_bytes(const roaring_array_t *ra) {
  466|  14.2k|    size_t count = ra_portable_header_size(ra);
  467|       |
  468|  95.7k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (468:25): [True: 81.5k, False: 14.2k]
  ------------------
  469|  81.5k|        count += container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  470|  81.5k|    }
  471|  14.2k|    return count;
  472|  14.2k|}
ra_portable_serialize:
  476|  7.12k|size_t ra_portable_serialize(const roaring_array_t *ra, char *buf) {
  477|  7.12k|    char *initbuf = buf;
  478|  7.12k|    uint32_t startOffset = 0;
  479|  7.12k|    bool hasrun = ra_has_run_container(ra);
  480|  7.12k|    if (hasrun) {
  ------------------
  |  Branch (480:9): [True: 0, False: 7.12k]
  ------------------
  481|      0|        uint32_t cookie = SERIAL_COOKIE | ((uint32_t)(ra->size - 1) << 16);
  482|      0|        uint32_t cookie_le = croaring_htole32(cookie);
  ------------------
  |  |  545|      0|#define croaring_htole32(x) (x)
  ------------------
  483|      0|        memcpy(buf, &cookie_le, sizeof(cookie_le));
  484|      0|        buf += sizeof(cookie_le);
  485|      0|        uint32_t s = (ra->size + 7) / 8;
  486|      0|        memset(buf, 0, s);
  487|      0|        for (int32_t i = 0; i < ra->size; ++i) {
  ------------------
  |  Branch (487:29): [True: 0, False: 0]
  ------------------
  488|      0|            if (get_container_type(ra->containers[i], ra->typecodes[i]) ==
  ------------------
  |  Branch (488:17): [True: 0, False: 0]
  ------------------
  489|      0|                RUN_CONTAINER_TYPE) {
  ------------------
  |  |   50|      0|#define RUN_CONTAINER_TYPE 3
  ------------------
  490|      0|                buf[i / 8] |= 1 << (i % 8);
  491|      0|            }
  492|      0|        }
  493|      0|        buf += s;
  494|      0|        if (ra->size < NO_OFFSET_THRESHOLD) {
  ------------------
  |  Branch (494:13): [True: 0, False: 0]
  ------------------
  495|      0|            startOffset = 4 + 4 * ra->size + s;
  496|      0|        } else {
  497|      0|            startOffset = 4 + 8 * ra->size + s;
  498|      0|        }
  499|  7.12k|    } else {  // backwards compatibility
  500|  7.12k|        uint32_t cookie = SERIAL_COOKIE_NO_RUNCONTAINER;
  501|  7.12k|        uint32_t cookie_le = croaring_htole32(cookie);
  ------------------
  |  |  545|  7.12k|#define croaring_htole32(x) (x)
  ------------------
  502|  7.12k|        memcpy(buf, &cookie_le, sizeof(cookie_le));
  503|  7.12k|        buf += sizeof(cookie_le);
  504|  7.12k|        uint32_t size_le = croaring_htole32((uint32_t)ra->size);
  ------------------
  |  |  545|  7.12k|#define croaring_htole32(x) (x)
  ------------------
  505|  7.12k|        memcpy(buf, &size_le, sizeof(size_le));
  506|  7.12k|        buf += sizeof(size_le);
  507|       |
  508|  7.12k|        startOffset = 4 + 4 + 4 * ra->size + 4 * ra->size;
  509|  7.12k|    }
  510|  81.5k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (510:25): [True: 74.3k, False: 7.12k]
  ------------------
  511|  74.3k|        uint16_t key_le = croaring_htole16(ra->keys[k]);
  ------------------
  |  |  544|  74.3k|#define croaring_htole16(x) (x)
  ------------------
  512|  74.3k|        memcpy(buf, &key_le, sizeof(key_le));
  513|  74.3k|        buf += sizeof(key_le);
  514|       |        // get_cardinality returns a value in [1,1<<16], subtracting one
  515|       |        // we get [0,1<<16 - 1] which fits in 16 bits
  516|  74.3k|        uint16_t card = (uint16_t)(container_get_cardinality(ra->containers[k],
  517|  74.3k|                                                             ra->typecodes[k]) -
  518|  74.3k|                                   1);
  519|  74.3k|        uint16_t card_le = croaring_htole16(card);
  ------------------
  |  |  544|  74.3k|#define croaring_htole16(x) (x)
  ------------------
  520|  74.3k|        memcpy(buf, &card_le, sizeof(card_le));
  521|  74.3k|        buf += sizeof(card_le);
  522|  74.3k|    }
  523|  7.12k|    if ((!hasrun) || (ra->size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (523:9): [True: 7.12k, False: 0]
  |  Branch (523:22): [True: 0, False: 0]
  ------------------
  524|       |        // writing the containers offsets
  525|  81.5k|        for (int32_t k = 0; k < ra->size; k++) {
  ------------------
  |  Branch (525:29): [True: 74.3k, False: 7.12k]
  ------------------
  526|  74.3k|            uint32_t off_le = croaring_htole32(startOffset);
  ------------------
  |  |  545|  74.3k|#define croaring_htole32(x) (x)
  ------------------
  527|  74.3k|            memcpy(buf, &off_le, sizeof(off_le));
  528|  74.3k|            buf += sizeof(off_le);
  529|  74.3k|            startOffset =
  530|  74.3k|                startOffset +
  531|  74.3k|                container_size_in_bytes(ra->containers[k], ra->typecodes[k]);
  532|  74.3k|        }
  533|  7.12k|    }
  534|  81.5k|    for (int32_t k = 0; k < ra->size; ++k) {
  ------------------
  |  Branch (534:25): [True: 74.3k, False: 7.12k]
  ------------------
  535|  74.3k|        buf += container_write(ra->containers[k], ra->typecodes[k], buf);
  536|  74.3k|    }
  537|  7.12k|    return buf - initbuf;
  538|  7.12k|}
ra_portable_deserialize:
  641|  14.2k|                             const size_t maxbytes, size_t *readbytes) {
  642|  14.2k|    *readbytes = sizeof(int32_t);  // for cookie
  643|  14.2k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (643:9): [True: 6.80k, False: 7.45k]
  ------------------
  644|       |        // Ran out of bytes while reading first 4 bytes.
  645|  6.80k|        return false;
  646|  6.80k|    }
  647|  7.45k|    uint32_t cookie;
  648|  7.45k|    memcpy(&cookie, buf, sizeof(int32_t));
  649|  7.45k|    cookie = croaring_letoh32(cookie);
  ------------------
  |  |  551|  7.45k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  545|  7.45k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  650|  7.45k|    buf += sizeof(uint32_t);
  651|  7.45k|    if ((cookie & 0xFFFF) != SERIAL_COOKIE &&
  ------------------
  |  Branch (651:9): [True: 7.38k, False: 68]
  ------------------
  652|  7.38k|        cookie != SERIAL_COOKIE_NO_RUNCONTAINER) {
  ------------------
  |  Branch (652:9): [True: 182, False: 7.20k]
  ------------------
  653|       |        // "I failed to find one of the right cookies.
  654|    182|        return false;
  655|    182|    }
  656|  7.26k|    int32_t size;
  657|       |
  658|  7.26k|    if ((cookie & 0xFFFF) == SERIAL_COOKIE)
  ------------------
  |  Branch (658:9): [True: 68, False: 7.20k]
  ------------------
  659|     68|        size = (cookie >> 16) + 1;
  660|  7.20k|    else {
  661|  7.20k|        *readbytes += sizeof(int32_t);
  662|  7.20k|        if (*readbytes > maxbytes) {
  ------------------
  |  Branch (662:13): [True: 4, False: 7.19k]
  ------------------
  663|       |            // Ran out of bytes while reading second part of the cookie.
  664|      4|            return false;
  665|      4|        }
  666|  7.19k|        uint32_t size_le;
  667|  7.19k|        memcpy(&size_le, buf, sizeof(int32_t));
  668|  7.19k|        size = (int32_t)croaring_letoh32(size_le);
  ------------------
  |  |  551|  7.19k|#define croaring_letoh32(x) croaring_htole32(x)
  |  |  ------------------
  |  |  |  |  545|  7.19k|#define croaring_htole32(x) (x)
  |  |  ------------------
  ------------------
  669|  7.19k|        buf += sizeof(uint32_t);
  670|  7.19k|    }
  671|  7.26k|    if (size < 0) {
  ------------------
  |  Branch (671:9): [True: 17, False: 7.24k]
  ------------------
  672|       |        // You cannot have a negative number of containers, the data must be
  673|       |        // corrupted.
  674|     17|        return false;
  675|     17|    }
  676|  7.24k|    if (size > (1 << 16)) {
  ------------------
  |  Branch (676:9): [True: 14, False: 7.23k]
  ------------------
  677|       |        // You cannot have so many containers, the data must be corrupted.
  678|     14|        return false;
  679|     14|    }
  680|  7.23k|    const char *bitmapOfRunContainers = NULL;
  681|  7.23k|    bool hasrun = (cookie & 0xFFFF) == SERIAL_COOKIE;
  682|  7.23k|    if (hasrun) {
  ------------------
  |  Branch (682:9): [True: 68, False: 7.16k]
  ------------------
  683|     68|        int32_t s = (size + 7) / 8;
  684|     68|        *readbytes += s;
  685|     68|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (685:13): [True: 2, False: 66]
  ------------------
  686|       |            // Ran out of bytes while reading run bitmap.
  687|      2|            return false;
  688|      2|        }
  689|     66|        bitmapOfRunContainers = buf;
  690|     66|        buf += s;
  691|     66|    }
  692|  7.23k|    const char *keyscards = buf;
  693|       |
  694|  7.23k|    *readbytes += size * 2 * sizeof(uint16_t);
  695|  7.23k|    if (*readbytes > maxbytes) {
  ------------------
  |  Branch (695:9): [True: 32, False: 7.19k]
  ------------------
  696|       |        // Ran out of bytes while reading key-cardinality array.
  697|     32|        return false;
  698|     32|    }
  699|  7.19k|    buf += size * 2 * sizeof(uint16_t);
  700|       |
  701|  7.19k|    bool is_ok = ra_init_with_capacity(answer, size);
  702|  7.19k|    if (!is_ok) {
  ------------------
  |  Branch (702:9): [True: 0, False: 7.19k]
  ------------------
  703|       |        // Failed to allocate memory for roaring array. Bailing out.
  704|      0|        return false;
  705|      0|    }
  706|       |
  707|  81.7k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (707:25): [True: 74.5k, False: 7.19k]
  ------------------
  708|  74.5k|        uint16_t tmp;
  709|  74.5k|        memcpy(&tmp, keyscards + 4 * k, sizeof(tmp));
  710|  74.5k|        answer->keys[k] = croaring_letoh16(tmp);
  ------------------
  |  |  550|  74.5k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  544|  74.5k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  711|  74.5k|    }
  712|  7.19k|    if ((!hasrun) || (size >= NO_OFFSET_THRESHOLD)) {
  ------------------
  |  Branch (712:9): [True: 7.13k, False: 61]
  |  Branch (712:22): [True: 19, False: 42]
  ------------------
  713|  7.15k|        *readbytes += size * 4;
  714|  7.15k|        if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (714:13): [True: 5, False: 7.15k]
  ------------------
  715|       |            // Ran out of bytes while reading offsets.
  716|      5|            ra_clear(answer);  // we need to clear the containers already
  717|       |                               // allocated, and the roaring array
  718|      5|            return false;
  719|      5|        }
  720|       |
  721|       |        // skipping the offsets
  722|  7.15k|        buf += size * 4;
  723|  7.15k|    }
  724|       |    // Reading the containers
  725|  81.6k|    for (int32_t k = 0; k < size; ++k) {
  ------------------
  |  Branch (725:25): [True: 74.5k, False: 7.14k]
  ------------------
  726|  74.5k|        uint16_t tmp;
  727|  74.5k|        memcpy(&tmp, keyscards + 4 * k + 2, sizeof(tmp));
  728|  74.5k|        tmp = croaring_letoh16(tmp);
  ------------------
  |  |  550|  74.5k|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  544|  74.5k|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  729|  74.5k|        uint32_t thiscard = tmp + 1;
  730|  74.5k|        bool isbitmap = (thiscard > DEFAULT_MAX_SIZE);
  731|  74.5k|        bool isrun = false;
  732|  74.5k|        if (hasrun) {
  ------------------
  |  Branch (732:13): [True: 141, False: 74.3k]
  ------------------
  733|    141|            if ((bitmapOfRunContainers[k / 8] & (1 << (k % 8))) != 0) {
  ------------------
  |  Branch (733:17): [True: 83, False: 58]
  ------------------
  734|     83|                isbitmap = false;
  735|     83|                isrun = true;
  736|     83|            }
  737|    141|        }
  738|  74.5k|        if (isbitmap) {
  ------------------
  |  Branch (738:13): [True: 66.6k, False: 7.84k]
  ------------------
  739|       |            // we check that the read is allowed
  740|  66.6k|            size_t containersize =
  741|  66.6k|                BITSET_CONTAINER_SIZE_IN_WORDS * sizeof(uint64_t);
  742|  66.6k|            *readbytes += containersize;
  743|  66.6k|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (743:17): [True: 7, False: 66.6k]
  ------------------
  744|       |                // Running out of bytes while reading a bitset container.
  745|      7|                ra_clear(answer);  // we need to clear the containers already
  746|       |                                   // allocated, and the roaring array
  747|      7|                return false;
  748|      7|            }
  749|       |            // it is now safe to read
  750|  66.6k|            bitset_container_t *c = bitset_container_create_uninitialized();
  751|  66.6k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (751:17): [True: 0, False: 66.6k]
  ------------------
  752|       |                // Failed to allocate memory for a bitset container.
  753|      0|                ra_clear(answer);  // we need to clear the containers already
  754|       |                                   // allocated, and the roaring array
  755|      0|                return false;
  756|      0|            }
  757|  66.6k|            answer->size++;
  758|  66.6k|            buf += bitset_container_read(thiscard, c, buf);
  759|  66.6k|            answer->containers[k] = c;
  760|  66.6k|            answer->typecodes[k] = BITSET_CONTAINER_TYPE;
  ------------------
  |  |   48|  66.6k|#define BITSET_CONTAINER_TYPE 1
  ------------------
  761|  66.6k|        } else if (isrun) {
  ------------------
  |  Branch (761:20): [True: 83, False: 7.76k]
  ------------------
  762|       |            // we check that the read is allowed
  763|     83|            *readbytes += sizeof(uint16_t);
  764|     83|            if (*readbytes > maxbytes) {
  ------------------
  |  Branch (764:17): [True: 9, False: 74]
  ------------------
  765|       |                // Running out of bytes while reading a run container (header).
  766|      9|                ra_clear(answer);  // we need to clear the containers already
  767|       |                                   // allocated, and the roaring array
  768|      9|                return false;
  769|      9|            }
  770|     74|            uint16_t n_runs;
  771|     74|            memcpy(&n_runs, buf, sizeof(uint16_t));
  772|     74|            n_runs = croaring_letoh16(n_runs);
  ------------------
  |  |  550|     74|#define croaring_letoh16(x) croaring_htole16(x)
  |  |  ------------------
  |  |  |  |  544|     74|#define croaring_htole16(x) (x)
  |  |  ------------------
  ------------------
  773|     74|            size_t containersize = n_runs * sizeof(rle16_t);
  774|     74|            *readbytes += containersize;
  775|     74|            if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (775:17): [True: 25, False: 49]
  ------------------
  776|       |                // Running out of bytes while reading a run container.
  777|     25|                ra_clear(answer);  // we need to clear the containers already
  778|       |                                   // allocated, and the roaring array
  779|     25|                return false;
  780|     25|            }
  781|       |            // it is now safe to read
  782|       |
  783|     49|            run_container_t *c = run_container_create();
  784|     49|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (784:17): [True: 0, False: 49]
  ------------------
  785|       |                // Failed to allocate memory for a run container.
  786|      0|                ra_clear(answer);  // we need to clear the containers already
  787|       |                                   // allocated, and the roaring array
  788|      0|                return false;
  789|      0|            }
  790|     49|            answer->size++;
  791|     49|            buf += run_container_read(thiscard, c, buf);
  792|     49|            answer->containers[k] = c;
  793|     49|            answer->typecodes[k] = RUN_CONTAINER_TYPE;
  ------------------
  |  |   50|     49|#define RUN_CONTAINER_TYPE 3
  ------------------
  794|  7.76k|        } else {
  795|       |            // we check that the read is allowed
  796|  7.76k|            size_t containersize = thiscard * sizeof(uint16_t);
  797|  7.76k|            *readbytes += containersize;
  798|  7.76k|            if (*readbytes > maxbytes) {  // data is corrupted?
  ------------------
  |  Branch (798:17): [True: 7, False: 7.75k]
  ------------------
  799|       |                // Running out of bytes while reading an array container.
  800|      7|                ra_clear(answer);  // we need to clear the containers already
  801|       |                                   // allocated, and the roaring array
  802|      7|                return false;
  803|      7|            }
  804|       |            // it is now safe to read
  805|  7.75k|            array_container_t *c =
  806|  7.75k|                array_container_create_given_capacity(thiscard);
  807|  7.75k|            if (c == NULL) {  // memory allocation failure
  ------------------
  |  Branch (807:17): [True: 0, False: 7.75k]
  ------------------
  808|       |                // Failed to allocate memory for an array container.
  809|      0|                ra_clear(answer);  // we need to clear the containers already
  810|       |                                   // allocated, and the roaring array
  811|      0|                return false;
  812|      0|            }
  813|  7.75k|            answer->size++;
  814|  7.75k|            buf += array_container_read(thiscard, c, buf);
  815|  7.75k|            answer->containers[k] = c;
  816|  7.75k|            answer->typecodes[k] = ARRAY_CONTAINER_TYPE;
  ------------------
  |  |   49|  7.75k|#define ARRAY_CONTAINER_TYPE 2
  ------------------
  817|  7.75k|        }
  818|  74.5k|    }
  819|  7.14k|    return true;
  820|  7.19k|}
roaring_array.c:realloc_array:
   42|   104k|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|   104k|    if (new_capacity == 0) {
  ------------------
  |  Branch (48:9): [True: 64.1k, False: 40.8k]
  ------------------
   49|  64.1k|        roaring_free(ra->containers);
   50|  64.1k|        ra->containers = NULL;
   51|  64.1k|        ra->keys = NULL;
   52|  64.1k|        ra->typecodes = NULL;
   53|  64.1k|        ra->allocation_size = 0;
   54|  64.1k|        return true;
   55|  64.1k|    }
   56|  40.8k|    const size_t memoryneeded =
   57|  40.8k|        new_capacity *
   58|  40.8k|        (sizeof(uint16_t) + sizeof(container_t *) + sizeof(uint8_t));
   59|  40.8k|    void *bigalloc = roaring_malloc(memoryneeded);
   60|  40.8k|    if (!bigalloc) return false;
  ------------------
  |  Branch (60:9): [True: 0, False: 40.8k]
  ------------------
   61|  40.8k|    void *oldbigalloc = ra->containers;
   62|  40.8k|    container_t **newcontainers = (container_t **)bigalloc;
   63|  40.8k|    uint16_t *newkeys = (uint16_t *)(newcontainers + new_capacity);
   64|  40.8k|    uint8_t *newtypecodes = (uint8_t *)(newkeys + new_capacity);
   65|  40.8k|    assert((char *)(newtypecodes + new_capacity) ==
   66|  40.8k|           (char *)bigalloc + memoryneeded);
   67|  40.8k|    if (ra->size > 0) {
  ------------------
  |  Branch (67:9): [True: 12.3k, False: 28.4k]
  ------------------
   68|  12.3k|        memcpy(newcontainers, ra->containers, sizeof(container_t *) * ra->size);
   69|  12.3k|        memcpy(newkeys, ra->keys, sizeof(uint16_t) * ra->size);
   70|  12.3k|        memcpy(newtypecodes, ra->typecodes, sizeof(uint8_t) * ra->size);
   71|  12.3k|    }
   72|  40.8k|    ra->containers = newcontainers;
   73|  40.8k|    ra->keys = newkeys;
   74|  40.8k|    ra->typecodes = newtypecodes;
   75|  40.8k|    ra->allocation_size = new_capacity;
   76|  40.8k|    roaring_free(oldbigalloc);
   77|       |    return true;
   78|  40.8k|}

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

