; LLVM IR from jermp/2i_bench :: external/CRoaring/src/containers (mixed_intersection)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.rle16_s = type { i16, i16 }
%struct.run_container_s = type { i32, i32, ptr }
%struct.bitset_container_s = type { i32, ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @run_container_is_full(ptr noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @run_bitset_container_intersect(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.rle16_s, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call zeroext i1 @run_container_is_full(ptr noundef %9)
  br i1 %10, label %11, label %15

11:                                               ; preds = %2
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call zeroext i1 @bitset_container_empty(ptr noundef %12)
  %14 = xor i1 %13, true
  store i1 %14, ptr %3, align 1
  br label %51

15:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %45, %15
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.run_container_s, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !11
  %21 = icmp slt i32 %17, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  store i32 2, ptr %7, align 4
  br label %48

23:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.run_container_s, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.rle16_s, ptr %26, i64 %28
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %8, ptr align 2 %29, i64 4, i1 false), !tbaa.struct !14
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.bitset_container_s, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds %struct.rle16_s, ptr %8, i32 0, i32 0
  %34 = load i16, ptr %33, align 2, !tbaa !19
  %35 = zext i16 %34 to i32
  %36 = getelementptr inbounds %struct.rle16_s, ptr %8, i32 0, i32 1
  %37 = load i16, ptr %36, align 2, !tbaa !21
  %38 = zext i16 %37 to i32
  %39 = call zeroext i1 @bitset_lenrange_empty(ptr noundef %32, i32 noundef %35, i32 noundef %38)
  br i1 %39, label %41, label %40

40:                                               ; preds = %23
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %42

41:                                               ; preds = %23
  store i32 0, ptr %7, align 4
  br label %42

42:                                               ; preds = %41, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %43 = load i32, ptr %7, align 4
  switch i32 %43, label %48 [
    i32 0, label %44
  ]

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !22

48:                                               ; preds = %42, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %49 = load i32, ptr %7, align 4
  switch i32 %49, label %53 [
    i32 2, label %50
    i32 1, label %51
  ]

50:                                               ; preds = %48
  store i1 false, ptr %3, align 1
  br label %51

51:                                               ; preds = %50, %48, %11
  %52 = load i1, ptr %3, align 1
  ret i1 %52

53:                                               ; preds = %48
  unreachable
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @bitset_container_empty(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @bitset_lenrange_empty(ptr noundef, i32 noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"run_container_s", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{i64 0, i64 2, !15, i64 2, i64 2, !15}
!15 = !{!16, !16, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!18, !6, i64 8}
!18 = !{!"bitset_container_s", !10, i64 0, !6, i64 8}
!19 = !{!20, !16, i64 0}
!20 = !{!"rle16_s", !16, i64 0, !16, i64 2}
!21 = !{!20, !16, i64 2}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.rle16_s = type { i16, i16 }

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @run_container_is_full(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @run_bitset_container_intersect(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = tail call zeroext i1 @run_container_is_full(ptr noundef %0)
  br i1 %3, label %7, label %.preheader

.preheader:                                       ; preds = %2
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %.not13 = icmp sgt i32 %4, 0
  br i1 %.not13, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  br label %13

7:                                                ; preds = %2
  %8 = tail call zeroext i1 @bitset_container_empty(ptr noundef %1)
  %9 = xor i1 %8, true
  br label %.loopexit

10:                                               ; preds = %13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = load i32, ptr %0, align 8, !tbaa !5
  %12 = sext i32 %11 to i64
  %.not = icmp slt i64 %indvars.iv.next, %12
  br i1 %.not, label %13, label %.loopexit.loopexit, !llvm.loop !11

13:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %14 = load ptr, ptr %5, align 8, !tbaa !13
  %15 = getelementptr inbounds %struct.rle16_s, ptr %14, i64 %indvars.iv
  %.sroa.0.0.copyload = load i16, ptr %15, align 2, !tbaa !14
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %15, i64 2
  %.sroa.4.0.copyload = load i16, ptr %.sroa.4.0..sroa_idx, align 2, !tbaa !14
  %16 = load ptr, ptr %6, align 8, !tbaa !16
  %17 = zext i16 %.sroa.0.0.copyload to i32
  %18 = zext i16 %.sroa.4.0.copyload to i32
  %19 = tail call zeroext i1 @bitset_lenrange_empty(ptr noundef %16, i32 noundef %17, i32 noundef %18)
  br i1 %19, label %10, label %.loopexit.loopexit

.loopexit.loopexit:                               ; preds = %13, %10
  %.3.ph = xor i1 %19, true
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %7
  %.3 = phi i1 [ %9, %7 ], [ false, %.preheader ], [ %.3.ph, %.loopexit.loopexit ]
  ret i1 %.3
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @bitset_container_empty(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @bitset_lenrange_empty(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

attributes #0 = { inlinehint nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"run_container_s", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!6, !10, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!17, !10, i64 8}
!17 = !{!"bitset_container_s", !7, i64 0, !10, i64 8}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass