_ZN7roaring7RoaringC2EmPKj:
   85|  12.3k|    Roaring(size_t n, const uint32_t *data) : Roaring() {
   86|  12.3k|        api::roaring_bitmap_add_many(&roaring, n, data);
   87|  12.3k|    }
_ZN7roaring7RoaringC2Ev:
   76|  18.4k|    Roaring() : roaring{} {
   77|       |        // The empty constructor roaring{} silences warnings from pedantic
   78|       |        // static analyzers.
   79|  18.4k|        api::roaring_bitmap_init_cleared(&roaring);
   80|  18.4k|    }
_ZN7roaring7RoaringD2Ev:
  907|  55.3k|    ~Roaring() {
  908|  55.3k|        if (!(roaring.high_low_container.flags & ROARING_FLAG_FROZEN)) {
  ------------------
  |  |   47|  55.3k|#define ROARING_FLAG_FROZEN UINT8_C(0x2)
  ------------------
  |  Branch (908:13): [True: 55.3k, False: 0]
  ------------------
  909|  55.3k|            api::roaring_bitmap_clear(&roaring);
  910|  55.3k|        } else {
  911|       |            // The roaring member variable copies the `roaring_bitmap_t` and
  912|       |            // nested `roaring_array_t` structures by value and is freed in the
  913|       |            // constructor, however the underlying memory arena used for the
  914|       |            // container data is not freed with it. Here we derive the arena
  915|       |            // pointer from the second arena allocation in
  916|       |            // `roaring_bitmap_frozen_view` and free it as well.
  917|      0|            roaring_bitmap_free(
  918|      0|                (roaring_bitmap_t *)((char *)
  919|      0|                                         roaring.high_low_container.containers -
  920|      0|                                     sizeof(roaring_bitmap_t)));
  921|      0|        }
  922|  55.3k|    }
_ZN7roaring7Roaring11runOptimizeEv:
  487|  12.3k|    bool runOptimize() noexcept {
  488|  12.3k|        return api::roaring_bitmap_run_optimize(&roaring);
  489|  12.3k|    }
_ZN7roaring7Roaring11shrinkToFitEv:
  495|  6.15k|    size_t shrinkToFit() noexcept {
  496|  6.15k|        return api::roaring_bitmap_shrink_to_fit(&roaring);
  497|  6.15k|    }
_ZN7roaring7Roaring3addEj:
  198|  6.15k|    void add(uint32_t x) noexcept { api::roaring_bitmap_add(&roaring, x); }
_ZN7roaring7Roaring10addCheckedEj:
  205|  6.15k|    bool addChecked(uint32_t x) noexcept {
  206|  6.15k|        return api::roaring_bitmap_add_checked(&roaring, x);
  207|  6.15k|    }
_ZN7roaring7Roaring8addRangeEmm:
  212|  6.15k|    void addRange(const uint64_t min, const uint64_t max) noexcept {
  213|  6.15k|        return api::roaring_bitmap_add_range(&roaring, min, max);
  214|  6.15k|    }
_ZN7roaring7Roaring7addManyEmPKj:
  226|  6.15k|    void addMany(size_t n_args, const uint32_t *vals) noexcept {
  227|  6.15k|        api::roaring_bitmap_add_many(&roaring, n_args, vals);
  228|  6.15k|    }
_ZN7roaring7Roaring6removeEj:
  258|  6.15k|    void remove(uint32_t x) noexcept {
  259|  6.15k|        api::roaring_bitmap_remove(&roaring, x);
  260|  6.15k|    }
_ZN7roaring7Roaring13removeCheckedEj:
  267|  6.15k|    bool removeChecked(uint32_t x) noexcept {
  268|  6.15k|        return api::roaring_bitmap_remove_checked(&roaring, x);
  269|  6.15k|    }
_ZN7roaring7Roaring11removeRangeEmm:
  274|  6.15k|    void removeRange(uint64_t min, uint64_t max) noexcept {
  275|  6.15k|        return api::roaring_bitmap_remove_range(&roaring, min, max);
  276|  6.15k|    }
_ZN7roaring7Roaring17removeRangeClosedEjj:
  281|  6.15k|    void removeRangeClosed(uint32_t min, uint32_t max) noexcept {
  282|  6.15k|        return api::roaring_bitmap_remove_range_closed(&roaring, min, max);
  283|  6.15k|    }
_ZNK7roaring7Roaring7maximumEv:
  315|  6.15k|    uint32_t maximum() const noexcept {
  316|  6.15k|        return api::roaring_bitmap_maximum(&roaring);
  317|  6.15k|    }
_ZNK7roaring7Roaring7minimumEv:
  322|  6.15k|    uint32_t minimum() const noexcept {
  323|  6.15k|        return api::roaring_bitmap_minimum(&roaring);
  324|  6.15k|    }
_ZNK7roaring7Roaring8containsEj:
  329|  6.15k|    bool contains(uint32_t x) const noexcept {
  330|  6.15k|        return api::roaring_bitmap_contains(&roaring, x);
  331|  6.15k|    }
_ZNK7roaring7Roaring13containsRangeEmm:
  336|  6.15k|    bool containsRange(const uint64_t x, const uint64_t y) const noexcept {
  337|  6.15k|        return api::roaring_bitmap_contains_range(&roaring, x, y);
  338|  6.15k|    }
_ZNK7roaring7Roaring6selectEjPj:
  520|  6.15k|    bool select(uint32_t rnk, uint32_t *element) const noexcept {
  521|  6.15k|        return api::roaring_bitmap_select(&roaring, rnk, element);
  522|  6.15k|    }
_ZNK7roaring7Roaring9intersectERKS0_:
  534|  6.15k|    bool intersect(const Roaring &r) const noexcept {
  535|  6.15k|        return api::roaring_bitmap_intersect(&roaring, &r.roaring);
  536|  6.15k|    }
_ZNK7roaring7Roaring13jaccard_indexERKS0_:
  545|  6.15k|    double jaccard_index(const Roaring &r) const noexcept {
  546|  6.15k|        return api::roaring_bitmap_jaccard_index(&roaring, &r.roaring);
  547|  6.15k|    }
_ZNK7roaring7Roaring14or_cardinalityERKS0_:
  552|  6.15k|    uint64_t or_cardinality(const Roaring &r) const noexcept {
  553|  6.15k|        return api::roaring_bitmap_or_cardinality(&roaring, &r.roaring);
  554|  6.15k|    }
_ZNK7roaring7Roaring18andnot_cardinalityERKS0_:
  559|  6.15k|    uint64_t andnot_cardinality(const Roaring &r) const noexcept {
  560|  6.15k|        return api::roaring_bitmap_andnot_cardinality(&roaring, &r.roaring);
  561|  6.15k|    }
_ZNK7roaring7Roaring15xor_cardinalityERKS0_:
  567|  6.15k|    uint64_t xor_cardinality(const Roaring &r) const noexcept {
  568|  6.15k|        return api::roaring_bitmap_xor_cardinality(&roaring, &r.roaring);
  569|  6.15k|    }
_ZNK7roaring7Roaring4rankEj:
  579|  6.15k|    uint64_t rank(uint32_t x) const noexcept {
  580|  6.15k|        return api::roaring_bitmap_rank(&roaring, x);
  581|  6.15k|    }
_ZNK7roaring7Roaring14getSizeInBytesEb:
  726|  12.3k|    size_t getSizeInBytes(bool portable = true) const noexcept {
  727|  12.3k|        if (portable) {
  ------------------
  |  Branch (727:13): [True: 12.3k, False: 0]
  ------------------
  728|  12.3k|            return api::roaring_bitmap_portable_size_in_bytes(&roaring);
  729|  12.3k|        } else {
  730|      0|            return api::roaring_bitmap_size_in_bytes(&roaring);
  731|      0|        }
  732|  12.3k|    }
_ZNK7roaring7RoaringanERKS0_:
  788|  6.15k|    Roaring operator&(const Roaring &o) const {
  789|  6.15k|        roaring_bitmap_t *r = api::roaring_bitmap_and(&roaring, &o.roaring);
  790|  6.15k|        if (r == NULL) {
  ------------------
  |  Branch (790:13): [True: 0, False: 6.15k]
  ------------------
  791|      0|            ROARING_TERMINATE("failed materalization in and");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  792|      0|        }
  793|  6.15k|        return Roaring(r);
  794|  6.15k|    }
_ZN7roaring7RoaringC2EPNS_3api16roaring_bitmap_sE:
  102|  30.7k|    explicit Roaring(roaring_bitmap_t *s) noexcept : roaring(*s) {
  103|  30.7k|        roaring_free(s);  // deallocate the passed-in pointer
  104|  30.7k|    }
_ZNK7roaring7RoaringmiERKS0_:
  801|  6.15k|    Roaring operator-(const Roaring &o) const {
  802|  6.15k|        roaring_bitmap_t *r = api::roaring_bitmap_andnot(&roaring, &o.roaring);
  803|  6.15k|        if (r == NULL) {
  ------------------
  |  Branch (803:13): [True: 0, False: 6.15k]
  ------------------
  804|      0|            ROARING_TERMINATE("failed materalization in andnot");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  805|      0|        }
  806|  6.15k|        return Roaring(r);
  807|  6.15k|    }
_ZNK7roaring7RoaringorERKS0_:
  814|  6.15k|    Roaring operator|(const Roaring &o) const {
  815|  6.15k|        roaring_bitmap_t *r = api::roaring_bitmap_or(&roaring, &o.roaring);
  816|  6.15k|        if (r == NULL) {
  ------------------
  |  Branch (816:13): [True: 0, False: 6.15k]
  ------------------
  817|      0|            ROARING_TERMINATE("failed materalization in or");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  818|      0|        }
  819|  6.15k|        return Roaring(r);
  820|  6.15k|    }
_ZNK7roaring7RoaringeoERKS0_:
  827|  6.15k|    Roaring operator^(const Roaring &o) const {
  828|  6.15k|        roaring_bitmap_t *r = api::roaring_bitmap_xor(&roaring, &o.roaring);
  829|  6.15k|        if (r == NULL) {
  ------------------
  |  Branch (829:13): [True: 0, False: 6.15k]
  ------------------
  830|      0|            ROARING_TERMINATE("failed materalization in xor");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  831|      0|        }
  832|  6.15k|        return Roaring(r);
  833|  6.15k|    }
_ZN7roaring7RoaringoRERKS0_:
  375|  6.15k|    Roaring &operator|=(const Roaring &r) noexcept {
  376|  6.15k|        api::roaring_bitmap_or_inplace(&roaring, &r.roaring);
  377|  6.15k|        return *this;
  378|  6.15k|    }
_ZN7roaring7RoaringaNERKS0_:
  353|  6.15k|    Roaring &operator&=(const Roaring &r) noexcept {
  354|  6.15k|        api::roaring_bitmap_and_inplace(&roaring, &r.roaring);
  355|  6.15k|        return *this;
  356|  6.15k|    }
_ZN7roaring7RoaringmIERKS0_:
  363|  6.15k|    Roaring &operator-=(const Roaring &r) noexcept {
  364|  6.15k|        api::roaring_bitmap_andnot_inplace(&roaring, &r.roaring);
  365|  6.15k|        return *this;
  366|  6.15k|    }
_ZN7roaring7RoaringeOERKS0_:
  385|  6.15k|    Roaring &operator^=(const Roaring &r) noexcept {
  386|  6.15k|        api::roaring_bitmap_xor_inplace(&roaring, &r.roaring);
  387|  6.15k|        return *this;
  388|  6.15k|    }
_ZNK7roaring7RoaringeqERKS0_:
  452|  12.3k|    bool operator==(const Roaring &r) const noexcept {
  453|  12.3k|        return api::roaring_bitmap_equals(&roaring, &r.roaring);
  454|  12.3k|    }
_ZNK7roaring7Roaring11cardinalityEv:
  398|  6.15k|    uint64_t cardinality() const noexcept {
  399|  6.15k|        return api::roaring_bitmap_get_cardinality(&roaring);
  400|  6.15k|    }
_ZNK7roaring7Roaring7isEmptyEv:
  405|  12.3k|    bool isEmpty() const noexcept {
  406|  12.3k|        return api::roaring_bitmap_is_empty(&roaring);
  407|  12.3k|    }
_ZNK7roaring7Roaring13toUint32ArrayEPj:
  438|  6.15k|    void toUint32Array(uint32_t *ans) const noexcept {
  439|  6.15k|        api::roaring_bitmap_to_uint32_array(&roaring, ans);
  440|  6.15k|    }
_ZNK7roaring7Roaring8isSubsetERKS0_:
  422|  6.15k|    bool isSubset(const Roaring &r) const noexcept {
  423|  6.15k|        return api::roaring_bitmap_is_subset(&roaring, &r.roaring);
  424|  6.15k|    }
_ZNK7roaring7Roaring14isStrictSubsetERKS0_:
  429|  6.15k|    bool isStrictSubset(const Roaring &r) const noexcept {
  430|  6.15k|        return api::roaring_bitmap_is_strict_subset(&roaring, &r.roaring);
  431|  6.15k|    }
_ZN7roaring7Roaring4flipEmm:
  460|  6.15k|    void flip(uint64_t range_start, uint64_t range_end) noexcept {
  461|  6.15k|        api::roaring_bitmap_flip_inplace(&roaring, range_start, range_end);
  462|  6.15k|    }
_ZN7roaring7Roaring10flipClosedEjj:
  468|  6.15k|    void flipClosed(uint32_t range_start, uint32_t range_end) noexcept {
  469|  6.15k|        api::roaring_bitmap_flip_inplace_closed(&roaring, range_start,
  470|  6.15k|                                                range_end);
  471|  6.15k|    }
_ZN7roaring7Roaring20removeRunCompressionEv:
  477|  6.15k|    bool removeRunCompression() noexcept {
  478|  6.15k|        return api::roaring_bitmap_remove_run_compression(&roaring);
  479|  6.15k|    }
_ZN7roaring7RoaringC2ERKS0_:
  110|  6.15k|    Roaring(const Roaring &r) : Roaring() {
  111|  6.15k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (111:13): [True: 0, False: 6.15k]
  ------------------
  112|      0|            ROARING_TERMINATE("failed roaring_bitmap_overwrite in constructor");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  113|      0|        }
  114|  6.15k|        api::roaring_bitmap_set_copy_on_write(
  115|  6.15k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  116|  6.15k|    }
_ZN7roaring7RoaringC2EOS0_:
  122|  6.15k|    Roaring(Roaring &&r) noexcept : roaring(r.roaring) {
  123|       |        //
  124|       |        // !!! This clones the bits of the roaring structure to a new location
  125|       |        // and then overwrites the old bits...assuming that this will still
  126|       |        // work.  There are scenarios where this could break; e.g. if some of
  127|       |        // those bits were pointers into the structure memory itself.  If such
  128|       |        // things were possible, a roaring_bitmap_move() API would be needed.
  129|       |        //
  130|  6.15k|        api::roaring_bitmap_init_cleared(&r.roaring);
  131|  6.15k|    }
_ZN7roaring7RoaringaSERKS0_:
  152|  6.15k|    Roaring &operator=(const Roaring &r) {
  153|  6.15k|        if (!api::roaring_bitmap_overwrite(&roaring, &r.roaring)) {
  ------------------
  |  Branch (153:13): [True: 0, False: 6.15k]
  ------------------
  154|      0|            ROARING_TERMINATE("failed memory alloc in assignment");
  ------------------
  |  |   27|      0|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  155|      0|        }
  156|  6.15k|        api::roaring_bitmap_set_copy_on_write(
  157|  6.15k|            &roaring, api::roaring_bitmap_get_copy_on_write(&r.roaring));
  158|  6.15k|        return *this;
  159|  6.15k|    }
_ZN7roaring7RoaringaSEOS0_:
  165|  6.15k|    Roaring &operator=(Roaring &&r) noexcept {
  166|  6.15k|        api::roaring_bitmap_clear(&roaring);  // free this class's allocations
  167|       |
  168|       |        // !!! See notes in the Move Constructor regarding roaring_bitmap_move()
  169|       |        //
  170|  6.15k|        roaring = r.roaring;
  171|  6.15k|        api::roaring_bitmap_init_cleared(&r.roaring);
  172|       |
  173|  6.15k|        return *this;
  174|  6.15k|    }
_ZN7roaring7Roaring8readSafeEPKcm:
  700|  12.3k|    static Roaring readSafe(const char *buf, size_t maxbytes) {
  701|  12.3k|        roaring_bitmap_t *r =
  702|  12.3k|            api::roaring_bitmap_portable_deserialize_safe(buf, maxbytes);
  703|  12.3k|        if (r == NULL) {
  ------------------
  |  Branch (703:13): [True: 6.14k, False: 6.16k]
  ------------------
  704|  6.14k|            ROARING_TERMINATE("failed alloc while reading");
  ------------------
  |  |   27|  6.14k|#define ROARING_TERMINATE(_s) throw std::runtime_error(_s)
  ------------------
  705|  6.14k|        }
  706|  6.16k|        return Roaring(r);
  707|  12.3k|    }
_ZNK7roaring7Roaring5writeEPcb:
  643|  6.15k|    size_t write(char *buf, bool portable = true) const noexcept {
  644|  6.15k|        if (portable) {
  ------------------
  |  Branch (644:13): [True: 6.15k, False: 0]
  ------------------
  645|  6.15k|            return api::roaring_bitmap_portable_serialize(&roaring, buf);
  646|  6.15k|        } else {
  647|      0|            return api::roaring_bitmap_serialize(&roaring, buf);
  648|      0|        }
  649|  6.15k|    }
_ZNK7roaring7Roaring8toStringEv:
  850|  6.15k|    std::string toString() const noexcept {
  851|  6.15k|        struct iter_data {
  852|  6.15k|            std::string str{};  // The empty constructor silences warnings from
  853|       |                                // pedantic static analyzers.
  854|  6.15k|            char first_char = '{';
  855|  6.15k|        } outer_iter_data;
  856|  6.15k|        if (!isEmpty()) {
  ------------------
  |  Branch (856:13): [True: 6.14k, False: 13]
  ------------------
  857|  6.14k|            iterate(
  858|  6.14k|                [](uint32_t value, void *inner_iter_data) -> bool {
  859|  6.14k|                    ((iter_data *)inner_iter_data)->str +=
  860|  6.14k|                        ((iter_data *)inner_iter_data)->first_char;
  861|  6.14k|                    ((iter_data *)inner_iter_data)->str +=
  862|  6.14k|                        std::to_string(value);
  863|  6.14k|                    ((iter_data *)inner_iter_data)->first_char = ',';
  864|  6.14k|                    return true;
  865|  6.14k|                },
  866|  6.14k|                (void *)&outer_iter_data);
  867|  6.14k|        } else
  868|     13|            outer_iter_data.str = '{';
  869|  6.15k|        outer_iter_data.str += '}';
  870|  6.15k|        return outer_iter_data.str;
  871|  6.15k|    }
_ZNK7roaring7Roaring7iterateEPFbjPvES1_:
  508|  6.14k|    void iterate(api::roaring_iterator iterator, void *ptr) const {
  509|  6.14k|        api::roaring_iterate(&roaring, iterator, ptr);
  510|  6.14k|    }
_ZZNK7roaring7Roaring8toStringEvENKUljPvE_clEjS1_:
  858|  3.59G|                [](uint32_t value, void *inner_iter_data) -> bool {
  859|  3.59G|                    ((iter_data *)inner_iter_data)->str +=
  860|  3.59G|                        ((iter_data *)inner_iter_data)->first_char;
  861|  3.59G|                    ((iter_data *)inner_iter_data)->str +=
  862|  3.59G|                        std::to_string(value);
  863|  3.59G|                    ((iter_data *)inner_iter_data)->first_char = ',';
  864|  3.59G|                    return true;
  865|  3.59G|                },
_ZNK7roaring7Roaring5beginEv:
 1067|  12.3k|inline RoaringSetBitBiDirectionalIterator Roaring::begin() const {
 1068|  12.3k|    return RoaringSetBitBiDirectionalIterator(*this);
 1069|  12.3k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorC2ERKNS_7RoaringEb:
  961|  12.3k|                                                bool exhausted = false) {
  962|  12.3k|        if (exhausted) {
  ------------------
  |  Branch (962:13): [True: 1, False: 12.3k]
  ------------------
  963|      1|            i.parent = &parent.roaring;
  964|      1|            i.container_index = INT32_MAX;
  965|      1|            i.has_value = false;
  966|      1|            i.current_value = UINT32_MAX;
  967|  12.3k|        } else {
  968|  12.3k|            api::roaring_iterator_init(&parent.roaring, &i);
  969|  12.3k|        }
  970|  12.3k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratorneERKS0_:
 1058|   326k|    bool operator!=(const RoaringSetBitBiDirectionalIterator &o) const {
 1059|   326k|        return i.current_value != *o || i.has_value != o.i.has_value;
  ------------------
  |  Branch (1059:16): [True: 320k, False: 6.15k]
  |  Branch (1059:41): [True: 0, False: 6.15k]
  ------------------
 1060|   326k|    }
_ZNK7roaring34RoaringSetBitBiDirectionalIteratordeEv:
  975|   326k|    value_type operator*() const { return i.current_value; }
_ZNK7roaring7Roaring3endEv:
 1071|   326k|inline RoaringSetBitBiDirectionalIterator &Roaring::end() const {
 1072|   326k|    static RoaringSetBitBiDirectionalIterator e(*this, true);
 1073|   326k|    return e;
 1074|   326k|}
_ZN7roaring34RoaringSetBitBiDirectionalIteratorppEi:
 1006|   320k|    type_of_iterator operator++(int) {  // i++, must return orig. value
 1007|   320k|        RoaringSetBitBiDirectionalIterator orig(*this);
 1008|   320k|        api::roaring_uint32_iterator_advance(&i);
 1009|   320k|        return orig;
 1010|   320k|    }
_ZN7roaring34RoaringSetBitBiDirectionalIterator13equalorlargerEj:
 1021|  6.15k|    CROARING_DEPRECATED void equalorlarger(uint32_t val) {
 1022|  6.15k|        api::roaring_uint32_iterator_move_equalorlarger(&i, val);
 1023|  6.15k|    }

binarySearch:
   52|  7.04M|                            uint16_t ikey) {
   53|  7.04M|    const int32_t gap = 16;
   54|  7.04M|    if (lenarray < gap) {
  ------------------
  |  Branch (54:9): [True: 2.77M, False: 4.27M]
  ------------------
   55|  4.21M|        for (int32_t j = 0; j < lenarray; j++) {
  ------------------
  |  Branch (55:29): [True: 4.20M, False: 7.25k]
  ------------------
   56|  4.20M|            if (array[j] >= ikey) {
  ------------------
  |  Branch (56:17): [True: 2.76M, False: 1.44M]
  ------------------
   57|  2.76M|                return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (57:24): [True: 2.61M, False: 145k]
  ------------------
   58|  2.76M|            }
   59|  4.20M|        }
   60|  7.25k|        return -(lenarray + 1);
   61|  2.77M|    }
   62|  4.27M|    const int32_t num_blocks = lenarray / gap;
   63|  4.27M|    int32_t base = 0;
   64|  4.27M|    int32_t n = num_blocks;
   65|  8.56M|    while (n > 3) {
  ------------------
  |  Branch (65:12): [True: 4.28M, False: 4.27M]
  ------------------
   66|  4.28M|        int32_t quarter = n >> 2;
   67|       |
   68|  4.28M|        int32_t k1 = array[(base + quarter + 1) * gap - 1];
   69|  4.28M|        int32_t k2 = array[(base + 2 * quarter + 1) * gap - 1];
   70|  4.28M|        int32_t k3 = array[(base + 3 * quarter + 1) * gap - 1];
   71|       |
   72|  4.28M|        int32_t c1 = (k1 < ikey);
   73|  4.28M|        int32_t c2 = (k2 < ikey);
   74|  4.28M|        int32_t c3 = (k3 < ikey);
   75|       |
   76|  4.28M|        base += (c1 + c2 + c3) * quarter;
   77|  4.28M|        n -= 3 * quarter;
   78|  4.28M|    }
   79|  7.91M|    while (n > 1) {
  ------------------
  |  Branch (79:12): [True: 3.63M, False: 4.27M]
  ------------------
   80|  3.63M|        int32_t half = n >> 1;
   81|  3.63M|        base = (array[(base + half + 1) * gap - 1] < ikey) ? base + half : base;
  ------------------
  |  Branch (81:16): [True: 508k, False: 3.12M]
  ------------------
   82|  3.63M|        n -= half;
   83|  3.63M|    }
   84|  4.27M|    int32_t lo = (array[(base + 1) * gap - 1] < ikey) ? base + 1 : base;
  ------------------
  |  Branch (84:18): [True: 1.98M, False: 2.28M]
  ------------------
   85|       |
   86|  4.27M|    if (lo < num_blocks) {
  ------------------
  |  Branch (86:9): [True: 3.97M, False: 305k]
  ------------------
   87|  3.97M|        const int32_t start = lo * gap;
   88|  3.97M|#if defined(CROARING_IS_X64)
   89|       |        // SSE2: subs_epu16 yields zero where lane >= ikey. movemask of an
   90|       |        // epi16 compare gives 2 bits per lane; ctz>>1 = lane index. Scan
   91|       |        // the first 8 lanes first and exit early when they contain the
   92|       |        // answer; otherwise the block-narrowing invariant guarantees the
   93|       |        // second-half mask is non-zero.
   94|  3.97M|        __m128i needle = _mm_set1_epi16((short)ikey);
   95|  3.97M|        __m128i zero = _mm_setzero_si128();
   96|  3.97M|        __m128i v0 = _mm_loadu_si128((const __m128i *)(array + start));
   97|  3.97M|        __m128i ge0 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v0), zero);
   98|  3.97M|        unsigned m0 = (unsigned)_mm_movemask_epi8(ge0);
   99|  3.97M|        if (m0 != 0) {
  ------------------
  |  Branch (99:13): [True: 2.82M, False: 1.14M]
  ------------------
  100|  2.82M|            int32_t j = start + (int32_t)(roaring_trailing_zeroes(m0) >> 1);
  101|  2.82M|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (101:20): [True: 2.09M, False: 731k]
  ------------------
  102|  2.82M|        }
  103|  1.14M|        __m128i v1 = _mm_loadu_si128((const __m128i *)(array + start + 8));
  104|  1.14M|        __m128i ge1 = _mm_cmpeq_epi16(_mm_subs_epu16(needle, v1), zero);
  105|  1.14M|        unsigned m1 = (unsigned)_mm_movemask_epi8(ge1);
  106|  1.14M|        int32_t j = start + 8 + (int32_t)(roaring_trailing_zeroes(m1) >> 1);
  107|  1.14M|        return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (107:16): [True: 502k, False: 641k]
  ------------------
  108|       |#else
  109|       |        const int32_t end = start + gap;
  110|       |        for (int32_t j = start; j < end; j++) {
  111|       |            if (array[j] >= ikey) {
  112|       |                return (array[j] == ikey) ? j : -(j + 1);
  113|       |            }
  114|       |        }
  115|       |        // Unreachable: the narrowing guarantees the last element of the
  116|       |        // selected block is >= ikey.
  117|       |        return -(end + 1);
  118|       |#endif
  119|  3.97M|    }
  120|       |
  121|  1.74M|    for (int32_t j = num_blocks * gap; j < lenarray; j++) {
  ------------------
  |  Branch (121:40): [True: 1.73M, False: 10.6k]
  ------------------
  122|  1.73M|        if (array[j] >= ikey) {
  ------------------
  |  Branch (122:13): [True: 294k, False: 1.43M]
  ------------------
  123|   294k|            return (array[j] == ikey) ? j : -(j + 1);
  ------------------
  |  Branch (123:20): [True: 164k, False: 130k]
  ------------------
  124|   294k|        }
  125|  1.73M|    }
  126|  10.6k|    return -(lenarray + 1);
  127|   305k|}
roaring.c:advanceUntil:
  137|    518|                                   int32_t length, uint16_t min) {
  138|    518|    int32_t lower = pos + 1;
  139|       |
  140|    518|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 518, False: 0]
  |  Branch (140:30): [True: 0, False: 0]
  ------------------
  141|    518|        return lower;
  142|    518|    }
  143|       |
  144|      0|    int32_t spansize = 1;
  145|       |
  146|      0|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 0, False: 0]
  |  Branch (146:43): [True: 0, False: 0]
  ------------------
  147|      0|        spansize <<= 1;
  148|      0|    }
  149|      0|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 0, False: 0]
  ------------------
  150|       |
  151|      0|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 0, False: 0]
  ------------------
  152|      0|        return upper;
  153|      0|    }
  154|      0|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 0, False: 0]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|      0|        return length;
  162|      0|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|      0|    lower += (spansize >> 1);
  166|       |
  167|      0|    int32_t mid = 0;
  168|      0|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 0, False: 0]
  ------------------
  169|      0|        mid = (lower + upper) >> 1;
  170|      0|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 0, False: 0]
  ------------------
  171|      0|            return mid;
  172|      0|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 0, False: 0]
  ------------------
  173|      0|            lower = mid;
  174|      0|        } else {
  175|      0|            upper = mid;
  176|      0|        }
  177|      0|    }
  178|      0|    return upper;
  179|      0|}
roaring.c:count_greater:
  197|  8.80k|                                    uint16_t ikey) {
  198|  8.80k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (198:9): [True: 0, False: 8.80k]
  ------------------
  199|  8.80k|    int32_t pos = binarySearch(array, lenarray, ikey);
  200|  8.80k|    if (pos >= 0) {
  ------------------
  |  Branch (200:9): [True: 1.92k, False: 6.88k]
  ------------------
  201|  1.92k|        return lenarray - (pos + 1);
  202|  6.88k|    } else {
  203|  6.88k|        return lenarray - (-pos - 1);
  204|  6.88k|    }
  205|  8.80k|}
roaring.c:count_less:
  186|  15.2k|                                 uint16_t ikey) {
  187|  15.2k|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (187:9): [True: 2.93k, False: 12.2k]
  ------------------
  188|  12.2k|    int32_t pos = binarySearch(array, lenarray, ikey);
  189|  12.2k|    return pos >= 0 ? pos : -(pos + 1);
  ------------------
  |  Branch (189:12): [True: 9.23k, False: 3.02k]
  ------------------
  190|  15.2k|}
array_util.c:advanceUntil:
  137|  17.2k|                                   int32_t length, uint16_t min) {
  138|  17.2k|    int32_t lower = pos + 1;
  139|       |
  140|  17.2k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 17, False: 17.2k]
  |  Branch (140:30): [True: 6.19k, False: 11.0k]
  ------------------
  141|  6.21k|        return lower;
  142|  6.21k|    }
  143|       |
  144|  11.0k|    int32_t spansize = 1;
  145|       |
  146|  48.2k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 47.0k, False: 1.19k]
  |  Branch (146:43): [True: 37.1k, False: 9.89k]
  ------------------
  147|  37.1k|        spansize <<= 1;
  148|  37.1k|    }
  149|  11.0k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 9.89k, False: 1.19k]
  ------------------
  150|       |
  151|  11.0k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 2.56k, False: 8.51k]
  ------------------
  152|  2.56k|        return upper;
  153|  2.56k|    }
  154|  8.51k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 165, False: 8.34k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    165|        return length;
  162|    165|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  8.34k|    lower += (spansize >> 1);
  166|       |
  167|  8.34k|    int32_t mid = 0;
  168|  26.5k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 22.5k, False: 4.01k]
  ------------------
  169|  22.5k|        mid = (lower + upper) >> 1;
  170|  22.5k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 4.33k, False: 18.2k]
  ------------------
  171|  4.33k|            return mid;
  172|  18.2k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 9.19k, False: 9.03k]
  ------------------
  173|  9.19k|            lower = mid;
  174|  9.19k|        } else {
  175|  9.03k|            upper = mid;
  176|  9.03k|        }
  177|  22.5k|    }
  178|  4.01k|    return upper;
  179|  8.34k|}
mixed_intersection.c:advanceUntil:
  137|   128k|                                   int32_t length, uint16_t min) {
  138|   128k|    int32_t lower = pos + 1;
  139|       |
  140|   128k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 494, False: 127k]
  |  Branch (140:30): [True: 72.4k, False: 55.3k]
  ------------------
  141|  72.8k|        return lower;
  142|  72.8k|    }
  143|       |
  144|  55.3k|    int32_t spansize = 1;
  145|       |
  146|   131k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 130k, False: 1.15k]
  |  Branch (146:43): [True: 76.1k, False: 54.2k]
  ------------------
  147|  76.1k|        spansize <<= 1;
  148|  76.1k|    }
  149|  55.3k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 54.2k, False: 1.15k]
  ------------------
  150|       |
  151|  55.3k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 26.8k, False: 28.4k]
  ------------------
  152|  26.8k|        return upper;
  153|  26.8k|    }
  154|  28.4k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 538, False: 27.9k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    538|        return length;
  162|    538|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  27.9k|    lower += (spansize >> 1);
  166|       |
  167|  27.9k|    int32_t mid = 0;
  168|  49.4k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 33.6k, False: 15.8k]
  ------------------
  169|  33.6k|        mid = (lower + upper) >> 1;
  170|  33.6k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 12.1k, False: 21.5k]
  ------------------
  171|  12.1k|            return mid;
  172|  21.5k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 8.12k, False: 13.4k]
  ------------------
  173|  8.12k|            lower = mid;
  174|  13.4k|        } else {
  175|  13.4k|            upper = mid;
  176|  13.4k|        }
  177|  33.6k|    }
  178|  15.8k|    return upper;
  179|  27.9k|}
mixed_subset.c:advanceUntil:
  137|    380|                                   int32_t length, uint16_t min) {
  138|    380|    int32_t lower = pos + 1;
  139|       |
  140|    380|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 0, False: 380]
  |  Branch (140:30): [True: 192, False: 188]
  ------------------
  141|    192|        return lower;
  142|    192|    }
  143|       |
  144|    188|    int32_t spansize = 1;
  145|       |
  146|    922|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 836, False: 86]
  |  Branch (146:43): [True: 734, False: 102]
  ------------------
  147|    734|        spansize <<= 1;
  148|    734|    }
  149|    188|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 102, False: 86]
  ------------------
  150|       |
  151|    188|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 0, False: 188]
  ------------------
  152|      0|        return upper;
  153|      0|    }
  154|    188|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 10, False: 178]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|     10|        return length;
  162|     10|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|    178|    lower += (spansize >> 1);
  166|       |
  167|    178|    int32_t mid = 0;
  168|    638|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 460, False: 178]
  ------------------
  169|    460|        mid = (lower + upper) >> 1;
  170|    460|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 0, False: 460]
  ------------------
  171|      0|            return mid;
  172|    460|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 270, False: 190]
  ------------------
  173|    270|            lower = mid;
  174|    270|        } else {
  175|    190|            upper = mid;
  176|    190|        }
  177|    460|    }
  178|    178|    return upper;
  179|    178|}
mixed_andnot.c:advanceUntil:
  137|  89.9k|                                   int32_t length, uint16_t min) {
  138|  89.9k|    int32_t lower = pos + 1;
  139|       |
  140|  89.9k|    if ((lower >= length) || (array[lower] >= min)) {
  ------------------
  |  Branch (140:9): [True: 4.76k, False: 85.1k]
  |  Branch (140:30): [True: 72.3k, False: 12.8k]
  ------------------
  141|  77.0k|        return lower;
  142|  77.0k|    }
  143|       |
  144|  12.8k|    int32_t spansize = 1;
  145|       |
  146|  25.9k|    while ((lower + spansize < length) && (array[lower + spansize] < min)) {
  ------------------
  |  Branch (146:12): [True: 25.4k, False: 497]
  |  Branch (146:43): [True: 13.0k, False: 12.3k]
  ------------------
  147|  13.0k|        spansize <<= 1;
  148|  13.0k|    }
  149|  12.8k|    int32_t upper = (lower + spansize < length) ? lower + spansize : length - 1;
  ------------------
  |  Branch (149:21): [True: 12.3k, False: 497]
  ------------------
  150|       |
  151|  12.8k|    if (array[upper] == min) {
  ------------------
  |  Branch (151:9): [True: 6.37k, False: 6.48k]
  ------------------
  152|  6.37k|        return upper;
  153|  6.37k|    }
  154|  6.48k|    if (array[upper] < min) {
  ------------------
  |  Branch (154:9): [True: 446, False: 6.04k]
  ------------------
  155|       |        // means
  156|       |        // array
  157|       |        // has no
  158|       |        // item
  159|       |        // >= min
  160|       |        // pos = array.length;
  161|    446|        return length;
  162|    446|    }
  163|       |
  164|       |    // we know that the next-smallest span was too small
  165|  6.04k|    lower += (spansize >> 1);
  166|       |
  167|  6.04k|    int32_t mid = 0;
  168|  9.31k|    while (lower + 1 != upper) {
  ------------------
  |  Branch (168:12): [True: 5.41k, False: 3.90k]
  ------------------
  169|  5.41k|        mid = (lower + upper) >> 1;
  170|  5.41k|        if (array[mid] == min) {
  ------------------
  |  Branch (170:13): [True: 2.14k, False: 3.27k]
  ------------------
  171|  2.14k|            return mid;
  172|  3.27k|        } else if (array[mid] < min) {
  ------------------
  |  Branch (172:20): [True: 1.15k, False: 2.11k]
  ------------------
  173|  1.15k|            lower = mid;
  174|  2.11k|        } else {
  175|  2.11k|            upper = mid;
  176|  2.11k|        }
  177|  5.41k|    }
  178|  3.90k|    return upper;
  179|  6.04k|}

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

array_container_contains:
  343|  3.23k|                                     uint16_t pos) {
  344|       |    /**
  345|       |     * SIMD Quad algorithm
  346|       |     * Daniel Lemire, "You can beat the binary search," in Daniel Lemire's blog,
  347|       |     *  April 27, 2026,
  348|       |     * https://lemire.me/blog/2026/04/27/you-can-beat-the-binary-search/.
  349|       |     */
  350|  3.23k|    const int32_t gap = 16;
  351|  3.23k|    const uint16_t *carr = arr->array;
  352|  3.23k|    int32_t cardinality = arr->cardinality;
  353|  3.23k|    if (cardinality < gap) {
  ------------------
  |  Branch (353:9): [True: 945, False: 2.29k]
  ------------------
  354|  1.08k|        for (int32_t j = 0; j < cardinality; j++) {
  ------------------
  |  Branch (354:29): [True: 1.05k, False: 34]
  ------------------
  355|  1.05k|            if (carr[j] >= pos) return carr[j] == pos;
  ------------------
  |  Branch (355:17): [True: 911, False: 142]
  ------------------
  356|  1.05k|        }
  357|     34|        return false;
  358|    945|    }
  359|  2.29k|    int32_t num_blocks = cardinality / gap;
  360|  2.29k|    int32_t base = 0;
  361|  2.29k|    int32_t n = num_blocks;
  362|  5.26k|    while (n > 3) {
  ------------------
  |  Branch (362:12): [True: 2.97k, False: 2.29k]
  ------------------
  363|  2.97k|        int32_t quarter = n >> 2;
  364|       |
  365|  2.97k|        int32_t k1 = carr[(base + quarter + 1) * gap - 1];
  366|  2.97k|        int32_t k2 = carr[(base + 2 * quarter + 1) * gap - 1];
  367|  2.97k|        int32_t k3 = carr[(base + 3 * quarter + 1) * gap - 1];
  368|       |
  369|  2.97k|        int32_t c1 = (k1 < pos);
  370|  2.97k|        int32_t c2 = (k2 < pos);
  371|  2.97k|        int32_t c3 = (k3 < pos);
  372|       |
  373|  2.97k|        base += (c1 + c2 + c3) * quarter;
  374|  2.97k|        n -= 3 * quarter;
  375|  2.97k|    }
  376|  4.04k|    while (n > 1) {
  ------------------
  |  Branch (376:12): [True: 1.75k, False: 2.29k]
  ------------------
  377|  1.75k|        int32_t half = n >> 1;
  378|  1.75k|        base = (carr[(base + half + 1) * gap - 1] < pos) ? base + half : base;
  ------------------
  |  Branch (378:16): [True: 76, False: 1.67k]
  ------------------
  379|  1.75k|        n -= half;
  380|  1.75k|    }
  381|  2.29k|    int32_t lo = (carr[(base + 1) * gap - 1] < pos) ? base + 1 : base;
  ------------------
  |  Branch (381:18): [True: 117, False: 2.17k]
  ------------------
  382|       |
  383|  2.29k|    if (lo < num_blocks) {
  ------------------
  |  Branch (383:9): [True: 2.21k, False: 73]
  ------------------
  384|  2.21k|        const uint16_t *blk = carr + lo * gap;
  385|       |#ifdef CROARING_USENEON
  386|       |        uint16x8_t needle = vdupq_n_u16(pos);
  387|       |        uint16x8_t v0 = vld1q_u16(blk);
  388|       |        uint16x8_t v1 = vld1q_u16(blk + 8);
  389|       |        uint16x8_t hit =
  390|       |            vorrq_u16(vceqq_u16(v0, needle), vceqq_u16(v1, needle));
  391|       |        return vmaxvq_u16(hit) != 0;
  392|       |#elif defined(CROARING_IS_X64)
  393|       |        __m128i needle = _mm_set1_epi16((short)pos);
  394|  2.21k|        __m128i v0 = _mm_loadu_si128((const __m128i *)blk);
  395|  2.21k|        __m128i v1 = _mm_loadu_si128((const __m128i *)(blk + 8));
  396|  2.21k|        __m128i hit = _mm_or_si128(_mm_cmpeq_epi16(v0, needle),
  397|  2.21k|                                   _mm_cmpeq_epi16(v1, needle));
  398|  2.21k|        return _mm_movemask_epi8(hit) != 0;
  399|       |#else
  400|       |        for (int32_t j = 0; j < gap; j++) {
  401|       |            if (blk[j] >= pos) return blk[j] == pos;
  402|       |        }
  403|       |        return false;
  404|       |#endif
  405|  2.21k|    }
  406|       |
  407|    638|    for (int32_t j = num_blocks * gap; j < cardinality; j++) {
  ------------------
  |  Branch (407:40): [True: 591, False: 47]
  ------------------
  408|    591|        uint16_t v = carr[j];
  409|    591|        if (v >= pos) return (v == pos);
  ------------------
  |  Branch (409:13): [True: 26, False: 565]
  ------------------
  410|    591|    }
  411|     47|    return false;
  412|     73|}
array_container_minimum:
  445|  3.51k|inline uint16_t array_container_minimum(const array_container_t *arr) {
  446|  3.51k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (446:9): [True: 0, False: 3.51k]
  ------------------
  447|  3.51k|    return arr->array[0];
  448|  3.51k|}
array_container_maximum:
  451|  12.8k|inline uint16_t array_container_maximum(const array_container_t *arr) {
  452|  12.8k|    if (arr->cardinality == 0) return 0;
  ------------------
  |  Branch (452:9): [True: 0, False: 12.8k]
  ------------------
  453|  12.8k|    return arr->array[arr->cardinality - 1];
  454|  12.8k|}
array_container_rank:
  457|  3.63k|inline int array_container_rank(const array_container_t *arr, uint16_t x) {
  458|  3.63k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  459|  3.63k|    const bool is_present = idx >= 0;
  460|  3.63k|    if (is_present) {
  ------------------
  |  Branch (460:9): [True: 3.06k, False: 566]
  ------------------
  461|  3.06k|        return idx + 1;
  462|  3.06k|    } else {
  463|    566|        return -idx - 1;
  464|    566|    }
  465|  3.63k|}
array_container_index_equalorlarger:
  507|  4.32k|                                               uint16_t x) {
  508|  4.32k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, x);
  509|  4.32k|    const bool is_present = idx >= 0;
  510|  4.32k|    if (is_present) {
  ------------------
  |  Branch (510:9): [True: 3.95k, False: 366]
  ------------------
  511|  3.95k|        return idx;
  512|  3.95k|    } else {
  513|    366|        int32_t candidate = -idx - 1;
  514|    366|        if (candidate < arr->cardinality) return candidate;
  ------------------
  |  Branch (514:13): [True: 366, False: 0]
  ------------------
  515|      0|        return -1;
  516|    366|    }
  517|  4.32k|}
roaring.c:array_container_add_range_nvals:
  527|    539|                                                   int32_t nvals_greater) {
  528|    539|    int32_t union_cardinality = nvals_less + (max - min + 1) + nvals_greater;
  529|    539|    if (union_cardinality > array->capacity) {
  ------------------
  |  Branch (529:9): [True: 503, False: 36]
  ------------------
  530|    503|        array_container_grow(array, union_cardinality, true);
  531|    503|    }
  532|    539|    memmove(&(array->array[union_cardinality - nvals_greater]),
  533|    539|            &(array->array[array->cardinality - nvals_greater]),
  534|    539|            nvals_greater * sizeof(uint16_t));
  535|  1.33M|    for (uint32_t i = 0; i <= max - min; i++) {
  ------------------
  |  Branch (535:26): [True: 1.33M, False: 539]
  ------------------
  536|  1.33M|        array->array[nvals_less + i] = (uint16_t)(min + i);
  537|  1.33M|    }
  538|    539|    array->cardinality = union_cardinality;
  539|    539|}
roaring.c:array_container_remove_range:
  557|  3.13k|                                                uint32_t pos, uint32_t count) {
  558|  3.13k|    if (count != 0) {
  ------------------
  |  Branch (558:9): [True: 324, False: 2.81k]
  ------------------
  559|    324|        memmove(&(array->array[pos]), &(array->array[pos + count]),
  560|    324|                (array->cardinality - pos - count) * sizeof(uint16_t));
  561|    324|        array->cardinality -= count;
  562|    324|    }
  563|  3.13k|}
roaring.c:array_container_cardinality:
   82|  69.1k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  69.1k|    return array->cardinality;
   84|  69.1k|}
roaring.c:array_container_try_add:
  293|  7.02M|                                          int32_t max_cardinality) {
  294|  7.02M|    const int32_t cardinality = arr->cardinality;
  295|       |
  296|       |    // best case, we can append.
  297|  7.02M|    if ((array_container_empty(arr) || arr->array[cardinality - 1] < value) &&
  ------------------
  |  Branch (297:10): [True: 15.5k, False: 7.01M]
  |  Branch (297:40): [True: 49.9k, False: 6.96M]
  ------------------
  298|  65.4k|        cardinality < max_cardinality) {
  ------------------
  |  Branch (298:9): [True: 65.4k, False: 0]
  ------------------
  299|  65.4k|        array_container_append(arr, value);
  300|  65.4k|        return 1;
  301|  65.4k|    }
  302|       |
  303|  6.96M|    const int32_t loc = binarySearch(arr->array, cardinality, value);
  304|       |
  305|  6.96M|    if (loc >= 0) {
  ------------------
  |  Branch (305:9): [True: 5.33M, False: 1.62M]
  ------------------
  306|  5.33M|        return 0;
  307|  5.33M|    } else if (cardinality < max_cardinality) {
  ------------------
  |  Branch (307:16): [True: 1.62M, False: 103]
  ------------------
  308|  1.62M|        if (array_container_full(arr)) {
  ------------------
  |  Branch (308:13): [True: 73.3k, False: 1.55M]
  ------------------
  309|  73.3k|            array_container_grow(arr, arr->capacity + 1, true);
  310|  73.3k|        }
  311|  1.62M|        const int32_t insert_idx = -loc - 1;
  312|  1.62M|        memmove(arr->array + insert_idx + 1, arr->array + insert_idx,
  313|  1.62M|                (cardinality - insert_idx) * sizeof(uint16_t));
  314|  1.62M|        arr->array[insert_idx] = value;
  315|  1.62M|        arr->cardinality++;
  316|  1.62M|        return 1;
  317|  1.62M|    } else {
  318|    103|        return -1;
  319|    103|    }
  320|  6.96M|}
roaring.c:array_container_empty:
  100|  7.02M|static inline bool array_container_empty(const array_container_t *array) {
  101|  7.02M|    return array->cardinality == 0;
  102|  7.02M|}
roaring.c:array_container_append:
  274|  65.4k|                                          uint16_t pos) {
  275|  65.4k|    const int32_t capacity = arr->capacity;
  276|       |
  277|  65.4k|    if (array_container_full(arr)) {
  ------------------
  |  Branch (277:9): [True: 31.3k, False: 34.1k]
  ------------------
  278|  31.3k|        array_container_grow(arr, capacity + 1, true);
  279|  31.3k|    }
  280|       |
  281|  65.4k|    arr->array[arr->cardinality++] = pos;
  282|  65.4k|}
roaring.c:array_container_full:
  106|  1.69M|static inline bool array_container_full(const array_container_t *array) {
  107|  1.69M|    return array->cardinality == array->capacity;
  108|  1.69M|}
roaring.c:array_container_remove:
  329|  5.96k|                                          uint16_t pos) {
  330|  5.96k|    const int32_t idx = binarySearch(arr->array, arr->cardinality, pos);
  331|  5.96k|    const bool is_present = idx >= 0;
  332|  5.96k|    if (is_present) {
  ------------------
  |  Branch (332:9): [True: 2.98k, False: 2.97k]
  ------------------
  333|  2.98k|        memmove(arr->array + idx, arr->array + idx + 1,
  334|  2.98k|                (arr->cardinality - idx - 1) * sizeof(uint16_t));
  335|  2.98k|        arr->cardinality--;
  336|  2.98k|    }
  337|       |
  338|  5.96k|    return is_present;
  339|  5.96k|}
roaring.c:array_container_nonzero_cardinality:
   87|  98.4k|    const array_container_t *array) {
   88|  98.4k|    return array->cardinality > 0;
   89|  98.4k|}
roaring.c:array_container_equals:
  230|  9.26k|                                          const array_container_t *container2) {
  231|  9.26k|    if (container1->cardinality != container2->cardinality) {
  ------------------
  |  Branch (231:9): [True: 2.20k, False: 7.06k]
  ------------------
  232|  2.20k|        return false;
  233|  2.20k|    }
  234|  7.06k|    return memequals(container1->array, container2->array,
  235|  7.06k|                     container1->cardinality * 2);
  236|  9.26k|}
roaring.c:array_container_select:
  252|  3.63k|                                          uint32_t *element) {
  253|  3.63k|    int card = array_container_cardinality(container);
  254|  3.63k|    if (*start_rank + card <= rank) {
  ------------------
  |  Branch (254:9): [True: 331, False: 3.30k]
  ------------------
  255|    331|        *start_rank += card;
  256|    331|        return false;
  257|  3.30k|    } else {
  258|  3.30k|        *element = container->array[rank - *start_rank];
  259|       |        return true;
  260|  3.30k|    }
  261|  3.63k|}
roaring.c:array_container_contains_range:
  421|     94|                                                  uint32_t range_end) {
  422|     94|    const int32_t range_count = range_end - range_start;
  423|     94|    const uint16_t rs_included = (uint16_t)range_start;
  424|     94|    const uint16_t re_included = (uint16_t)(range_end - 1);
  425|       |
  426|       |    // Empty range is always included
  427|     94|    if (range_count <= 0) {
  ------------------
  |  Branch (427:9): [True: 0, False: 94]
  ------------------
  428|      0|        return true;
  429|      0|    }
  430|     94|    if (range_count > arr->cardinality) {
  ------------------
  |  Branch (430:9): [True: 39, False: 55]
  ------------------
  431|     39|        return false;
  432|     39|    }
  433|       |
  434|     55|    const int32_t start =
  435|     55|        binarySearch(arr->array, arr->cardinality, rs_included);
  436|       |    // If this sorted array contains all items in the range:
  437|       |    // * the start item must be found
  438|       |    // * the last item in range range_count must exist, and be the expected end
  439|       |    // value
  440|     55|    return (start >= 0) && (arr->cardinality >= start + range_count) &&
  ------------------
  |  Branch (440:12): [True: 35, False: 20]
  |  Branch (440:28): [True: 32, False: 3]
  ------------------
  441|     32|           (arr->array[start + range_count - 1] == re_included);
  ------------------
  |  Branch (441:12): [True: 7, False: 25]
  ------------------
  442|     94|}
roaring_array.c:array_container_size_in_bytes:
  221|  17.4k|    const array_container_t *container) {
  222|  17.4k|    return container->cardinality * sizeof(uint16_t);
  223|  17.4k|}
roaring_array.c:array_container_cardinality:
   82|  6.91k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  6.91k|    return array->cardinality;
   84|  6.91k|}
array.c:array_container_size_in_bytes:
  221|  13.8k|    const array_container_t *container) {
  222|  13.8k|    return container->cardinality * sizeof(uint16_t);
  223|  13.8k|}
convert.c:array_container_cardinality:
   82|  14.4k|static inline int array_container_cardinality(const array_container_t *array) {
   83|  14.4k|    return array->cardinality;
   84|  14.4k|}
convert.c:array_container_serialized_size_in_bytes:
  173|   140k|static inline int32_t array_container_serialized_size_in_bytes(int32_t card) {
  174|   140k|    return card * sizeof(uint16_t);
  175|   140k|}
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|    350|static inline int array_container_cardinality(const array_container_t *array) {
   83|    350|    return array->cardinality;
   84|    350|}

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

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

run_container_contains:
  260|  8.48k|inline bool run_container_contains(const run_container_t *run, uint16_t pos) {
  261|  8.48k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  262|  8.48k|    if (index >= 0) return true;
  ------------------
  |  Branch (262:9): [True: 5.95k, False: 2.52k]
  ------------------
  263|  2.52k|    index = -index - 2;  // points to preceding value, possibly -1
  264|  2.52k|    if (index != -1) {   // possible match
  ------------------
  |  Branch (264:9): [True: 896, False: 1.63k]
  ------------------
  265|    896|        int32_t offset = pos - run->runs[index].value;
  266|    896|        int32_t le = run->runs[index].length;
  267|    896|        if (offset <= le) return true;
  ------------------
  |  Branch (267:13): [True: 568, False: 328]
  ------------------
  268|    896|    }
  269|  1.95k|    return false;
  270|  2.52k|}
interleavedBinarySearch:
  112|   402k|                                       uint16_t ikey) {
  113|   402k|    int32_t low = 0;
  114|   402k|    int32_t high = lenarray - 1;
  115|  1.85M|    while (low <= high) {
  ------------------
  |  Branch (115:12): [True: 1.63M, False: 220k]
  ------------------
  116|  1.63M|        int32_t middleIndex = (low + high) >> 1;
  117|  1.63M|        uint16_t middleValue = array[middleIndex].value;
  118|  1.63M|        if (middleValue < ikey) {
  ------------------
  |  Branch (118:13): [True: 636k, False: 997k]
  ------------------
  119|   636k|            low = middleIndex + 1;
  120|   997k|        } else if (middleValue > ikey) {
  ------------------
  |  Branch (120:20): [True: 815k, False: 181k]
  ------------------
  121|   815k|            high = middleIndex - 1;
  122|   815k|        } else {
  123|   181k|            return middleIndex;
  124|   181k|        }
  125|  1.63M|    }
  126|   220k|    return -(low + 1);
  127|   402k|}
run_container_minimum:
  563|  17.9k|inline uint16_t run_container_minimum(const run_container_t *run) {
  564|  17.9k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (564:9): [True: 0, False: 17.9k]
  ------------------
  565|  17.9k|    return run->runs[0].value;
  566|  17.9k|}
run_container_maximum:
  569|  17.4k|inline uint16_t run_container_maximum(const run_container_t *run) {
  570|  17.4k|    if (run->n_runs == 0) return 0;
  ------------------
  |  Branch (570:9): [True: 0, False: 17.4k]
  ------------------
  571|  17.4k|    return run->runs[run->n_runs - 1].value + run->runs[run->n_runs - 1].length;
  572|  17.4k|}
roaring.c:run_container_create_range:
  532|  85.2k|                                                          uint32_t stop) {
  533|  85.2k|    run_container_t *rc = run_container_create_given_capacity(1);
  534|  85.2k|    if (rc) {
  ------------------
  |  Branch (534:9): [True: 85.2k, False: 0]
  ------------------
  535|  85.2k|        rle16_t r;
  536|  85.2k|        r.value = (uint16_t)start;
  537|  85.2k|        r.length = (uint16_t)(stop - start - 1);
  538|  85.2k|        run_container_append_first(rc, r);
  539|  85.2k|    }
  540|  85.2k|    return rc;
  541|  85.2k|}
roaring.c:run_container_append_first:
  351|  85.2k|                                                 rle16_t vl) {
  352|  85.2k|    run->runs[run->n_runs] = vl;
  353|  85.2k|    run->n_runs++;
  354|  85.2k|    return vl;
  355|  85.2k|}
roaring.c:rle16_count_greater:
  178|    411|                                          int32_t lenarray, uint16_t key) {
  179|    411|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (179:9): [True: 0, False: 411]
  ------------------
  180|    411|    int32_t low = 0;
  181|    411|    int32_t high = lenarray - 1;
  182|  3.11k|    while (low <= high) {
  ------------------
  |  Branch (182:12): [True: 2.75k, False: 369]
  ------------------
  183|  2.75k|        int32_t middleIndex = (low + high) >> 1;
  184|  2.75k|        uint16_t min_value = array[middleIndex].value;
  185|  2.75k|        uint16_t max_value =
  186|  2.75k|            array[middleIndex].value + array[middleIndex].length;
  187|  2.75k|        if (max_value < key) {
  ------------------
  |  Branch (187:13): [True: 2.50k, False: 244]
  ------------------
  188|  2.50k|            low = middleIndex + 1;
  189|  2.50k|        } else if (key + UINT32_C(1) < min_value) {  // uint32 arithmetic
  ------------------
  |  Branch (189:20): [True: 202, False: 42]
  ------------------
  190|    202|            high = middleIndex - 1;
  191|    202|        } else {
  192|     42|            return lenarray - (middleIndex + 1);
  193|     42|        }
  194|  2.75k|    }
  195|    369|    return lenarray - low;
  196|    411|}
roaring.c:rle16_count_less:
  157|    411|                                       uint16_t key) {
  158|    411|    if (lenarray == 0) return 0;
  ------------------
  |  Branch (158:9): [True: 1, False: 410]
  ------------------
  159|    410|    int32_t low = 0;
  160|    410|    int32_t high = lenarray - 1;
  161|  2.62k|    while (low <= high) {
  ------------------
  |  Branch (161:12): [True: 2.43k, False: 184]
  ------------------
  162|  2.43k|        int32_t middleIndex = (low + high) >> 1;
  163|  2.43k|        uint16_t min_value = array[middleIndex].value;
  164|  2.43k|        uint16_t max_value =
  165|  2.43k|            array[middleIndex].value + array[middleIndex].length;
  166|  2.43k|        if (max_value + UINT32_C(1) < key) {  // uint32 arithmetic
  ------------------
  |  Branch (166:13): [True: 1.05k, False: 1.38k]
  ------------------
  167|  1.05k|            low = middleIndex + 1;
  168|  1.38k|        } else if (key < min_value) {
  ------------------
  |  Branch (168:20): [True: 1.15k, False: 226]
  ------------------
  169|  1.15k|            high = middleIndex - 1;
  170|  1.15k|        } else {
  171|    226|            return middleIndex;
  172|    226|        }
  173|  2.43k|    }
  174|    184|    return low;
  175|    410|}
roaring.c:run_container_add_range_nruns:
  610|    411|                                                 int32_t nruns_greater) {
  611|    411|    int32_t nruns_common = run->n_runs - nruns_less - nruns_greater;
  612|    411|    if (nruns_common == 0) {
  ------------------
  |  Branch (612:9): [True: 102, False: 309]
  ------------------
  613|    102|        makeRoomAtIndex(run, (uint16_t)nruns_less);
  614|    102|        run->runs[nruns_less].value = (uint16_t)min;
  615|    102|        run->runs[nruns_less].length = (uint16_t)(max - min);
  616|    309|    } else {
  617|    309|        uint32_t common_min = run->runs[nruns_less].value;
  618|    309|        uint32_t common_max = run->runs[nruns_less + nruns_common - 1].value +
  619|    309|                              run->runs[nruns_less + nruns_common - 1].length;
  620|    309|        uint32_t result_min = (common_min < min) ? common_min : min;
  ------------------
  |  Branch (620:31): [True: 64, False: 245]
  ------------------
  621|    309|        uint32_t result_max = (common_max > max) ? common_max : max;
  ------------------
  |  Branch (621:31): [True: 35, False: 274]
  ------------------
  622|       |
  623|    309|        run->runs[nruns_less].value = (uint16_t)result_min;
  624|    309|        run->runs[nruns_less].length = (uint16_t)(result_max - result_min);
  625|       |
  626|    309|        memmove(&(run->runs[nruns_less + 1]),
  627|    309|                &(run->runs[run->n_runs - nruns_greater]),
  628|    309|                nruns_greater * sizeof(rle16_t));
  629|    309|        run->n_runs = nruns_less + 1 + nruns_greater;
  630|    309|    }
  631|    411|}
roaring.c:makeRoomAtIndex:
  208|    755|static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) {
  209|       |    /* This function calls realloc + memmove sequentially to move by one index.
  210|       |     * Potentially copying twice the array.
  211|       |     */
  212|    755|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 630, False: 125]
  ------------------
  213|    630|        run_container_grow(run, run->n_runs + 1, true);
  214|    755|    memmove(run->runs + 1 + index, run->runs + index,
  215|    755|            (run->n_runs - index) * sizeof(rle16_t));
  216|    755|    run->n_runs++;
  217|    755|}
roaring.c:run_container_remove_range:
  667|  1.80k|                                              uint32_t min, uint32_t max) {
  668|  1.80k|    int32_t first = rle16_find_run(run->runs, run->n_runs, (uint16_t)min);
  669|  1.80k|    int32_t last = rle16_find_run(run->runs, run->n_runs, (uint16_t)max);
  670|       |
  671|  1.80k|    if (first >= 0 && min > run->runs[first].value &&
  ------------------
  |  Branch (671:9): [True: 694, False: 1.11k]
  |  Branch (671:23): [True: 292, False: 402]
  ------------------
  672|    292|        max < ((uint32_t)run->runs[first].value +
  ------------------
  |  Branch (672:9): [True: 40, False: 252]
  ------------------
  673|    292|               (uint32_t)run->runs[first].length)) {
  674|       |        // split this run into two adjacent runs
  675|       |
  676|       |        // right subinterval
  677|     40|        makeRoomAtIndex(run, (uint16_t)(first + 1));
  678|     40|        run->runs[first + 1].value = (uint16_t)(max + 1);
  679|     40|        run->runs[first + 1].length =
  680|     40|            (uint16_t)((run->runs[first].value + run->runs[first].length) -
  681|     40|                       (max + 1));
  682|       |
  683|       |        // left subinterval
  684|     40|        run->runs[first].length =
  685|     40|            (uint16_t)((min - 1) - run->runs[first].value);
  686|       |
  687|     40|        return;
  688|     40|    }
  689|       |
  690|       |    // update left-most partial run
  691|  1.76k|    if (first >= 0) {
  ------------------
  |  Branch (691:9): [True: 654, False: 1.11k]
  ------------------
  692|    654|        if (min > run->runs[first].value) {
  ------------------
  |  Branch (692:13): [True: 252, False: 402]
  ------------------
  693|    252|            run->runs[first].length =
  694|    252|                (uint16_t)((min - 1) - run->runs[first].value);
  695|    252|            first++;
  696|    252|        }
  697|  1.11k|    } else {
  698|  1.11k|        first = -first - 1;
  699|  1.11k|    }
  700|       |
  701|       |    // update right-most run
  702|  1.76k|    if (last >= 0) {
  ------------------
  |  Branch (702:9): [True: 631, False: 1.13k]
  ------------------
  703|    631|        uint16_t run_max = run->runs[last].value + run->runs[last].length;
  704|    631|        if (run_max > max) {
  ------------------
  |  Branch (704:13): [True: 409, False: 222]
  ------------------
  705|    409|            run->runs[last].value = (uint16_t)(max + 1);
  706|    409|            run->runs[last].length = (uint16_t)(run_max - (max + 1));
  707|    409|            last--;
  708|    409|        }
  709|  1.13k|    } else {
  710|  1.13k|        last = (-last - 1) - 1;
  711|  1.13k|    }
  712|       |
  713|       |    // remove intermediate runs
  714|  1.76k|    if (first <= last) {
  ------------------
  |  Branch (714:9): [True: 146, False: 1.62k]
  ------------------
  715|    146|        run_container_shift_tail(run, run->n_runs - (last + 1),
  716|    146|                                 -(last - first + 1));
  717|    146|    }
  718|  1.76k|}
roaring.c:rle16_find_run:
  133|  3.61k|                                     uint16_t ikey) {
  134|  3.61k|    int32_t low = 0;
  135|  3.61k|    int32_t high = lenarray - 1;
  136|  14.5k|    while (low <= high) {
  ------------------
  |  Branch (136:12): [True: 12.3k, False: 2.24k]
  ------------------
  137|  12.3k|        int32_t middleIndex = (low + high) >> 1;
  138|  12.3k|        uint16_t min = array[middleIndex].value;
  139|  12.3k|        uint16_t max = array[middleIndex].value + array[middleIndex].length;
  140|  12.3k|        if (ikey > max) {
  ------------------
  |  Branch (140:13): [True: 1.42k, False: 10.9k]
  ------------------
  141|  1.42k|            low = middleIndex + 1;
  142|  10.9k|        } else if (ikey < min) {
  ------------------
  |  Branch (142:20): [True: 9.54k, False: 1.36k]
  ------------------
  143|  9.54k|            high = middleIndex - 1;
  144|  9.54k|        } else {
  145|  1.36k|            return middleIndex;
  146|  1.36k|        }
  147|  12.3k|    }
  148|  2.24k|    return -(low + 1);
  149|  3.61k|}
roaring.c:run_container_shift_tail:
  650|    146|                                            int32_t distance) {
  651|    146|    if (distance > 0) {
  ------------------
  |  Branch (651:9): [True: 0, False: 146]
  ------------------
  652|      0|        if (run->capacity < count + distance) {
  ------------------
  |  Branch (652:13): [True: 0, False: 0]
  ------------------
  653|       |            run_container_grow(run, count + distance, true);
  654|      0|        }
  655|      0|    }
  656|    146|    int32_t srcpos = run->n_runs - count;
  657|    146|    int32_t dstpos = srcpos + distance;
  658|    146|    memmove(&(run->runs[dstpos]), &(run->runs[srcpos]),
  659|    146|            sizeof(rle16_t) * count);
  660|    146|    run->n_runs += distance;
  661|    146|}
roaring.c:run_container_remove:
  223|  2.95k|static inline bool run_container_remove(run_container_t *run, uint16_t pos) {
  224|  2.95k|    int32_t index = interleavedBinarySearch(run->runs, run->n_runs, pos);
  225|  2.95k|    if (index >= 0) {
  ------------------
  |  Branch (225:9): [True: 1.16k, False: 1.78k]
  ------------------
  226|  1.16k|        int32_t le = run->runs[index].length;
  227|  1.16k|        if (le == 0) {
  ------------------
  |  Branch (227:13): [True: 263, False: 905]
  ------------------
  228|    263|            recoverRoomAtIndex(run, (uint16_t)index);
  229|    905|        } else {
  230|    905|            run->runs[index].value++;
  231|    905|            run->runs[index].length--;
  232|    905|        }
  233|  1.16k|        return true;
  234|  1.16k|    }
  235|  1.78k|    index = -index - 2;  // points to preceding value, possibly -1
  236|  1.78k|    if (index >= 0) {    // possible match
  ------------------
  |  Branch (236:9): [True: 817, False: 968]
  ------------------
  237|    817|        int32_t offset = pos - run->runs[index].value;
  238|    817|        int32_t le = run->runs[index].length;
  239|    817|        if (offset < le) {
  ------------------
  |  Branch (239:13): [True: 613, False: 204]
  ------------------
  240|       |            // need to break in two
  241|    613|            run->runs[index].length = (uint16_t)(offset - 1);
  242|       |            // need to insert
  243|    613|            uint16_t newvalue = pos + 1;
  244|    613|            int32_t newlength = le - offset - 1;
  245|    613|            makeRoomAtIndex(run, (uint16_t)(index + 1));
  246|    613|            run->runs[index + 1].value = newvalue;
  247|    613|            run->runs[index + 1].length = (uint16_t)newlength;
  248|    613|            return true;
  249|       |
  250|    613|        } else if (offset == le) {
  ------------------
  |  Branch (250:20): [True: 24, False: 180]
  ------------------
  251|     24|            run->runs[index].length--;
  252|     24|            return true;
  253|     24|        }
  254|    817|    }
  255|       |    // no match
  256|  1.14k|    return false;
  257|  1.78k|}
roaring.c:recoverRoomAtIndex:
  102|    263|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|    263|    memmove(run->runs + index, run->runs + (1 + index),
  104|    263|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|    263|    run->n_runs--;
  106|    263|}
roaring.c:run_container_nonzero_cardinality:
  309|  60.9k|    const run_container_t *run) {
  310|  60.9k|    return run->n_runs > 0;  // runs never empty
  311|  60.9k|}
roaring.c:run_container_is_full:
  394|  6.20k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  6.20k|    rle16_t vl = run->runs[0];
  396|  6.20k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.47k, False: 4.73k]
  |  Branch (396:34): [True: 1.25k, False: 224]
  |  Branch (396:53): [True: 1.10k, False: 142]
  ------------------
  397|  6.20k|}
roaring.c:run_container_equals:
  502|    135|                                        const run_container_t *container2) {
  503|    135|    if (container1->n_runs != container2->n_runs) {
  ------------------
  |  Branch (503:9): [True: 103, False: 32]
  ------------------
  504|    103|        return false;
  505|    103|    }
  506|     32|    return memequals(container1->runs, container2->runs,
  507|     32|                     container1->n_runs * sizeof(rle16_t));
  508|    135|}
roaring.c:run_container_contains_range:
  278|    180|                                                uint32_t pos_end) {
  279|    180|    uint32_t count = 0;
  280|    180|    int32_t index =
  281|    180|        interleavedBinarySearch(run->runs, run->n_runs, (uint16_t)pos_start);
  282|    180|    if (index < 0) {
  ------------------
  |  Branch (282:9): [True: 100, False: 80]
  ------------------
  283|    100|        index = -index - 2;
  284|    100|        if ((index == -1) ||
  ------------------
  |  Branch (284:13): [True: 16, False: 84]
  ------------------
  285|     84|            ((pos_start - run->runs[index].value) > run->runs[index].length)) {
  ------------------
  |  Branch (285:13): [True: 12, False: 72]
  ------------------
  286|     28|            return false;
  287|     28|        }
  288|    100|    }
  289|  2.38k|    for (int32_t i = index; i < run->n_runs; ++i) {
  ------------------
  |  Branch (289:29): [True: 2.31k, False: 71]
  ------------------
  290|  2.31k|        const uint32_t stop = run->runs[i].value + run->runs[i].length;
  291|  2.31k|        if (run->runs[i].value >= pos_end) break;
  ------------------
  |  Branch (291:13): [True: 12, False: 2.29k]
  ------------------
  292|  2.29k|        if (stop >= pos_end) {
  ------------------
  |  Branch (292:13): [True: 69, False: 2.22k]
  ------------------
  293|     69|            count += (((pos_end - run->runs[i].value) > 0)
  ------------------
  |  Branch (293:23): [True: 69, False: 0]
  ------------------
  294|     69|                          ? (pos_end - run->runs[i].value)
  295|     69|                          : 0);
  296|     69|            break;
  297|     69|        }
  298|  2.22k|        const uint32_t min = (stop - pos_start) > 0 ? (stop - pos_start) : 0;
  ------------------
  |  Branch (298:30): [True: 2.21k, False: 15]
  ------------------
  299|  2.22k|        count += (min < run->runs[i].length) ? min : run->runs[i].length;
  ------------------
  |  Branch (299:18): [True: 57, False: 2.17k]
  ------------------
  300|  2.22k|    }
  301|    152|    return count >= (pos_end - pos_start - 1);
  302|    180|}
roaring_array.c:run_container_size_in_bytes:
  493|  2.51k|    const run_container_t *container) {
  494|  2.51k|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|  2.51k|}
roaring_array.c:run_container_serialized_size_in_bytes:
  456|  2.51k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|  2.51k|    return sizeof(uint16_t) +
  458|  2.51k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|  2.51k|}
convert.c:run_container_serialized_size_in_bytes:
  456|   140k|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|   140k|    return sizeof(uint16_t) +
  458|   140k|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|   140k|}
mixed_intersection.c:run_container_is_full:
  394|  16.3k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  16.3k|    rle16_t vl = run->runs[0];
  396|  16.3k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 1.46k, False: 14.9k]
  |  Branch (396:34): [True: 700, False: 760]
  |  Branch (396:53): [True: 204, False: 496]
  ------------------
  397|  16.3k|}
mixed_union.c:run_container_is_full:
  394|  2.73k|static inline bool run_container_is_full(const run_container_t *run) {
  395|  2.73k|    rle16_t vl = run->runs[0];
  396|  2.73k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 354, False: 2.38k]
  |  Branch (396:34): [True: 229, False: 125]
  |  Branch (396:53): [True: 106, False: 123]
  ------------------
  397|  2.73k|}
mixed_union.c:run_container_append_first:
  351|  2.03k|                                                 rle16_t vl) {
  352|  2.03k|    run->runs[run->n_runs] = vl;
  353|  2.03k|    run->n_runs++;
  354|  2.03k|    return vl;
  355|  2.03k|}
mixed_union.c:run_container_append_value_first:
  385|    599|                                                       uint16_t val) {
  386|    599|    rle16_t newrle = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|    599|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  387|    599|    run->runs[run->n_runs] = newrle;
  388|    599|    run->n_runs++;
  389|    599|    return newrle;
  390|    599|}
mixed_union.c:run_container_append:
  332|   154k|                                        rle16_t *previousrl) {
  333|   154k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   154k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 143k, False: 11.3k]
  ------------------
  335|   143k|        run->runs[run->n_runs] = vl;
  336|   143k|        run->n_runs++;
  337|   143k|        *previousrl = vl;
  338|   143k|    } else {
  339|  11.3k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|  11.3k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 11.3k, False: 0]
  ------------------
  341|  11.3k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|  11.3k|            run->runs[run->n_runs - 1] = *previousrl;
  343|  11.3k|        }
  344|  11.3k|    }
  345|   154k|}
mixed_union.c:run_container_append_value:
  368|   467k|                                              rle16_t *previousrl) {
  369|   467k|    const uint32_t previousend = previousrl->value + previousrl->length;
  370|   467k|    if (val > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (370:9): [True: 51.9k, False: 415k]
  ------------------
  371|  51.9k|        *previousrl = CROARING_MAKE_RLE16(val, 0);
  ------------------
  |  |   60|  51.9k|    (rle16_t) { .value = (uint16_t)(val), .length = (uint16_t)(len) }
  ------------------
  372|  51.9k|        run->runs[run->n_runs] = *previousrl;
  373|  51.9k|        run->n_runs++;
  374|   415k|    } else if (val == previousend + 1) {  // we merge
  ------------------
  |  Branch (374:16): [True: 142k, False: 273k]
  ------------------
  375|   142k|        previousrl->length++;
  376|   142k|        run->runs[run->n_runs - 1] = *previousrl;
  377|   142k|    }
  378|   467k|}
run.c:run_container_is_full:
  394|   124k|static inline bool run_container_is_full(const run_container_t *run) {
  395|   124k|    rle16_t vl = run->runs[0];
  396|   124k|    return (run->n_runs == 1) && (vl.value == 0) && (vl.length == 0xFFFF);
  ------------------
  |  Branch (396:12): [True: 109k, False: 14.3k]
  |  Branch (396:34): [True: 108k, False: 1.79k]
  |  Branch (396:53): [True: 105k, False: 2.19k]
  ------------------
  397|   124k|}
run.c:run_container_serialized_size_in_bytes:
  456|     59|static inline int32_t run_container_serialized_size_in_bytes(int32_t num_runs) {
  457|     59|    return sizeof(uint16_t) +
  458|     59|           sizeof(rle16_t) * num_runs;  // each run requires 2 2-byte entries.
  459|     59|}
run.c:recoverRoomAtIndex:
  102|  6.31k|static inline void recoverRoomAtIndex(run_container_t *run, uint16_t index) {
  103|  6.31k|    memmove(run->runs + index, run->runs + (1 + index),
  104|  6.31k|            (run->n_runs - index - 1) * sizeof(rle16_t));
  105|  6.31k|    run->n_runs--;
  106|  6.31k|}
run.c:makeRoomAtIndex:
  208|  42.5k|static inline void makeRoomAtIndex(run_container_t *run, uint16_t index) {
  209|       |    /* This function calls realloc + memmove sequentially to move by one index.
  210|       |     * Potentially copying twice the array.
  211|       |     */
  212|  42.5k|    if (run->n_runs + 1 > run->capacity)
  ------------------
  |  Branch (212:9): [True: 2.41k, False: 40.1k]
  ------------------
  213|  2.41k|        run_container_grow(run, run->n_runs + 1, true);
  214|  42.5k|    memmove(run->runs + 1 + index, run->runs + index,
  215|  42.5k|            (run->n_runs - index) * sizeof(rle16_t));
  216|  42.5k|    run->n_runs++;
  217|  42.5k|}
run.c:run_container_append_first:
  351|  2.31k|                                                 rle16_t vl) {
  352|  2.31k|    run->runs[run->n_runs] = vl;
  353|  2.31k|    run->n_runs++;
  354|  2.31k|    return vl;
  355|  2.31k|}
run.c:run_container_append:
  332|   292k|                                        rle16_t *previousrl) {
  333|   292k|    const uint32_t previousend = previousrl->value + previousrl->length;
  334|   292k|    if (vl.value > previousend + 1) {  // we add a new one
  ------------------
  |  Branch (334:9): [True: 151k, False: 141k]
  ------------------
  335|   151k|        run->runs[run->n_runs] = vl;
  336|   151k|        run->n_runs++;
  337|   151k|        *previousrl = vl;
  338|   151k|    } else {
  339|   141k|        uint32_t newend = vl.value + vl.length + UINT32_C(1);
  340|   141k|        if (newend > previousend) {  // we merge
  ------------------
  |  Branch (340:13): [True: 108k, False: 32.7k]
  ------------------
  341|   108k|            previousrl->length = (uint16_t)(newend - 1 - previousrl->value);
  342|   108k|            run->runs[run->n_runs - 1] = *previousrl;
  343|   108k|        }
  344|   141k|    }
  345|   292k|}
run.c:run_container_empty:
  314|     14|static inline bool run_container_empty(const run_container_t *run) {
  315|     14|    return run->n_runs == 0;  // runs never empty
  316|     14|}
run.c:run_container_size_in_bytes:
  493|     59|    const run_container_t *container) {
  494|     59|    return run_container_serialized_size_in_bytes(container->n_runs);
  495|     59|}

roaring_trailing_zeroes:
  235|  63.9M|inline int roaring_trailing_zeroes(unsigned long long input_num) {
  236|  63.9M|    return __builtin_ctzll(input_num);
  237|  63.9M|}
roaring_leading_zeroes:
  239|  4.03k|inline int roaring_leading_zeroes(unsigned long long input_num) {
  240|  4.03k|    return __builtin_clzll(input_num);
  241|  4.03k|}
roaring.c:roaring_hamming:
  280|   196k|static inline int roaring_hamming(uint64_t x) {
  281|       |#if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  282|       |    CROARING_REGULAR_VISUAL_STUDIO
  283|       |#ifdef CROARING_USENEON
  284|       |    return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
  285|       |#elif defined(_M_ARM64)
  286|       |    return roaring_hamming_backup(x);
  287|       |    // (int) _CountOneBits64(x); is unavailable
  288|       |#else   // _M_ARM64
  289|       |    return (int)__popcnt64(x);
  290|       |#endif  // _M_ARM64
  291|       |#elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  292|       |    CROARING_REGULAR_VISUAL_STUDIO
  293|       |#ifdef _M_ARM
  294|       |    return roaring_hamming_backup(x);
  295|       |    // _CountOneBits is unavailable
  296|       |#else   // _M_ARM
  297|       |    return (int)__popcnt((unsigned int)x) +
  298|       |           (int)__popcnt((unsigned int)(x >> 32));
  299|       |#endif  // _M_ARM
  300|       |#else
  301|   196k|    return __builtin_popcountll(x);
  302|   196k|#endif
  303|   196k|}
mixed_intersection.c:roaring_hamming:
  280|   210k|static inline int roaring_hamming(uint64_t x) {
  281|       |#if defined(_WIN64) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  282|       |    CROARING_REGULAR_VISUAL_STUDIO
  283|       |#ifdef CROARING_USENEON
  284|       |    return vaddv_u8(vcnt_u8(vcreate_u8(input_num)));
  285|       |#elif defined(_M_ARM64)
  286|       |    return roaring_hamming_backup(x);
  287|       |    // (int) _CountOneBits64(x); is unavailable
  288|       |#else   // _M_ARM64
  289|       |    return (int)__popcnt64(x);
  290|       |#endif  // _M_ARM64
  291|       |#elif defined(_WIN32) && defined(CROARING_REGULAR_VISUAL_STUDIO) && \
  292|       |    CROARING_REGULAR_VISUAL_STUDIO
  293|       |#ifdef _M_ARM
  294|       |    return roaring_hamming_backup(x);
  295|       |    // _CountOneBits is unavailable
  296|       |#else   // _M_ARM
  297|       |    return (int)__popcnt((unsigned int)x) +
  298|       |           (int)__popcnt((unsigned int)(x >> 32));
  299|       |#endif  // _M_ARM
  300|       |#else
  301|   210k|    return __builtin_popcountll(x);
  302|   210k|#endif
  303|   210k|}

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

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

intersect_vector16:
  386|  1.74k|                           size_t s_b, uint16_t *C) {
  387|  1.74k|    size_t count = 0;
  388|  1.74k|    size_t i_a = 0, i_b = 0;
  389|  1.74k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  390|  1.74k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  391|  1.74k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  392|  1.74k|    __m128i v_a, v_b;
  393|  1.74k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (393:9): [True: 1.61k, False: 127]
  |  Branch (393:25): [True: 1.47k, False: 146]
  ------------------
  394|  1.47k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  395|  1.47k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  396|  3.94k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (396:16): [True: 2.42k, False: 1.51k]
  |  Branch (396:33): [True: 184, False: 1.33k]
  ------------------
  397|  2.60k|            const __m128i res_v = _mm_cmpestrm(
  398|  2.60k|                v_b, vectorlength, v_a, vectorlength,
  399|  2.60k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  400|  2.60k|            const int r = _mm_extract_epi32(res_v, 0);
  401|  2.60k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  402|  2.60k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  403|  2.60k|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  404|  2.60k|            count += _mm_popcnt_u32(r);
  405|  2.60k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  406|  2.60k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  407|  2.60k|            if (a_max <= b_max) {
  ------------------
  |  Branch (407:17): [True: 1.50k, False: 1.10k]
  ------------------
  408|  1.50k|                i_a += vectorlength;
  409|  1.50k|                if (i_a == st_a) break;
  ------------------
  |  Branch (409:21): [True: 101, False: 1.40k]
  ------------------
  410|  1.40k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  411|  1.40k|            }
  412|  2.50k|            if (b_max <= a_max) {
  ------------------
  |  Branch (412:17): [True: 1.21k, False: 1.29k]
  ------------------
  413|  1.21k|                i_b += vectorlength;
  414|  1.21k|                if (i_b == st_b) break;
  ------------------
  |  Branch (414:21): [True: 36, False: 1.17k]
  ------------------
  415|  1.17k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  416|  1.17k|            }
  417|  2.50k|        }
  418|  1.47k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (418:13): [True: 1.37k, False: 101]
  |  Branch (418:29): [True: 1.33k, False: 36]
  ------------------
  419|  42.7k|            while (true) {
  ------------------
  |  Branch (419:20): [True: 42.7k, Folded]
  ------------------
  420|  42.7k|                const __m128i res_v = _mm_cmpistrm(
  421|  42.7k|                    v_b, v_a,
  422|  42.7k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  423|  42.7k|                const int r = _mm_extract_epi32(res_v, 0);
  424|  42.7k|                __m128i sm16 =
  425|  42.7k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  426|  42.7k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  427|  42.7k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  428|  42.7k|                count += _mm_popcnt_u32(r);
  429|  42.7k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  430|  42.7k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  431|  42.7k|                if (a_max <= b_max) {
  ------------------
  |  Branch (431:21): [True: 18.8k, False: 23.8k]
  ------------------
  432|  18.8k|                    i_a += vectorlength;
  433|  18.8k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (433:25): [True: 756, False: 18.0k]
  ------------------
  434|  18.0k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  435|  18.0k|                }
  436|  41.9k|                if (b_max <= a_max) {
  ------------------
  |  Branch (436:21): [True: 25.2k, False: 16.6k]
  ------------------
  437|  25.2k|                    i_b += vectorlength;
  438|  25.2k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (438:25): [True: 579, False: 24.7k]
  ------------------
  439|  24.7k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  440|  24.7k|                }
  441|  41.9k|            }
  442|  1.47k|    }
  443|       |    // intersect the tail using scalar intersection
  444|  27.3k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (444:12): [True: 25.9k, False: 1.37k]
  |  Branch (444:25): [True: 25.6k, False: 369]
  ------------------
  445|  25.6k|        uint16_t a = A[i_a];
  446|  25.6k|        uint16_t b = B[i_b];
  447|  25.6k|        if (a < b) {
  ------------------
  |  Branch (447:13): [True: 10.0k, False: 15.5k]
  ------------------
  448|  10.0k|            i_a++;
  449|  15.5k|        } else if (b < a) {
  ------------------
  |  Branch (449:20): [True: 10.0k, False: 5.50k]
  ------------------
  450|  10.0k|            i_b++;
  451|  10.0k|        } else {
  452|  5.50k|            C[count] = a;  //==b;
  453|  5.50k|            count++;
  454|  5.50k|            i_a++;
  455|  5.50k|            i_b++;
  456|  5.50k|        }
  457|  25.6k|    }
  458|  1.74k|    return (int32_t)count;
  459|  1.74k|}
array_container_to_uint32_array_vector16:
  464|  5.70k|                                             uint32_t base) {
  465|  5.70k|    int outpos = 0;
  466|  5.70k|    uint32_t *out = (uint32_t *)vout;
  467|  5.70k|    size_t i = 0;
  468|   181k|    for (; i + sizeof(__m128i) / sizeof(uint16_t) <= cardinality;
  ------------------
  |  Branch (468:12): [True: 176k, False: 5.70k]
  ------------------
  469|   176k|         i += sizeof(__m128i) / sizeof(uint16_t)) {
  470|   176k|        __m128i vinput = _mm_loadu_si128((const __m128i *)(array + i));
  471|   176k|        __m256i voutput = _mm256_add_epi32(_mm256_cvtepu16_epi32(vinput),
  472|   176k|                                           _mm256_set1_epi32(base));
  473|   176k|        _mm256_storeu_si256((__m256i *)(out + outpos), voutput);
  474|   176k|        outpos += sizeof(__m256i) / sizeof(uint32_t);
  475|   176k|    }
  476|  19.6k|    for (; i < cardinality; ++i) {
  ------------------
  |  Branch (476:12): [True: 13.9k, False: 5.70k]
  ------------------
  477|  13.9k|        const uint32_t val = base + array[i];
  478|  13.9k|        memcpy(out + outpos, &val,
  479|  13.9k|               sizeof(uint32_t));  // should be compiled as a MOV on x64
  480|  13.9k|        outpos++;
  481|  13.9k|    }
  482|  5.70k|    return outpos;
  483|  5.70k|}
intersect_vector16_inplace:
  486|  4.43k|                                   size_t s_b) {
  487|  4.43k|    size_t count = 0;
  488|  4.43k|    size_t i_a = 0, i_b = 0;
  489|  4.43k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  490|  4.43k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  491|  4.43k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  492|  4.43k|    __m128i v_a, v_b;
  493|  4.43k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (493:9): [True: 2.21k, False: 2.22k]
  |  Branch (493:25): [True: 2.03k, False: 180]
  ------------------
  494|  2.03k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  495|  2.03k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  496|  2.03k|        __m128i tmp[2] = {_mm_setzero_si128()};
  497|  2.03k|        size_t tmp_count = 0;
  498|  4.03k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (498:16): [True: 1.79k, False: 2.23k]
  |  Branch (498:33): [True: 291, False: 1.94k]
  ------------------
  499|  2.08k|            const __m128i res_v = _mm_cmpestrm(
  500|  2.08k|                v_b, vectorlength, v_a, vectorlength,
  501|  2.08k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  502|  2.08k|            const int r = _mm_extract_epi32(res_v, 0);
  503|  2.08k|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  504|  2.08k|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  505|  2.08k|            _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  506|  2.08k|            tmp_count += _mm_popcnt_u32(r);
  507|  2.08k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  508|  2.08k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  509|  2.08k|            if (a_max <= b_max) {
  ------------------
  |  Branch (509:17): [True: 1.94k, False: 145]
  ------------------
  510|  1.94k|                _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  511|  1.94k|                _mm_storeu_si128(tmp, _mm_setzero_si128());
  512|  1.94k|                count += tmp_count;
  513|  1.94k|                tmp_count = 0;
  514|  1.94k|                i_a += vectorlength;
  515|  1.94k|                if (i_a == st_a) break;
  ------------------
  |  Branch (515:21): [True: 72, False: 1.87k]
  ------------------
  516|  1.87k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  517|  1.87k|            }
  518|  2.01k|            if (b_max <= a_max) {
  ------------------
  |  Branch (518:17): [True: 332, False: 1.68k]
  ------------------
  519|    332|                i_b += vectorlength;
  520|    332|                if (i_b == st_b) break;
  ------------------
  |  Branch (520:21): [True: 13, False: 319]
  ------------------
  521|    319|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  522|    319|            }
  523|  2.01k|        }
  524|  2.03k|        if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (524:13): [True: 1.96k, False: 72]
  |  Branch (524:29): [True: 1.94k, False: 13]
  ------------------
  525|   220k|            while (true) {
  ------------------
  |  Branch (525:20): [True: 220k, Folded]
  ------------------
  526|   220k|                const __m128i res_v = _mm_cmpistrm(
  527|   220k|                    v_b, v_a,
  528|   220k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  529|   220k|                const int r = _mm_extract_epi32(res_v, 0);
  530|   220k|                __m128i sm16 =
  531|   220k|                    _mm_loadu_si128((const __m128i *)shuffle_mask16 + r);
  532|   220k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  533|   220k|                _mm_storeu_si128((__m128i *)&((uint16_t *)tmp)[tmp_count], p);
  534|   220k|                tmp_count += _mm_popcnt_u32(r);
  535|   220k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  536|   220k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  537|   220k|                if (a_max <= b_max) {
  ------------------
  |  Branch (537:21): [True: 130k, False: 90.1k]
  ------------------
  538|   130k|                    _mm_storeu_si128((__m128i *)&A[count], tmp[0]);
  539|   130k|                    _mm_storeu_si128(tmp, _mm_setzero_si128());
  540|   130k|                    count += tmp_count;
  541|   130k|                    tmp_count = 0;
  542|   130k|                    i_a += vectorlength;
  543|   130k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (543:25): [True: 1.07k, False: 129k]
  ------------------
  544|   129k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  545|   129k|                }
  546|   219k|                if (b_max <= a_max) {
  ------------------
  |  Branch (546:21): [True: 124k, False: 95.0k]
  ------------------
  547|   124k|                    i_b += vectorlength;
  548|   124k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (548:25): [True: 874, False: 123k]
  ------------------
  549|   123k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  550|   123k|                }
  551|   219k|            }
  552|  1.94k|        }
  553|       |        // tmp_count <= 8, so this does not affect efficiency so much
  554|  4.44k|        for (size_t i = 0; i < tmp_count; i++) {
  ------------------
  |  Branch (554:28): [True: 2.41k, False: 2.03k]
  ------------------
  555|  2.41k|            A[count] = ((uint16_t *)tmp)[i];
  556|  2.41k|            count++;
  557|  2.41k|        }
  558|  2.03k|        i_a += tmp_count;  // We can at least jump pass $tmp_count elements in A
  559|  2.03k|    }
  560|       |    // intersect the tail using scalar intersection
  561|  31.2k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (561:12): [True: 27.2k, False: 4.00k]
  |  Branch (561:25): [True: 26.8k, False: 426]
  ------------------
  562|  26.8k|        uint16_t a = A[i_a];
  563|  26.8k|        uint16_t b = B[i_b];
  564|  26.8k|        if (a < b) {
  ------------------
  |  Branch (564:13): [True: 8.54k, False: 18.2k]
  ------------------
  565|  8.54k|            i_a++;
  566|  18.2k|        } else if (b < a) {
  ------------------
  |  Branch (566:20): [True: 6.77k, False: 11.5k]
  ------------------
  567|  6.77k|            i_b++;
  568|  11.5k|        } else {
  569|  11.5k|            A[count] = a;  //==b;
  570|  11.5k|            count++;
  571|  11.5k|            i_a++;
  572|  11.5k|            i_b++;
  573|  11.5k|        }
  574|  26.8k|    }
  575|  4.43k|    return (int32_t)count;
  576|  4.43k|}
intersect_vector16_cardinality:
  581|  6.98k|                                       const uint16_t *B, size_t s_b) {
  582|  6.98k|    size_t count = 0;
  583|  6.98k|    size_t i_a = 0, i_b = 0;
  584|  6.98k|    const int vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  585|  6.98k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  586|  6.98k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  587|  6.98k|    __m128i v_a, v_b;
  588|  6.98k|    if ((i_a < st_a) && (i_b < st_b)) {
  ------------------
  |  Branch (588:9): [True: 6.47k, False: 508]
  |  Branch (588:25): [True: 5.88k, False: 584]
  ------------------
  589|  5.88k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  590|  5.88k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  591|  15.7k|        while ((A[i_a] == 0) || (B[i_b] == 0)) {
  ------------------
  |  Branch (591:16): [True: 9.69k, False: 6.07k]
  |  Branch (591:33): [True: 736, False: 5.34k]
  ------------------
  592|  10.4k|            const __m128i res_v = _mm_cmpestrm(
  593|  10.4k|                v_b, vectorlength, v_a, vectorlength,
  594|  10.4k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  595|  10.4k|            const int r = _mm_extract_epi32(res_v, 0);
  596|  10.4k|            count += _mm_popcnt_u32(r);
  597|  10.4k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  598|  10.4k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  599|  10.4k|            if (a_max <= b_max) {
  ------------------
  |  Branch (599:17): [True: 6.01k, False: 4.41k]
  ------------------
  600|  6.01k|                i_a += vectorlength;
  601|  6.01k|                if (i_a == st_a) break;
  ------------------
  |  Branch (601:21): [True: 404, False: 5.61k]
  ------------------
  602|  5.61k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  603|  5.61k|            }
  604|  10.0k|            if (b_max <= a_max) {
  ------------------
  |  Branch (604:17): [True: 4.86k, False: 5.16k]
  ------------------
  605|  4.86k|                i_b += vectorlength;
  606|  4.86k|                if (i_b == st_b) break;
  ------------------
  |  Branch (606:21): [True: 144, False: 4.71k]
  ------------------
  607|  4.71k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  608|  4.71k|            }
  609|  10.0k|        }
  610|  5.88k|        if ((i_a < st_a) && (i_b < st_b))
  ------------------
  |  Branch (610:13): [True: 5.48k, False: 404]
  |  Branch (610:29): [True: 5.34k, False: 144]
  ------------------
  611|   170k|            while (true) {
  ------------------
  |  Branch (611:20): [True: 170k, Folded]
  ------------------
  612|   170k|                const __m128i res_v = _mm_cmpistrm(
  613|   170k|                    v_b, v_a,
  614|   170k|                    _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  615|   170k|                const int r = _mm_extract_epi32(res_v, 0);
  616|   170k|                count += _mm_popcnt_u32(r);
  617|   170k|                const uint16_t a_max = A[i_a + vectorlength - 1];
  618|   170k|                const uint16_t b_max = B[i_b + vectorlength - 1];
  619|   170k|                if (a_max <= b_max) {
  ------------------
  |  Branch (619:21): [True: 75.3k, False: 95.4k]
  ------------------
  620|  75.3k|                    i_a += vectorlength;
  621|  75.3k|                    if (i_a == st_a) break;
  ------------------
  |  Branch (621:25): [True: 3.02k, False: 72.3k]
  ------------------
  622|  72.3k|                    v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  623|  72.3k|                }
  624|   167k|                if (b_max <= a_max) {
  ------------------
  |  Branch (624:21): [True: 101k, False: 66.5k]
  ------------------
  625|   101k|                    i_b += vectorlength;
  626|   101k|                    if (i_b == st_b) break;
  ------------------
  |  Branch (626:25): [True: 2.31k, False: 98.8k]
  ------------------
  627|  98.8k|                    v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  628|  98.8k|                }
  629|   167k|            }
  630|  5.88k|    }
  631|       |    // intersect the tail using scalar intersection
  632|   109k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (632:12): [True: 103k, False: 5.50k]
  |  Branch (632:25): [True: 102k, False: 1.47k]
  ------------------
  633|   102k|        uint16_t a = A[i_a];
  634|   102k|        uint16_t b = B[i_b];
  635|   102k|        if (a < b) {
  ------------------
  |  Branch (635:13): [True: 40.3k, False: 62.1k]
  ------------------
  636|  40.3k|            i_a++;
  637|  62.1k|        } else if (b < a) {
  ------------------
  |  Branch (637:20): [True: 40.1k, False: 22.0k]
  ------------------
  638|  40.1k|            i_b++;
  639|  40.1k|        } else {
  640|  22.0k|            count++;
  641|  22.0k|            i_a++;
  642|  22.0k|            i_b++;
  643|  22.0k|        }
  644|   102k|    }
  645|  6.98k|    return (int32_t)count;
  646|  6.98k|}
difference_vector16:
  655|  2.27k|                            size_t s_b, uint16_t *C) {
  656|       |    // we handle the degenerate case
  657|  2.27k|    if (s_a == 0) return 0;
  ------------------
  |  Branch (657:9): [True: 0, False: 2.27k]
  ------------------
  658|  2.27k|    if (s_b == 0) {
  ------------------
  |  Branch (658:9): [True: 0, False: 2.27k]
  ------------------
  659|      0|        if (A != C) memcpy(C, A, sizeof(uint16_t) * s_a);
  ------------------
  |  Branch (659:13): [True: 0, False: 0]
  ------------------
  660|      0|        return (int32_t)s_a;
  661|      0|    }
  662|       |    // handle the leading zeroes, it is messy but it allows us to use the fast
  663|       |    // _mm_cmpistrm instrinsic safely
  664|  2.27k|    int32_t count = 0;
  665|  2.27k|    if ((A[0] == 0) || (B[0] == 0)) {
  ------------------
  |  Branch (665:9): [True: 2.08k, False: 187]
  |  Branch (665:24): [True: 3, False: 184]
  ------------------
  666|  2.08k|        if ((A[0] == 0) && (B[0] == 0)) {
  ------------------
  |  Branch (666:13): [True: 2.08k, False: 3]
  |  Branch (666:28): [True: 318, False: 1.76k]
  ------------------
  667|    318|            A++;
  668|    318|            s_a--;
  669|    318|            B++;
  670|    318|            s_b--;
  671|  1.76k|        } else if (A[0] == 0) {
  ------------------
  |  Branch (671:20): [True: 1.76k, False: 3]
  ------------------
  672|  1.76k|            C[count++] = 0;
  673|  1.76k|            A++;
  674|  1.76k|            s_a--;
  675|  1.76k|        } else {
  676|      3|            B++;
  677|      3|            s_b--;
  678|      3|        }
  679|  2.08k|    }
  680|       |    // at this point, we have two non-empty arrays, made of non-zero
  681|       |    // increasing values.
  682|  2.27k|    size_t i_a = 0, i_b = 0;
  683|  2.27k|    const size_t vectorlength = sizeof(__m128i) / sizeof(uint16_t);
  684|  2.27k|    const size_t st_a = (s_a / vectorlength) * vectorlength;
  685|  2.27k|    const size_t st_b = (s_b / vectorlength) * vectorlength;
  686|  2.27k|    if ((i_a < st_a) && (i_b < st_b)) {  // this is the vectorized code path
  ------------------
  |  Branch (686:9): [True: 1.87k, False: 393]
  |  Branch (686:25): [True: 1.59k, False: 288]
  ------------------
  687|  1.59k|        __m128i v_a, v_b;                //, v_bmax;
  688|       |        // we load a vector from A and a vector from B
  689|  1.59k|        v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  690|  1.59k|        v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  691|       |        // we have a runningmask which indicates which values from A have been
  692|       |        // spotted in B, these don't get written out.
  693|  1.59k|        __m128i runningmask_a_found_in_b = _mm_setzero_si128();
  694|       |        /****
  695|       |         * start of the main vectorized loop
  696|       |         *****/
  697|  45.9k|        while (true) {
  ------------------
  |  Branch (697:16): [True: 45.9k, Folded]
  ------------------
  698|       |            // afoundinb will contain a mask indicate for each entry in A
  699|       |            // whether it is seen
  700|       |            // in B
  701|  45.9k|            const __m128i a_found_in_b = _mm_cmpistrm(
  702|  45.9k|                v_b, v_a,
  703|  45.9k|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  704|  45.9k|            runningmask_a_found_in_b =
  705|  45.9k|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  706|       |            // we always compare the last values of A and B
  707|  45.9k|            const uint16_t a_max = A[i_a + vectorlength - 1];
  708|  45.9k|            const uint16_t b_max = B[i_b + vectorlength - 1];
  709|  45.9k|            if (a_max <= b_max) {
  ------------------
  |  Branch (709:17): [True: 20.6k, False: 25.3k]
  ------------------
  710|       |                // Ok. In this code path, we are ready to write our v_a
  711|       |                // because there is no need to read more from B, they will
  712|       |                // all be large values.
  713|  20.6k|                const int bitmask_belongs_to_difference =
  714|  20.6k|                    _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  715|       |                /*** next few lines are probably expensive *****/
  716|  20.6k|                __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  717|  20.6k|                                               bitmask_belongs_to_difference);
  718|  20.6k|                __m128i p = _mm_shuffle_epi8(v_a, sm16);
  719|  20.6k|                _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  720|  20.6k|                count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  721|       |                // we advance a
  722|  20.6k|                i_a += vectorlength;
  723|  20.6k|                if (i_a == st_a)  // no more
  ------------------
  |  Branch (723:21): [True: 1.10k, False: 19.5k]
  ------------------
  724|  1.10k|                    break;
  725|  19.5k|                runningmask_a_found_in_b = _mm_setzero_si128();
  726|  19.5k|                v_a = _mm_lddqu_si128((__m128i *)&A[i_a]);
  727|  19.5k|            }
  728|  44.8k|            if (b_max <= a_max) {
  ------------------
  |  Branch (728:17): [True: 28.3k, False: 16.4k]
  ------------------
  729|       |                // in this code path, the current v_b has become useless
  730|  28.3k|                i_b += vectorlength;
  731|  28.3k|                if (i_b == st_b) break;
  ------------------
  |  Branch (731:21): [True: 481, False: 27.9k]
  ------------------
  732|  27.9k|                v_b = _mm_lddqu_si128((__m128i *)&B[i_b]);
  733|  27.9k|            }
  734|  44.8k|        }
  735|       |        // at this point, either we have i_a == st_a, which is the end of the
  736|       |        // vectorized processing,
  737|       |        // or we have i_b == st_b,  and we are not done processing the vector...
  738|       |        // so we need to finish it off.
  739|  1.59k|        if (i_a < st_a) {        // we have unfinished business...
  ------------------
  |  Branch (739:13): [True: 481, False: 1.10k]
  ------------------
  740|    481|            uint16_t buffer[8];  // buffer to do a masked load
  741|    481|            memset(buffer, 0, 8 * sizeof(uint16_t));
  742|    481|            memcpy(buffer, B + i_b, (s_b - i_b) * sizeof(uint16_t));
  743|    481|            v_b = _mm_lddqu_si128((__m128i *)buffer);
  744|    481|            const __m128i a_found_in_b = _mm_cmpistrm(
  745|    481|                v_b, v_a,
  746|    481|                _SIDD_UWORD_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK);
  747|    481|            runningmask_a_found_in_b =
  748|    481|                _mm_or_si128(runningmask_a_found_in_b, a_found_in_b);
  749|    481|            const int bitmask_belongs_to_difference =
  750|    481|                _mm_extract_epi32(runningmask_a_found_in_b, 0) ^ 0xFF;
  751|    481|            __m128i sm16 = _mm_loadu_si128((const __m128i *)shuffle_mask16 +
  752|    481|                                           bitmask_belongs_to_difference);
  753|    481|            __m128i p = _mm_shuffle_epi8(v_a, sm16);
  754|    481|            _mm_storeu_si128((__m128i *)&C[count], p);  // can overflow
  755|    481|            count += _mm_popcnt_u32(bitmask_belongs_to_difference);
  756|    481|            i_a += vectorlength;
  757|    481|        }
  758|       |        // at this point we should have i_a == st_a and i_b == st_b
  759|  1.59k|    }
  760|       |    // do the tail using scalar code
  761|  98.1k|    while (i_a < s_a && i_b < s_b) {
  ------------------
  |  Branch (761:12): [True: 96.3k, False: 1.73k]
  |  Branch (761:25): [True: 95.8k, False: 534]
  ------------------
  762|  95.8k|        uint16_t a = A[i_a];
  763|  95.8k|        uint16_t b = B[i_b];
  764|  95.8k|        if (b < a) {
  ------------------
  |  Branch (764:13): [True: 67.5k, False: 28.3k]
  ------------------
  765|  67.5k|            i_b++;
  766|  67.5k|        } else if (a < b) {
  ------------------
  |  Branch (766:20): [True: 23.0k, False: 5.30k]
  ------------------
  767|  23.0k|            C[count] = a;
  768|  23.0k|            count++;
  769|  23.0k|            i_a++;
  770|  23.0k|        } else {  //==
  771|  5.30k|            i_a++;
  772|  5.30k|            i_b++;
  773|  5.30k|        }
  774|  95.8k|    }
  775|  2.27k|    if (i_a < s_a) {
  ------------------
  |  Branch (775:9): [True: 534, False: 1.73k]
  ------------------
  776|    534|        if (C == A) {
  ------------------
  |  Branch (776:13): [True: 0, False: 534]
  ------------------
  777|      0|            assert((size_t)count <= i_a);
  778|      0|            if ((size_t)count < i_a) {
  ------------------
  |  Branch (778:17): [True: 0, False: 0]
  ------------------
  779|      0|                memmove(C + count, A + i_a, sizeof(uint16_t) * (s_a - i_a));
  780|      0|            }
  781|    534|        } else {
  782|  26.7k|            for (size_t i = 0; i < (s_a - i_a); i++) {
  ------------------
  |  Branch (782:32): [True: 26.1k, False: 534]
  ------------------
  783|  26.1k|                C[count + i] = A[i + i_a];
  784|  26.1k|            }
  785|    534|        }
  786|    534|        count += (int32_t)(s_a - i_a);
  787|    534|    }
  788|  2.27k|    return count;
  789|  2.27k|}
intersect_skewed_uint16:
  855|    735|                                uint16_t *buffer) {
  856|    735|    size_t pos = 0, idx_l = 0, idx_s = 0;
  857|       |
  858|    735|    if (0 == size_s) {
  ------------------
  |  Branch (858:9): [True: 0, False: 735]
  ------------------
  859|      0|        return 0;
  860|      0|    }
  861|    735|    int32_t index1 = 0, index2 = 0, index3 = 0, index4 = 0;
  862|  1.94k|    while ((idx_s + 4 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (862:12): [True: 1.21k, False: 734]
  |  Branch (862:37): [True: 1.21k, False: 1]
  ------------------
  863|  1.21k|        uint16_t target1 = small[idx_s];
  864|  1.21k|        uint16_t target2 = small[idx_s + 1];
  865|  1.21k|        uint16_t target3 = small[idx_s + 2];
  866|  1.21k|        uint16_t target4 = small[idx_s + 3];
  867|  1.21k|        binarySearch4(large + idx_l, (int32_t)(size_l - idx_l), target1,
  868|  1.21k|                      target2, target3, target4, &index1, &index2, &index3,
  869|  1.21k|                      &index4);
  870|  1.21k|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (870:13): [True: 1.20k, False: 2]
  |  Branch (870:42): [True: 582, False: 627]
  ------------------
  871|    582|            buffer[pos++] = target1;
  872|    582|        }
  873|  1.21k|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (873:13): [True: 1.20k, False: 4]
  |  Branch (873:42): [True: 703, False: 504]
  ------------------
  874|    703|            buffer[pos++] = target2;
  875|    703|        }
  876|  1.21k|        if ((index3 + idx_l < size_l) && (large[idx_l + index3] == target3)) {
  ------------------
  |  Branch (876:13): [True: 1.20k, False: 5]
  |  Branch (876:42): [True: 676, False: 530]
  ------------------
  877|    676|            buffer[pos++] = target3;
  878|    676|        }
  879|  1.21k|        if ((index4 + idx_l < size_l) && (large[idx_l + index4] == target4)) {
  ------------------
  |  Branch (879:13): [True: 1.20k, False: 8]
  |  Branch (879:42): [True: 647, False: 556]
  ------------------
  880|    647|            buffer[pos++] = target4;
  881|    647|        }
  882|  1.21k|        idx_s += 4;
  883|  1.21k|        idx_l += index4;
  884|  1.21k|    }
  885|    735|    if ((idx_s + 2 <= size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (885:9): [True: 370, False: 365]
  |  Branch (885:34): [True: 368, False: 2]
  ------------------
  886|    368|        uint16_t target1 = small[idx_s];
  887|    368|        uint16_t target2 = small[idx_s + 1];
  888|    368|        binarySearch2(large + idx_l, (int32_t)(size_l - idx_l), target1,
  889|    368|                      target2, &index1, &index2);
  890|    368|        if ((index1 + idx_l < size_l) && (large[idx_l + index1] == target1)) {
  ------------------
  |  Branch (890:13): [True: 363, False: 5]
  |  Branch (890:42): [True: 241, False: 122]
  ------------------
  891|    241|            buffer[pos++] = target1;
  892|    241|        }
  893|    368|        if ((index2 + idx_l < size_l) && (large[idx_l + index2] == target2)) {
  ------------------
  |  Branch (893:13): [True: 352, False: 16]
  |  Branch (893:42): [True: 245, False: 107]
  ------------------
  894|    245|            buffer[pos++] = target2;
  895|    245|        }
  896|    368|        idx_s += 2;
  897|    368|        idx_l += index2;
  898|    368|    }
  899|    735|    if ((idx_s < size_s) && (idx_l < size_l)) {
  ------------------
  |  Branch (899:9): [True: 343, False: 392]
  |  Branch (899:29): [True: 340, False: 3]
  ------------------
  900|    340|        uint16_t val_s = small[idx_s];
  901|    340|        int32_t index =
  902|    340|            binarySearch(large + idx_l, (int32_t)(size_l - idx_l), val_s);
  903|    340|        if (index >= 0) buffer[pos++] = val_s;
  ------------------
  |  Branch (903:13): [True: 242, False: 98]
  ------------------
  904|    340|    }
  905|    735|    return (int32_t)pos;
  906|    735|}
intersect_skewed_uint16_cardinality:
  912|  2.10k|                                            size_t size_l) {
  913|  2.10k|    size_t pos = 0, idx_l = 0, idx_s = 0;
  914|       |
  915|  2.10k|    if (0 == size_s) {
  ------------------
  |  Branch (915:9): [True: 0, False: 2.10k]
  ------------------
  916|      0|        return 0;
  917|      0|    }
  918|       |
  919|  2.10k|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  920|       |
  921|  27.6k|    while (true) {
  ------------------
  |  Branch (921:12): [True: 27.6k, Folded]
  ------------------
  922|  27.6k|        if (val_l < val_s) {
  ------------------
  |  Branch (922:13): [True: 5.80k, False: 21.8k]
  ------------------
  923|  5.80k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  924|  5.80k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (924:17): [True: 92, False: 5.70k]
  ------------------
  925|  5.70k|            val_l = large[idx_l];
  926|  21.8k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (926:20): [True: 10.1k, False: 11.7k]
  ------------------
  927|  10.1k|            idx_s++;
  928|  10.1k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (928:17): [True: 892, False: 9.22k]
  ------------------
  929|  9.22k|            val_s = small[idx_s];
  930|  11.7k|        } else {
  931|  11.7k|            pos++;
  932|  11.7k|            idx_s++;
  933|  11.7k|            if (idx_s == size_s) break;
  ------------------
  |  Branch (933:17): [True: 1.05k, False: 10.7k]
  ------------------
  934|  10.7k|            val_s = small[idx_s];
  935|  10.7k|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  936|  10.7k|            if (idx_l == size_l) break;
  ------------------
  |  Branch (936:17): [True: 68, False: 10.6k]
  ------------------
  937|  10.6k|            val_l = large[idx_l];
  938|  10.6k|        }
  939|  27.6k|    }
  940|       |
  941|  2.10k|    return (int32_t)pos;
  942|  2.10k|}
intersect_skewed_uint16_nonempty:
  945|    526|                                      const uint16_t *large, size_t size_l) {
  946|    526|    size_t idx_l = 0, idx_s = 0;
  947|       |
  948|    526|    if (0 == size_s) {
  ------------------
  |  Branch (948:9): [True: 0, False: 526]
  ------------------
  949|      0|        return false;
  950|      0|    }
  951|       |
  952|    526|    uint16_t val_l = large[idx_l], val_s = small[idx_s];
  953|       |
  954|  2.05k|    while (true) {
  ------------------
  |  Branch (954:12): [True: 2.05k, Folded]
  ------------------
  955|  2.05k|        if (val_l < val_s) {
  ------------------
  |  Branch (955:13): [True: 786, False: 1.26k]
  ------------------
  956|    786|            idx_l = advanceUntil(large, (int32_t)idx_l, (int32_t)size_l, val_s);
  957|    786|            if (idx_l == size_l) break;
  ------------------
  |  Branch (957:17): [True: 22, False: 764]
  ------------------
  958|    764|            val_l = large[idx_l];
  959|  1.26k|        } else if (val_s < val_l) {
  ------------------
  |  Branch (959:20): [True: 840, False: 425]
  ------------------
  960|    840|            idx_s++;
  961|    840|            if (idx_s == size_s) break;
  ------------------
  |  Branch (961:17): [True: 79, False: 761]
  ------------------
  962|    761|            val_s = small[idx_s];
  963|    761|        } else {
  964|    425|            return true;
  965|    425|        }
  966|  2.05k|    }
  967|       |
  968|    101|    return false;
  969|    526|}
intersect_uint16_nonempty:
 1025|  1.74k|                               const uint16_t *B, const size_t lenB) {
 1026|  1.74k|    if (lenA == 0 || lenB == 0) return 0;
  ------------------
  |  Branch (1026:9): [True: 0, False: 1.74k]
  |  Branch (1026:22): [True: 0, False: 1.74k]
  ------------------
 1027|  1.74k|    const uint16_t *endA = A + lenA;
 1028|  1.74k|    const uint16_t *endB = B + lenB;
 1029|       |
 1030|  1.74k|    while (1) {
  ------------------
  |  Branch (1030:12): [True: 1.74k, Folded]
  ------------------
 1031|  9.38k|        while (*A < *B) {
  ------------------
  |  Branch (1031:16): [True: 7.16k, False: 2.22k]
  ------------------
 1032|  7.68k|        SKIP_FIRST_COMPARE:
 1033|  7.68k|            if (++A == endA) return false;
  ------------------
  |  Branch (1033:17): [True: 39, False: 7.64k]
  ------------------
 1034|  7.68k|        }
 1035|  4.83k|        while (*A > *B) {
  ------------------
  |  Branch (1035:16): [True: 2.61k, False: 2.22k]
  ------------------
 1036|  2.61k|            if (++B == endB) return false;
  ------------------
  |  Branch (1036:17): [True: 8, False: 2.60k]
  ------------------
 1037|  2.61k|        }
 1038|  2.22k|        if (*A == *B) {
  ------------------
  |  Branch (1038:13): [True: 1.69k, False: 522]
  ------------------
 1039|  1.69k|            return true;
 1040|  1.69k|        } else {
 1041|    522|            goto SKIP_FIRST_COMPARE;
 1042|    522|        }
 1043|  2.22k|    }
 1044|      0|    return false;  // NOTREACHED
 1045|  1.74k|}
union_uint16:
 1105|  4.52k|                    size_t size_2, uint16_t *buffer) {
 1106|  4.52k|    size_t pos = 0, idx_1 = 0, idx_2 = 0;
 1107|       |
 1108|  4.52k|    if (0 == size_2) {
  ------------------
  |  Branch (1108:9): [True: 64, False: 4.46k]
  ------------------
 1109|     64|        memmove(buffer, set_1, size_1 * sizeof(uint16_t));
 1110|     64|        return size_1;
 1111|     64|    }
 1112|  4.46k|    if (0 == size_1) {
  ------------------
  |  Branch (1112:9): [True: 0, False: 4.46k]
  ------------------
 1113|      0|        memmove(buffer, set_2, size_2 * sizeof(uint16_t));
 1114|      0|        return size_2;
 1115|      0|    }
 1116|       |
 1117|  4.46k|    uint16_t val_1 = set_1[idx_1], val_2 = set_2[idx_2];
 1118|       |
 1119|   192k|    while (true) {
  ------------------
  |  Branch (1119:12): [True: 192k, Folded]
  ------------------
 1120|   192k|        if (val_1 < val_2) {
  ------------------
  |  Branch (1120:13): [True: 7.67k, False: 184k]
  ------------------
 1121|  7.67k|            buffer[pos++] = val_1;
 1122|  7.67k|            ++idx_1;
 1123|  7.67k|            if (idx_1 >= size_1) break;
  ------------------
  |  Branch (1123:17): [True: 383, False: 7.28k]
  ------------------
 1124|  7.28k|            val_1 = set_1[idx_1];
 1125|   184k|        } else if (val_2 < val_1) {
  ------------------
  |  Branch (1125:20): [True: 153k, False: 31.3k]
  ------------------
 1126|   153k|            buffer[pos++] = val_2;
 1127|   153k|            ++idx_2;
 1128|   153k|            if (idx_2 >= size_2) break;
  ------------------
  |  Branch (1128:17): [True: 176, False: 153k]
  ------------------
 1129|   153k|            val_2 = set_2[idx_2];
 1130|   153k|        } else {
 1131|  31.3k|            buffer[pos++] = val_1;
 1132|  31.3k|            ++idx_1;
 1133|  31.3k|            ++idx_2;
 1134|  31.3k|            if (idx_1 >= size_1 || idx_2 >= size_2) break;
  ------------------
  |  Branch (1134:17): [True: 3.77k, False: 27.5k]
  |  Branch (1134:36): [True: 128, False: 27.4k]
  ------------------
 1135|  27.4k|            val_1 = set_1[idx_1];
 1136|  27.4k|            val_2 = set_2[idx_2];
 1137|  27.4k|        }
 1138|   192k|    }
 1139|       |
 1140|  4.46k|    if (idx_1 < size_1) {
  ------------------
  |  Branch (1140:9): [True: 304, False: 4.16k]
  ------------------
 1141|    304|        const size_t n_elems = size_1 - idx_1;
 1142|    304|        memmove(buffer + pos, set_1 + idx_1, n_elems * sizeof(uint16_t));
 1143|    304|        pos += n_elems;
 1144|  4.16k|    } else if (idx_2 < size_2) {
  ------------------
  |  Branch (1144:16): [True: 1.75k, False: 2.40k]
  ------------------
 1145|  1.75k|        const size_t n_elems = size_2 - idx_2;
 1146|  1.75k|        memmove(buffer + pos, set_2 + idx_2, n_elems * sizeof(uint16_t));
 1147|  1.75k|        pos += n_elems;
 1148|  1.75k|    }
 1149|       |
 1150|  4.46k|    return pos;
 1151|  4.46k|}
difference_uint16:
 1154|  3.43k|                      int length2, uint16_t *a_out) {
 1155|  3.43k|    int out_card = 0;
 1156|  3.43k|    int k1 = 0, k2 = 0;
 1157|  3.43k|    if (length1 == 0) return 0;
  ------------------
  |  Branch (1157:9): [True: 0, False: 3.43k]
  ------------------
 1158|  3.43k|    if (length2 == 0) {
  ------------------
  |  Branch (1158:9): [True: 0, False: 3.43k]
  ------------------
 1159|      0|        if (a1 != a_out) memcpy(a_out, a1, sizeof(uint16_t) * length1);
  ------------------
  |  Branch (1159:13): [True: 0, False: 0]
  ------------------
 1160|      0|        return length1;
 1161|      0|    }
 1162|  3.43k|    uint16_t s1 = a1[k1];
 1163|  3.43k|    uint16_t s2 = a2[k2];
 1164|   423k|    while (true) {
  ------------------
  |  Branch (1164:12): [True: 423k, Folded]
  ------------------
 1165|   423k|        if (s1 < s2) {
  ------------------
  |  Branch (1165:13): [True: 207k, False: 216k]
  ------------------
 1166|   207k|            a_out[out_card++] = s1;
 1167|   207k|            ++k1;
 1168|   207k|            if (k1 >= length1) {
  ------------------
  |  Branch (1168:17): [True: 0, False: 207k]
  ------------------
 1169|      0|                break;
 1170|      0|            }
 1171|   207k|            s1 = a1[k1];
 1172|   216k|        } else if (s1 == s2) {
  ------------------
  |  Branch (1172:20): [True: 216k, False: 0]
  ------------------
 1173|   216k|            ++k1;
 1174|   216k|            ++k2;
 1175|   216k|            if (k1 >= length1) {
  ------------------
  |  Branch (1175:17): [True: 2.23k, False: 214k]
  ------------------
 1176|  2.23k|                break;
 1177|  2.23k|            }
 1178|   214k|            if (k2 >= length2) {
  ------------------
  |  Branch (1178:17): [True: 1.20k, False: 213k]
  ------------------
 1179|  1.20k|                memmove(a_out + out_card, a1 + k1,
 1180|  1.20k|                        sizeof(uint16_t) * (length1 - k1));
 1181|  1.20k|                return out_card + length1 - k1;
 1182|  1.20k|            }
 1183|   213k|            s1 = a1[k1];
 1184|   213k|            s2 = a2[k2];
 1185|   213k|        } else {  // if (val1>val2)
 1186|      0|            ++k2;
 1187|      0|            if (k2 >= length2) {
  ------------------
  |  Branch (1187:17): [True: 0, False: 0]
  ------------------
 1188|      0|                memmove(a_out + out_card, a1 + k1,
 1189|      0|                        sizeof(uint16_t) * (length1 - k1));
 1190|      0|                return out_card + length1 - k1;
 1191|      0|            }
 1192|      0|            s2 = a2[k2];
 1193|      0|        }
 1194|   423k|    }
 1195|  2.23k|    return out_card;
 1196|  3.43k|}
xor_uint16:
 1199|  7.70k|                   const uint16_t *array_2, int32_t card_2, uint16_t *out) {
 1200|  7.70k|    int32_t pos1 = 0, pos2 = 0, pos_out = 0;
 1201|   206k|    while (pos1 < card_1 && pos2 < card_2) {
  ------------------
  |  Branch (1201:12): [True: 199k, False: 7.12k]
  |  Branch (1201:29): [True: 198k, False: 580]
  ------------------
 1202|   198k|        const uint16_t v1 = array_1[pos1];
 1203|   198k|        const uint16_t v2 = array_2[pos2];
 1204|   198k|        if (v1 == v2) {
  ------------------
  |  Branch (1204:13): [True: 38.2k, False: 160k]
  ------------------
 1205|  38.2k|            ++pos1;
 1206|  38.2k|            ++pos2;
 1207|  38.2k|            continue;
 1208|  38.2k|        }
 1209|   160k|        if (v1 < v2) {
  ------------------
  |  Branch (1209:13): [True: 28.1k, False: 132k]
  ------------------
 1210|  28.1k|            out[pos_out++] = v1;
 1211|  28.1k|            ++pos1;
 1212|   132k|        } else {
 1213|   132k|            out[pos_out++] = v2;
 1214|   132k|            ++pos2;
 1215|   132k|        }
 1216|   160k|    }
 1217|  7.70k|    if (pos1 < card_1) {
  ------------------
  |  Branch (1217:9): [True: 580, False: 7.12k]
  ------------------
 1218|    580|        const size_t n_elems = card_1 - pos1;
 1219|    580|        memcpy(out + pos_out, array_1 + pos1, n_elems * sizeof(uint16_t));
 1220|    580|        pos_out += (int32_t)n_elems;
 1221|  7.12k|    } else if (pos2 < card_2) {
  ------------------
  |  Branch (1221:16): [True: 2.23k, False: 4.88k]
  ------------------
 1222|  2.23k|        const size_t n_elems = card_2 - pos2;
 1223|  2.23k|        memcpy(out + pos_out, array_2 + pos2, n_elems * sizeof(uint16_t));
 1224|  2.23k|        pos_out += (int32_t)n_elems;
 1225|  2.23k|    }
 1226|  7.70k|    return pos_out;
 1227|  7.70k|}
union_vector16:
 1654|  4.52k|                        uint16_t *output) {
 1655|  4.52k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1655:9): [True: 990, False: 3.53k]
  |  Branch (1655:26): [True: 0, False: 3.53k]
  ------------------
 1656|    990|        return (uint32_t)union_uint16(array1, length1, array2, length2, output);
 1657|    990|    }
 1658|  3.53k|    __m128i vA, vB, V, vecMin, vecMax;
 1659|  3.53k|    __m128i laststore;
 1660|  3.53k|    uint16_t *initoutput = output;
 1661|  3.53k|    uint32_t len1 = length1 / 8;
 1662|  3.53k|    uint32_t len2 = length2 / 8;
 1663|  3.53k|    uint32_t pos1 = 0;
 1664|  3.53k|    uint32_t pos2 = 0;
 1665|       |    // we start the machine
 1666|  3.53k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1667|  3.53k|    pos1++;
 1668|  3.53k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1669|  3.53k|    pos2++;
 1670|  3.53k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1671|  3.53k|    laststore = _mm_set1_epi16(-1);
 1672|  3.53k|    output += store_unique(laststore, vecMin, output);
 1673|  3.53k|    laststore = vecMin;
 1674|  3.53k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1674:9): [True: 3.03k, False: 509]
  |  Branch (1674:26): [True: 3.03k, False: 0]
  ------------------
 1675|  3.03k|        uint16_t curA, curB;
 1676|  3.03k|        curA = array1[8 * pos1];
 1677|  3.03k|        curB = array2[8 * pos2];
 1678|   102k|        while (true) {
  ------------------
  |  Branch (1678:16): [True: 102k, Folded]
  ------------------
 1679|   102k|            if (curA <= curB) {
  ------------------
  |  Branch (1679:17): [True: 43.2k, False: 59.2k]
  ------------------
 1680|  43.2k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1681|  43.2k|                pos1++;
 1682|  43.2k|                if (pos1 < len1) {
  ------------------
  |  Branch (1682:21): [True: 41.0k, False: 2.27k]
  ------------------
 1683|  41.0k|                    curA = array1[8 * pos1];
 1684|  41.0k|                } else {
 1685|  2.27k|                    break;
 1686|  2.27k|                }
 1687|  59.2k|            } else {
 1688|  59.2k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1689|  59.2k|                pos2++;
 1690|  59.2k|                if (pos2 < len2) {
  ------------------
  |  Branch (1690:21): [True: 58.5k, False: 751]
  ------------------
 1691|  58.5k|                    curB = array2[8 * pos2];
 1692|  58.5k|                } else {
 1693|    751|                    break;
 1694|    751|                }
 1695|  59.2k|            }
 1696|  99.5k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1697|  99.5k|            output += store_unique(laststore, vecMin, output);
 1698|  99.5k|            laststore = vecMin;
 1699|  99.5k|        }
 1700|  3.03k|        sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1701|  3.03k|        output += store_unique(laststore, vecMin, output);
 1702|  3.03k|        laststore = vecMin;
 1703|  3.03k|    }
 1704|       |    // we finish the rest off using a scalar algorithm
 1705|       |    // could be improved?
 1706|       |    //
 1707|       |    // copy the small end on a tmp buffer
 1708|  3.53k|    uint32_t len = (uint32_t)(output - initoutput);
 1709|  3.53k|    uint16_t buffer[16];
 1710|  3.53k|    uint32_t leftoversize = store_unique(laststore, vecMax, buffer);
 1711|  3.53k|    if (pos1 == len1) {
  ------------------
  |  Branch (1711:9): [True: 2.78k, False: 751]
  ------------------
 1712|  2.78k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1713|  2.78k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1714|  2.78k|        leftoversize += length1 - 8 * len1;
 1715|  2.78k|        qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1716|       |
 1717|  2.78k|        leftoversize = unique(buffer, leftoversize);
 1718|  2.78k|        len += (uint32_t)union_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1719|  2.78k|                                      length2 - 8 * pos2, output);
 1720|  2.78k|    } else {
 1721|    751|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1722|    751|               (length2 - 8 * len2) * sizeof(uint16_t));
 1723|    751|        leftoversize += length2 - 8 * len2;
 1724|    751|        qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1725|    751|        leftoversize = unique(buffer, leftoversize);
 1726|    751|        len += (uint32_t)union_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1727|    751|                                      length1 - 8 * pos1, output);
 1728|    751|    }
 1729|  3.53k|    return len;
 1730|  4.52k|}
xor_vector16:
 1778|  7.70k|                      uint16_t *output) {
 1779|  7.70k|    if ((length1 < 8) || (length2 < 8)) {
  ------------------
  |  Branch (1779:9): [True: 3.10k, False: 4.60k]
  |  Branch (1779:26): [True: 348, False: 4.25k]
  ------------------
 1780|  3.45k|        return xor_uint16(array1, length1, array2, length2, output);
 1781|  3.45k|    }
 1782|  4.25k|    __m128i vA, vB, V, vecMin, vecMax;
 1783|  4.25k|    __m128i laststore;
 1784|  4.25k|    uint16_t *initoutput = output;
 1785|  4.25k|    uint32_t len1 = length1 / 8;
 1786|  4.25k|    uint32_t len2 = length2 / 8;
 1787|  4.25k|    uint32_t pos1 = 0;
 1788|  4.25k|    uint32_t pos2 = 0;
 1789|       |    // we start the machine
 1790|  4.25k|    vA = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1791|  4.25k|    pos1++;
 1792|  4.25k|    vB = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1793|  4.25k|    pos2++;
 1794|  4.25k|    sse_merge(&vA, &vB, &vecMin, &vecMax);
 1795|  4.25k|    laststore = _mm_set1_epi16(-1);
 1796|  4.25k|    uint16_t buffer[17];
 1797|  4.25k|    output += store_unique_xor(laststore, vecMin, output);
 1798|       |
 1799|  4.25k|    laststore = vecMin;
 1800|  4.25k|    if ((pos1 < len1) && (pos2 < len2)) {
  ------------------
  |  Branch (1800:9): [True: 3.91k, False: 338]
  |  Branch (1800:26): [True: 3.79k, False: 118]
  ------------------
 1801|  3.79k|        uint16_t curA, curB;
 1802|  3.79k|        curA = array1[8 * pos1];
 1803|  3.79k|        curB = array2[8 * pos2];
 1804|   179k|        while (true) {
  ------------------
  |  Branch (1804:16): [True: 179k, Folded]
  ------------------
 1805|   179k|            if (curA <= curB) {
  ------------------
  |  Branch (1805:17): [True: 85.6k, False: 94.1k]
  ------------------
 1806|  85.6k|                V = _mm_lddqu_si128((const __m128i *)array1 + pos1);
 1807|  85.6k|                pos1++;
 1808|  85.6k|                if (pos1 < len1) {
  ------------------
  |  Branch (1808:21): [True: 83.1k, False: 2.50k]
  ------------------
 1809|  83.1k|                    curA = array1[8 * pos1];
 1810|  83.1k|                } else {
 1811|  2.50k|                    break;
 1812|  2.50k|                }
 1813|  94.1k|            } else {
 1814|  94.1k|                V = _mm_lddqu_si128((const __m128i *)array2 + pos2);
 1815|  94.1k|                pos2++;
 1816|  94.1k|                if (pos2 < len2) {
  ------------------
  |  Branch (1816:21): [True: 92.8k, False: 1.28k]
  ------------------
 1817|  92.8k|                    curB = array2[8 * pos2];
 1818|  92.8k|                } else {
 1819|  1.28k|                    break;
 1820|  1.28k|                }
 1821|  94.1k|            }
 1822|   176k|            sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1823|       |            // conditionally stores the last value of laststore as well as all
 1824|       |            // but the
 1825|       |            // last value of vecMin
 1826|   176k|            output += store_unique_xor(laststore, vecMin, output);
 1827|   176k|            laststore = vecMin;
 1828|   176k|        }
 1829|  3.79k|        sse_merge(&V, &vecMax, &vecMin, &vecMax);
 1830|       |        // conditionally stores the last value of laststore as well as all but
 1831|       |        // the
 1832|       |        // last value of vecMin
 1833|  3.79k|        output += store_unique_xor(laststore, vecMin, output);
 1834|  3.79k|        laststore = vecMin;
 1835|  3.79k|    }
 1836|  4.25k|    uint32_t len = (uint32_t)(output - initoutput);
 1837|       |
 1838|       |    // we finish the rest off using a scalar algorithm
 1839|       |    // could be improved?
 1840|       |    // conditionally stores the last value of laststore as well as all but the
 1841|       |    // last value of vecMax,
 1842|       |    // we store to "buffer"
 1843|  4.25k|    int leftoversize = store_unique_xor(laststore, vecMax, buffer);
 1844|  4.25k|    uint16_t vec7 = (uint16_t)_mm_extract_epi16(vecMax, 7);
 1845|  4.25k|    uint16_t vec6 = (uint16_t)_mm_extract_epi16(vecMax, 6);
 1846|  4.25k|    if (vec7 != vec6) buffer[leftoversize++] = vec7;
  ------------------
  |  Branch (1846:9): [True: 4.20k, False: 49]
  ------------------
 1847|  4.25k|    if (pos1 == len1) {
  ------------------
  |  Branch (1847:9): [True: 2.84k, False: 1.40k]
  ------------------
 1848|  2.84k|        memcpy(buffer + leftoversize, array1 + 8 * pos1,
 1849|  2.84k|               (length1 - 8 * len1) * sizeof(uint16_t));
 1850|  2.84k|        leftoversize += length1 - 8 * len1;
 1851|  2.84k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (1851:13): [True: 7, False: 2.84k]
  ------------------
 1852|      7|            memcpy(output, array2 + 8 * pos2,
 1853|      7|                   (length2 - 8 * pos2) * sizeof(uint16_t));
 1854|      7|            len += (length2 - 8 * pos2);
 1855|  2.84k|        } else {
 1856|  2.84k|            qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1857|  2.84k|            leftoversize = unique_xor(buffer, leftoversize);
 1858|  2.84k|            len += xor_uint16(buffer, leftoversize, array2 + 8 * pos2,
 1859|  2.84k|                              length2 - 8 * pos2, output);
 1860|  2.84k|        }
 1861|  2.84k|    } else {
 1862|  1.40k|        memcpy(buffer + leftoversize, array2 + 8 * pos2,
 1863|  1.40k|               (length2 - 8 * len2) * sizeof(uint16_t));
 1864|  1.40k|        leftoversize += length2 - 8 * len2;
 1865|  1.40k|        if (leftoversize == 0) {  // trivial case
  ------------------
  |  Branch (1865:13): [True: 2, False: 1.40k]
  ------------------
 1866|      2|            memcpy(output, array1 + 8 * pos1,
 1867|      2|                   (length1 - 8 * pos1) * sizeof(uint16_t));
 1868|      2|            len += (length1 - 8 * pos1);
 1869|  1.40k|        } else {
 1870|  1.40k|            qsort(buffer, leftoversize, sizeof(uint16_t), uint16_compare);
 1871|  1.40k|            leftoversize = unique_xor(buffer, leftoversize);
 1872|  1.40k|            len += xor_uint16(buffer, leftoversize, array1 + 8 * pos1,
 1873|  1.40k|                              length1 - 8 * pos1, output);
 1874|  1.40k|        }
 1875|  1.40k|    }
 1876|  4.25k|    return len;
 1877|  7.70k|}
fast_union_uint16:
 1980|  4.52k|                         uint16_t *buffer) {
 1981|  4.52k|#if CROARING_IS_X64
 1982|  4.52k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1982:9): [True: 4.52k, False: 0]
  ------------------
 1983|       |        // compute union with smallest array first
 1984|  4.52k|        if (size_1 < size_2) {
  ------------------
  |  Branch (1984:13): [True: 2.28k, False: 2.24k]
  ------------------
 1985|  2.28k|            return union_vector16(set_1, (uint32_t)size_1, set_2,
 1986|  2.28k|                                  (uint32_t)size_2, buffer);
 1987|  2.28k|        } else {
 1988|  2.24k|            return union_vector16(set_2, (uint32_t)size_2, set_1,
 1989|  2.24k|                                  (uint32_t)size_1, buffer);
 1990|  2.24k|        }
 1991|  4.52k|    } else {
 1992|       |        // compute union with smallest array first
 1993|      0|        if (size_1 < size_2) {
  ------------------
  |  Branch (1993:13): [True: 0, False: 0]
  ------------------
 1994|      0|            return union_uint16(set_1, size_1, set_2, size_2, buffer);
 1995|      0|        } else {
 1996|      0|            return union_uint16(set_2, size_2, set_1, size_1, buffer);
 1997|      0|        }
 1998|      0|    }
 1999|       |#else
 2000|       |    // compute union with smallest array first
 2001|       |    if (size_1 < size_2) {
 2002|       |        return union_uint16(set_1, size_1, set_2, size_2, buffer);
 2003|       |    } else {
 2004|       |        return union_uint16(set_2, size_2, set_1, size_1, buffer);
 2005|       |    }
 2006|       |#endif
 2007|  4.52k|}
memequals:
 2111|  7.09k|bool memequals(const void *s1, const void *s2, size_t n) {
 2112|  7.09k|    if (n == 0) {
  ------------------
  |  Branch (2112:9): [True: 0, False: 7.09k]
  ------------------
 2113|      0|        return true;
 2114|      0|    }
 2115|  7.09k|#if CROARING_IS_X64
 2116|  7.09k|    int support = croaring_hardware_support();
 2117|  7.09k|#if CROARING_COMPILER_SUPPORTS_AVX512
 2118|  7.09k|    if (support & ROARING_SUPPORTS_AVX512) {
  ------------------
  |  Branch (2118:9): [True: 0, False: 7.09k]
  ------------------
 2119|      0|        return _avx512_memequals(s1, s2, n);
 2120|      0|    } else
 2121|  7.09k|#endif  // CROARING_COMPILER_SUPPORTS_AVX512
 2122|  7.09k|        if (support & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (2122:13): [True: 7.09k, False: 0]
  ------------------
 2123|  7.09k|            return _avx2_memequals(s1, s2, n);
 2124|  7.09k|        } else {
 2125|      0|            return memcmp(s1, s2, n) == 0;
 2126|      0|        }
 2127|       |#else
 2128|       |    return memcmp(s1, s2, n) == 0;
 2129|       |#endif
 2130|  7.09k|}
array_util.c:binarySearch4:
  804|  1.21k|                          int32_t *index4) {
  805|  1.21k|    const uint16_t *base1 = array;
  806|  1.21k|    const uint16_t *base2 = array;
  807|  1.21k|    const uint16_t *base3 = array;
  808|  1.21k|    const uint16_t *base4 = array;
  809|  1.21k|    if (n == 0) return;
  ------------------
  |  Branch (809:9): [True: 0, False: 1.21k]
  ------------------
  810|  15.1k|    while (n > 1) {
  ------------------
  |  Branch (810:12): [True: 13.9k, False: 1.21k]
  ------------------
  811|  13.9k|        int32_t half = n >> 1;
  812|  13.9k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (812:17): [True: 1.04k, False: 12.8k]
  ------------------
  813|  13.9k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (813:17): [True: 1.94k, False: 11.9k]
  ------------------
  814|  13.9k|        base3 = (base3[half] < target3) ? &base3[half] : base3;
  ------------------
  |  Branch (814:17): [True: 2.52k, False: 11.3k]
  ------------------
  815|  13.9k|        base4 = (base4[half] < target4) ? &base4[half] : base4;
  ------------------
  |  Branch (815:17): [True: 2.96k, False: 10.9k]
  ------------------
  816|  13.9k|        n -= half;
  817|  13.9k|    }
  818|  1.21k|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  819|  1.21k|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  820|  1.21k|    *index3 = (int32_t)((*base3 < target3) + base3 - array);
  821|  1.21k|    *index4 = (int32_t)((*base4 < target4) + base4 - array);
  822|  1.21k|}
array_util.c:binarySearch2:
  833|    368|                          uint16_t target2, int32_t *index1, int32_t *index2) {
  834|    368|    const uint16_t *base1 = array;
  835|    368|    const uint16_t *base2 = array;
  836|    368|    if (n == 0) return;
  ------------------
  |  Branch (836:9): [True: 0, False: 368]
  ------------------
  837|  3.50k|    while (n > 1) {
  ------------------
  |  Branch (837:12): [True: 3.14k, False: 368]
  ------------------
  838|  3.14k|        int32_t half = n >> 1;
  839|  3.14k|        base1 = (base1[half] < target1) ? &base1[half] : base1;
  ------------------
  |  Branch (839:17): [True: 781, False: 2.36k]
  ------------------
  840|  3.14k|        base2 = (base2[half] < target2) ? &base2[half] : base2;
  ------------------
  |  Branch (840:17): [True: 1.30k, False: 1.83k]
  ------------------
  841|  3.14k|        n -= half;
  842|  3.14k|    }
  843|    368|    *index1 = (int32_t)((*base1 < target1) + base1 - array);
  844|    368|    *index2 = (int32_t)((*base2 < target2) + base2 - array);
  845|    368|}
array_util.c:sse_merge:
 1244|   290k|                             __m128i *vecMin, __m128i *vecMax) {  // output
 1245|   290k|    __m128i vecTmp;
 1246|   290k|    vecTmp = _mm_min_epu16(*vInput1, *vInput2);
 1247|   290k|    *vecMax = _mm_max_epu16(*vInput1, *vInput2);
 1248|   290k|    vecTmp = _mm_alignr_epi8(vecTmp, vecTmp, 2);
 1249|   290k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1250|   290k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1251|   290k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1252|   290k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1253|   290k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1254|   290k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1255|   290k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1256|   290k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1257|   290k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1258|   290k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1259|   290k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1260|   290k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1261|   290k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1262|   290k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1263|   290k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1264|   290k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1265|   290k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1266|   290k|    vecTmp = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1267|   290k|    *vecMin = _mm_min_epu16(vecTmp, *vecMax);
 1268|   290k|    *vecMax = _mm_max_epu16(vecTmp, *vecMax);
 1269|       |    *vecMin = _mm_alignr_epi8(*vecMin, *vecMin, 2);
 1270|   290k|}
array_util.c:store_unique:
 1619|   109k|static inline int store_unique(__m128i old, __m128i newval, uint16_t *output) {
 1620|   109k|    __m128i vecTmp = _mm_alignr_epi8(newval, old, 16 - 2);
 1621|       |    // lots of high latency instructions follow (optimize?)
 1622|   109k|    int M = _mm_movemask_epi8(
 1623|   109k|        _mm_packs_epi16(_mm_cmpeq_epi16(vecTmp, newval), _mm_setzero_si128()));
 1624|   109k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1625|   109k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1626|   109k|    __m128i val = _mm_shuffle_epi8(newval, key);
 1627|   109k|    _mm_storeu_si128((__m128i *)output, val);
 1628|   109k|    return numberofnewvalues;
 1629|   109k|}
array_util.c:uint16_compare:
 1645|   124k|static int uint16_compare(const void *a, const void *b) {
 1646|   124k|    return (*(uint16_t *)a - *(uint16_t *)b);
 1647|   124k|}
array_util.c:unique:
 1634|  3.53k|static inline uint32_t unique(uint16_t *out, uint32_t len) {
 1635|  3.53k|    uint32_t pos = 1;
 1636|  36.3k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1636:26): [True: 32.8k, False: 3.53k]
  ------------------
 1637|  32.8k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1637:13): [True: 32.7k, False: 109]
  ------------------
 1638|  32.7k|            out[pos++] = out[i];
 1639|  32.7k|        }
 1640|  32.8k|    }
 1641|  3.53k|    return pos;
 1642|  3.53k|}
array_util.c:store_unique_xor:
 1746|   188k|                                   uint16_t *output) {
 1747|   188k|    __m128i vecTmp1 = _mm_alignr_epi8(newval, old, 16 - 4);
 1748|       |    __m128i vecTmp2 = _mm_alignr_epi8(newval, old, 16 - 2);
 1749|   188k|    __m128i equalleft = _mm_cmpeq_epi16(vecTmp2, vecTmp1);
 1750|   188k|    __m128i equalright = _mm_cmpeq_epi16(vecTmp2, newval);
 1751|   188k|    __m128i equalleftoright = _mm_or_si128(equalleft, equalright);
 1752|   188k|    int M = _mm_movemask_epi8(
 1753|   188k|        _mm_packs_epi16(equalleftoright, _mm_setzero_si128()));
 1754|   188k|    int numberofnewvalues = 8 - _mm_popcnt_u32(M);
 1755|   188k|    __m128i key = _mm_lddqu_si128((const __m128i *)uniqshuf + M);
 1756|   188k|    __m128i val = _mm_shuffle_epi8(vecTmp2, key);
 1757|   188k|    _mm_storeu_si128((__m128i *)output, val);
 1758|   188k|    return numberofnewvalues;
 1759|   188k|}
array_util.c:unique_xor:
 1764|  4.24k|static inline uint32_t unique_xor(uint16_t *out, uint32_t len) {
 1765|  4.24k|    uint32_t pos = 1;
 1766|  42.0k|    for (uint32_t i = 1; i < len; ++i) {
  ------------------
  |  Branch (1766:26): [True: 37.7k, False: 4.24k]
  ------------------
 1767|  37.7k|        if (out[i] != out[i - 1]) {
  ------------------
  |  Branch (1767:13): [True: 37.5k, False: 223]
  ------------------
 1768|  37.5k|            out[pos++] = out[i];
 1769|  37.5k|        } else
 1770|    223|            pos--;  // if it is identical to previous, delete it
 1771|  37.7k|    }
 1772|  4.24k|    return pos;
 1773|  4.24k|}
array_util.c:_avx2_memequals:
 2069|  7.09k|static inline bool _avx2_memequals(const void *s1, const void *s2, size_t n) {
 2070|  7.09k|    const uint8_t *ptr1 = (const uint8_t *)s1;
 2071|  7.09k|    const uint8_t *ptr2 = (const uint8_t *)s2;
 2072|  7.09k|    const uint8_t *end1 = ptr1 + n;
 2073|  7.09k|    const uint8_t *end8 = ptr1 + n / 8 * 8;
 2074|  7.09k|    const uint8_t *end32 = ptr1 + n / 32 * 32;
 2075|       |
 2076|   132k|    while (ptr1 < end32) {
  ------------------
  |  Branch (2076:12): [True: 125k, False: 7.03k]
  ------------------
 2077|   125k|        __m256i r1 = _mm256_loadu_si256((const __m256i *)ptr1);
 2078|   125k|        __m256i r2 = _mm256_loadu_si256((const __m256i *)ptr2);
 2079|   125k|        int mask = _mm256_movemask_epi8(_mm256_cmpeq_epi8(r1, r2));
 2080|   125k|        if ((uint32_t)mask != UINT32_MAX) {
  ------------------
  |  Branch (2080:13): [True: 62, False: 125k]
  ------------------
 2081|     62|            return false;
 2082|     62|        }
 2083|   125k|        ptr1 += 32;
 2084|   125k|        ptr2 += 32;
 2085|   125k|    }
 2086|       |
 2087|  12.6k|    while (ptr1 < end8) {
  ------------------
  |  Branch (2087:12): [True: 5.66k, False: 6.94k]
  ------------------
 2088|  5.66k|        uint64_t v1, v2;
 2089|  5.66k|        memcpy(&v1, ptr1, sizeof(uint64_t));
 2090|  5.66k|        memcpy(&v2, ptr2, sizeof(uint64_t));
 2091|  5.66k|        if (v1 != v2) {
  ------------------
  |  Branch (2091:13): [True: 88, False: 5.58k]
  ------------------
 2092|     88|            return false;
 2093|     88|        }
 2094|  5.58k|        ptr1 += 8;
 2095|  5.58k|        ptr2 += 8;
 2096|  5.58k|    }
 2097|       |
 2098|  25.1k|    while (ptr1 < end1) {
  ------------------
  |  Branch (2098:12): [True: 18.2k, False: 6.91k]
  ------------------
 2099|  18.2k|        if (*ptr1 != *ptr2) {
  ------------------
  |  Branch (2099:13): [True: 34, False: 18.2k]
  ------------------
 2100|     34|            return false;
 2101|     34|        }
 2102|  18.2k|        ptr1++;
 2103|  18.2k|        ptr2++;
 2104|  18.2k|    }
 2105|       |
 2106|  6.91k|    return true;
 2107|  6.94k|}

bitset_extract_setbits_avx2:
  685|    932|                                   uint32_t base) {
  686|    932|    uint32_t *initout = out;
  687|    932|    __m256i baseVec = _mm256_set1_epi32(base - 1);
  688|    932|    __m256i incVec = _mm256_set1_epi32(64);
  689|    932|    __m256i add8 = _mm256_set1_epi32(8);
  690|    932|    uint32_t *safeout = out + outcapacity;
  691|    932|    size_t i = 0;
  692|   777k|    for (; (i < length) && (out + 64 <= safeout); ++i) {
  ------------------
  |  Branch (692:12): [True: 777k, False: 267]
  |  Branch (692:28): [True: 776k, False: 665]
  ------------------
  693|   776k|        uint64_t w = words[i];
  694|   776k|        if (w == 0) {
  ------------------
  |  Branch (694:13): [True: 111k, False: 664k]
  ------------------
  695|   111k|            baseVec = _mm256_add_epi32(baseVec, incVec);
  696|   664k|        } else {
  697|  3.32M|            for (int k = 0; k < 4; ++k) {
  ------------------
  |  Branch (697:29): [True: 2.65M, False: 664k]
  ------------------
  698|  2.65M|                uint8_t byteA = (uint8_t)w;
  699|  2.65M|                uint8_t byteB = (uint8_t)(w >> 8);
  700|  2.65M|                w >>= 16;
  701|  2.65M|                __m256i vecA =
  702|  2.65M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteA]);
  703|  2.65M|                __m256i vecB =
  704|  2.65M|                    _mm256_loadu_si256((const __m256i *)vecDecodeTable[byteB]);
  705|  2.65M|                uint8_t advanceA = lengthTable[byteA];
  706|  2.65M|                uint8_t advanceB = lengthTable[byteB];
  707|  2.65M|                vecA = _mm256_add_epi32(baseVec, vecA);
  708|  2.65M|                baseVec = _mm256_add_epi32(baseVec, add8);
  709|  2.65M|                vecB = _mm256_add_epi32(baseVec, vecB);
  710|  2.65M|                baseVec = _mm256_add_epi32(baseVec, add8);
  711|  2.65M|                _mm256_storeu_si256((__m256i *)out, vecA);
  712|  2.65M|                out += advanceA;
  713|  2.65M|                _mm256_storeu_si256((__m256i *)out, vecB);
  714|  2.65M|                out += advanceB;
  715|  2.65M|            }
  716|   664k|        }
  717|   776k|    }
  718|    932|    base += i * 64;
  719|  13.6k|    for (; (i < length) && (out < safeout); ++i) {
  ------------------
  |  Branch (719:12): [True: 13.2k, False: 364]
  |  Branch (719:28): [True: 12.7k, False: 568]
  ------------------
  720|  12.7k|        uint64_t w = words[i];
  721|  31.6k|        while ((w != 0) && (out < safeout)) {
  ------------------
  |  Branch (721:16): [True: 18.9k, False: 12.7k]
  |  Branch (721:28): [True: 18.9k, False: 0]
  ------------------
  722|  18.9k|            int r =
  723|  18.9k|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  724|  18.9k|            uint32_t val = r + base;
  725|  18.9k|            memcpy(out, &val,
  726|  18.9k|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  727|  18.9k|            out++;
  728|  18.9k|            w &= (w - 1);
  729|  18.9k|        }
  730|  12.7k|        base += 64;
  731|  12.7k|    }
  732|    932|    return out - initout;
  733|    932|}
bitset_extract_setbits:
  738|    465|                              uint32_t *out, uint32_t base) {
  739|    465|    int outpos = 0;
  740|   476k|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (740:24): [True: 476k, False: 465]
  ------------------
  741|   476k|        uint64_t w = words[i];
  742|  2.78M|        while (w != 0) {
  ------------------
  |  Branch (742:16): [True: 2.30M, False: 476k]
  ------------------
  743|  2.30M|            int r =
  744|  2.30M|                roaring_trailing_zeroes(w);  // on x64, should compile to TZCNT
  745|  2.30M|            uint32_t val = r + base;
  746|  2.30M|            memcpy(out + outpos, &val,
  747|  2.30M|                   sizeof(uint32_t));  // should be compiled as a MOV on x64
  748|  2.30M|            outpos++;
  749|  2.30M|            w &= (w - 1);
  750|  2.30M|        }
  751|   476k|        base += 64;
  752|   476k|    }
  753|    465|    return outpos;
  754|    465|}
bitset_extract_setbits_uint16:
  848|  2.66k|                                     uint16_t *out, uint16_t base) {
  849|  2.66k|    int outpos = 0;
  850|  2.72M|    for (size_t i = 0; i < length; ++i) {
  ------------------
  |  Branch (850:24): [True: 2.72M, False: 2.66k]
  ------------------
  851|  2.72M|        uint64_t w = words[i];
  852|  5.17M|        while (w != 0) {
  ------------------
  |  Branch (852:16): [True: 2.45M, False: 2.72M]
  ------------------
  853|  2.45M|            int r = roaring_trailing_zeroes(w);
  854|  2.45M|            out[outpos++] = (uint16_t)(r + base);
  855|  2.45M|            w &= (w - 1);
  856|  2.45M|        }
  857|  2.72M|        base += 64;
  858|  2.72M|    }
  859|  2.66k|    return outpos;
  860|  2.66k|}
bitset_clear_list:
 1028|  1.54k|                           uint64_t length) {
 1029|  1.54k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1029:9): [True: 1.54k, False: 0]
  ------------------
 1030|  1.54k|        return _asm_bitset_clear_list(words, card, list, length);
 1031|  1.54k|    } else {
 1032|      0|        return _scalar_bitset_clear_list(words, card, list, length);
 1033|      0|    }
 1034|  1.54k|}
bitset_set_list_withcard:
 1037|  1.35k|                                  const uint16_t *list, uint64_t length) {
 1038|  1.35k|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1038:9): [True: 1.35k, False: 0]
  ------------------
 1039|  1.35k|        return _asm_bitset_set_list_withcard(words, card, list, length);
 1040|  1.35k|    } else {
 1041|      0|        return _scalar_bitset_set_list_withcard(words, card, list, length);
 1042|      0|    }
 1043|  1.35k|}
bitset_set_list:
 1045|    195|void bitset_set_list(uint64_t *words, const uint16_t *list, uint64_t length) {
 1046|    195|    if (croaring_hardware_support() & ROARING_SUPPORTS_AVX2) {
  ------------------
  |  Branch (1046:9): [True: 195, False: 0]
  ------------------
 1047|    195|        _asm_bitset_set_list(words, list, length);
 1048|    195|    } else {
 1049|      0|        _scalar_bitset_set_list(words, list, length);
 1050|      0|    }
 1051|    195|}
bitset_flip_list_withcard:
 1107|  1.34k|                                   const uint16_t *list, uint64_t length) {
 1108|  1.34k|    uint64_t offset, load, newload, pos, index;
 1109|  1.34k|    const uint16_t *end = list + length;
 1110|  2.33M|    while (list != end) {
  ------------------
  |  Branch (1110:12): [True: 2.33M, False: 1.34k]
  ------------------
 1111|  2.33M|        pos = *list;
 1112|  2.33M|        offset = pos >> 6;
 1113|  2.33M|        index = pos % 64;
 1114|  2.33M|        load = words[offset];
 1115|  2.33M|        newload = load ^ (UINT64_C(1) << index);
 1116|       |        // todo: is a branch here all that bad?
 1117|  2.33M|        card +=
 1118|       |            (1 - 2 * (((UINT64_C(1) << index) & load) >> index));  // +1 or -1
 1119|  2.33M|        words[offset] = newload;
 1120|  2.33M|        list++;
 1121|  2.33M|    }
 1122|  1.34k|    return card;
 1123|  1.34k|}
bitset_util.c:_asm_bitset_clear_list:
  949|  1.54k|                                              uint64_t length) {
  950|  1.54k|    uint64_t offset, load, pos;
  951|  1.54k|    uint64_t shift = 6;
  952|  1.54k|    const uint16_t *end = list + length;
  953|  1.54k|    if (!length) return card;
  ------------------
  |  Branch (953:9): [True: 0, False: 1.54k]
  ------------------
  954|       |    // btr is not available as an intrinsic in GCC
  955|  1.54k|    __asm volatile(
  956|  1.54k|        "1:\n"
  957|  1.54k|        "movzwq (%[list]), %[pos]\n"
  958|  1.54k|        "shrx %[shift], %[pos], %[offset]\n"
  959|  1.54k|        "mov (%[words],%[offset],8), %[load]\n"
  960|  1.54k|        "btr %[pos], %[load]\n"
  961|  1.54k|        "mov %[load], (%[words],%[offset],8)\n"
  962|  1.54k|        "sbb $0, %[card]\n"
  963|  1.54k|        "add $2, %[list]\n"
  964|  1.54k|        "cmp %[list], %[end]\n"
  965|  1.54k|        "jnz 1b"
  966|  1.54k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
  967|  1.54k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
  968|  1.54k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift)
  969|  1.54k|        :
  970|  1.54k|        /* clobbers */ "memory");
  971|  1.54k|    return card;
  972|  1.54k|}
bitset_util.c:_asm_bitset_set_list_withcard:
  867|  1.35k|                                                     uint64_t length) {
  868|  1.35k|    uint64_t offset, load, pos;
  869|  1.35k|    uint64_t shift = 6;
  870|  1.35k|    const uint16_t *end = list + length;
  871|  1.35k|    if (!length) return card;
  ------------------
  |  Branch (871:9): [True: 0, False: 1.35k]
  ------------------
  872|       |    // TODO: could unroll for performance, see bitset_set_list
  873|       |    // bts is not available as an intrinsic in GCC
  874|  1.35k|    __asm volatile(
  875|  1.35k|        "1:\n"
  876|  1.35k|        "movzwq (%[list]), %[pos]\n"
  877|  1.35k|        "shrx %[shift], %[pos], %[offset]\n"
  878|  1.35k|        "mov (%[words],%[offset],8), %[load]\n"
  879|  1.35k|        "bts %[pos], %[load]\n"
  880|  1.35k|        "mov %[load], (%[words],%[offset],8)\n"
  881|  1.35k|        "sbb $-1, %[card]\n"
  882|  1.35k|        "add $2, %[list]\n"
  883|  1.35k|        "cmp %[list], %[end]\n"
  884|  1.35k|        "jnz 1b"
  885|  1.35k|        : [card] "+&r"(card), [list] "+&r"(list), [load] "=&r"(load),
  886|  1.35k|          [pos] "=&r"(pos), [offset] "=&r"(offset)
  887|  1.35k|        : [end] "r"(end), [words] "r"(words), [shift] "r"(shift));
  888|  1.35k|    return card;
  889|  1.35k|}
bitset_util.c:_asm_bitset_set_list:
  892|    195|                                        uint64_t length) {
  893|    195|    uint64_t pos;
  894|    195|    const uint16_t *end = list + length;
  895|       |
  896|    195|    uint64_t shift = 6;
  897|    195|    uint64_t offset;
  898|    195|    uint64_t load;
  899|  5.58k|    for (; list + 3 < end; list += 4) {
  ------------------
  |  Branch (899:12): [True: 5.38k, False: 195]
  ------------------
  900|  5.38k|        pos = list[0];
  901|  5.38k|        __asm volatile(
  902|  5.38k|            "shrx %[shift], %[pos], %[offset]\n"
  903|  5.38k|            "mov (%[words],%[offset],8), %[load]\n"
  904|  5.38k|            "bts %[pos], %[load]\n"
  905|  5.38k|            "mov %[load], (%[words],%[offset],8)"
  906|  5.38k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  907|  5.38k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  908|  5.38k|        pos = list[1];
  909|  5.38k|        __asm volatile(
  910|  5.38k|            "shrx %[shift], %[pos], %[offset]\n"
  911|  5.38k|            "mov (%[words],%[offset],8), %[load]\n"
  912|  5.38k|            "bts %[pos], %[load]\n"
  913|  5.38k|            "mov %[load], (%[words],%[offset],8)"
  914|  5.38k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  915|  5.38k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  916|  5.38k|        pos = list[2];
  917|  5.38k|        __asm volatile(
  918|  5.38k|            "shrx %[shift], %[pos], %[offset]\n"
  919|  5.38k|            "mov (%[words],%[offset],8), %[load]\n"
  920|  5.38k|            "bts %[pos], %[load]\n"
  921|  5.38k|            "mov %[load], (%[words],%[offset],8)"
  922|  5.38k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  923|  5.38k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  924|  5.38k|        pos = list[3];
  925|  5.38k|        __asm volatile(
  926|  5.38k|            "shrx %[shift], %[pos], %[offset]\n"
  927|  5.38k|            "mov (%[words],%[offset],8), %[load]\n"
  928|  5.38k|            "bts %[pos], %[load]\n"
  929|  5.38k|            "mov %[load], (%[words],%[offset],8)"
  930|  5.38k|            : [load] "=&r"(load), [offset] "=&r"(offset)
  931|  5.38k|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  932|  5.38k|    }
  933|       |
  934|    493|    while (list != end) {
  ------------------
  |  Branch (934:12): [True: 298, False: 195]
  ------------------
  935|    298|        pos = list[0];
  936|    298|        __asm volatile(
  937|    298|            "shrx %[shift], %[pos], %[offset]\n"
  938|    298|            "mov (%[words],%[offset],8), %[load]\n"
  939|    298|            "bts %[pos], %[load]\n"
  940|    298|            "mov %[load], (%[words],%[offset],8)"
  941|    298|            : [load] "=&r"(load), [offset] "=&r"(offset)
  942|    298|            : [words] "r"(words), [shift] "r"(shift), [pos] "r"(pos));
  943|    298|        list++;
  944|    298|    }
  945|    195|}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

