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

; 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.bitset_container_s = type { i32, ptr }
%struct.run_container_s = type { i32, i32, ptr }
%struct.rle16_s = type { i16, i16 }

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

; Function Attrs: inlinehint nounwind uwtable
declare zeroext i1 @bitset_container_contains(ptr noundef, i16 noundef zeroext) #1

; 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 i32 @run_container_cardinality(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @run_container_is_subset_bitset(ptr noundef %0, ptr noundef %1) #2 {
  %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 i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.bitset_container_s, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp ne i32 %14, -1
  br i1 %15, label %16, label %25

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.bitset_container_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i32 @run_container_cardinality(ptr noundef %20)
  %22 = icmp slt i32 %19, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %16
  store i1 false, ptr %3, align 1
  br label %94

24:                                               ; preds = %16
  br label %37

25:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = call i32 @bitset_container_compute_cardinality(ptr noundef %26)
  store i32 %27, ptr %6, align 4, !tbaa !12
  %28 = load i32, ptr %6, align 4, !tbaa !12
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = call i32 @run_container_cardinality(ptr noundef %29)
  %31 = icmp slt i32 %28, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %25
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %34

33:                                               ; preds = %25
  store i32 0, ptr %7, align 4
  br label %34

34:                                               ; preds = %33, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %35 = load i32, ptr %7, align 4
  switch i32 %35, label %96 [
    i32 0, label %36
    i32 1, label %94
  ]

36:                                               ; preds = %34
  br label %37

37:                                               ; preds = %36, %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !12
  br label %38

38:                                               ; preds = %88, %37
  %39 = load i32, ptr %8, align 4, !tbaa !12
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.run_container_s, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !13
  %43 = icmp slt i32 %39, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  store i32 2, ptr %7, align 4
  br label %91

45:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.run_container_s, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = load i32, ptr %8, align 4, !tbaa !12
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct.rle16_s, ptr %48, i64 %50
  %52 = getelementptr inbounds %struct.rle16_s, ptr %51, i32 0, i32 0
  %53 = load i16, ptr %52, align 2, !tbaa !16
  %54 = zext i16 %53 to i32
  store i32 %54, ptr %9, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.run_container_s, ptr %55, i32 0, i32 2
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = load i32, ptr %8, align 4, !tbaa !12
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %struct.rle16_s, ptr %57, i64 %59
  %61 = getelementptr inbounds %struct.rle16_s, ptr %60, i32 0, i32 1
  %62 = load i16, ptr %61, align 2, !tbaa !19
  %63 = zext i16 %62 to i32
  store i32 %63, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %64 = load i32, ptr %9, align 4, !tbaa !12
  store i32 %64, ptr %11, align 4, !tbaa !12
  br label %65

65:                                               ; preds = %79, %45
  %66 = load i32, ptr %11, align 4, !tbaa !12
  %67 = load i32, ptr %9, align 4, !tbaa !12
  %68 = load i32, ptr %10, align 4, !tbaa !12
  %69 = add i32 %67, %68
  %70 = icmp ule i32 %66, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %65
  store i32 5, ptr %7, align 4
  br label %82

72:                                               ; preds = %65
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = load i32, ptr %11, align 4, !tbaa !12
  %75 = trunc i32 %74 to i16
  %76 = call zeroext i1 @bitset_container_contains(ptr noundef %73, i16 noundef zeroext %75)
  br i1 %76, label %78, label %77

77:                                               ; preds = %72
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %82

78:                                               ; preds = %72
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %11, align 4, !tbaa !12
  %81 = add i32 %80, 1
  store i32 %81, ptr %11, align 4, !tbaa !12
  br label %65, !llvm.loop !20

82:                                               ; preds = %77, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %83 = load i32, ptr %7, align 4
  switch i32 %83, label %85 [
    i32 5, label %84
  ]

84:                                               ; preds = %82
  store i32 0, ptr %7, align 4
  br label %85

85:                                               ; preds = %84, %82
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %86 = load i32, ptr %7, align 4
  switch i32 %86, label %91 [
    i32 0, label %87
  ]

87:                                               ; preds = %85
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %8, align 4, !tbaa !12
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %8, align 4, !tbaa !12
  br label %38, !llvm.loop !22

91:                                               ; preds = %85, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %92 = load i32, ptr %7, align 4
  switch i32 %92, label %96 [
    i32 2, label %93
    i32 1, label %94
  ]

93:                                               ; preds = %91
  store i1 true, ptr %3, align 1
  br label %94

94:                                               ; preds = %93, %91, %34, %23
  %95 = load i1, ptr %3, align 1
  ret i1 %95

96:                                               ; preds = %91, %34
  unreachable
}

declare i32 @bitset_container_compute_cardinality(ptr noundef) #3

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 = { 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 #3 = { "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, !11, i64 0}
!10 = !{!"bitset_container_s", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !11, i64 0}
!14 = !{!"run_container_s", !11, i64 0, !11, i64 4, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!17, !18, i64 0}
!17 = !{!"rle16_s", !18, i64 0, !18, i64 2}
!18 = !{!"short", !7, i64 0}
!19 = !{!17, !18, i64 2}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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 zeroext i1 @bitset_container_contains(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @run_container_cardinality(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @run_container_is_subset_bitset(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %3, -1
  br i1 %.not, label %7, label %4

4:                                                ; preds = %2
  %5 = tail call i32 @run_container_cardinality(ptr noundef %0)
  %6 = icmp slt i32 %3, %5
  br i1 %6, label %.loopexit, label %10

7:                                                ; preds = %2
  %8 = tail call i32 @bitset_container_compute_cardinality(ptr noundef nonnull %1) #3
  %9 = tail call i32 @run_container_cardinality(ptr noundef %0)
  %.not34 = icmp slt i32 %8, %9
  br i1 %.not34, label %.loopexit, label %10

10:                                               ; preds = %7, %4
  %11 = load i32, ptr %0, align 8, !tbaa !11
  %12 = icmp slt i32 %11, 1
  br i1 %12, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  br label %14

14:                                               ; preds = %.lr.ph, %28
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %28 ]
  %15 = load ptr, ptr %13, align 8, !tbaa !13
  %16 = getelementptr inbounds %struct.rle16_s, ptr %15, i64 %indvars.iv
  %17 = load i16, ptr %16, align 2, !tbaa !14
  %18 = zext i16 %17 to i32
  %19 = getelementptr inbounds i8, ptr %16, i64 2
  %20 = load i16, ptr %19, align 2, !tbaa !17
  %21 = zext i16 %20 to i32
  %22 = add nuw nsw i32 %21, %18
  br label %25

23:                                               ; preds = %25
  %24 = add nuw nsw i32 %.037, 1
  %exitcond.not = icmp eq i32 %.037, %22
  br i1 %exitcond.not, label %28, label %25, !llvm.loop !18

25:                                               ; preds = %14, %23
  %.037 = phi i32 [ %18, %14 ], [ %24, %23 ]
  %26 = trunc i32 %.037 to i16
  %27 = tail call zeroext i1 @bitset_container_contains(ptr noundef nonnull %1, i16 noundef zeroext %26)
  br i1 %27, label %23, label %.loopexit

28:                                               ; preds = %23
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr %0, align 8, !tbaa !11
  %30 = sext i32 %29 to i64
  %.not41 = icmp slt i64 %indvars.iv.next, %30
  br i1 %.not41, label %14, label %.loopexit, !llvm.loop !20

.loopexit:                                        ; preds = %28, %25, %10, %7, %4
  %.5 = phi i1 [ false, %7 ], [ false, %4 ], [ true, %10 ], [ false, %25 ], [ true, %28 ]
  ret i1 %.5
}

declare i32 @bitset_container_compute_cardinality(ptr noundef) local_unnamed_addr #2

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" }
attributes #2 = { "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 #3 = { 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, !7, i64 0}
!6 = !{!"bitset_container_s", !7, i64 0, !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 = !{!12, !7, i64 0}
!12 = !{!"run_container_s", !7, i64 0, !7, i64 4, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!15, !16, i64 0}
!15 = !{!"rle16_s", !16, i64 0, !16, i64 2}
!16 = !{!"short", !8, i64 0}
!17 = !{!15, !16, i64 2}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass