; 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.array_container_s = type { i32, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @run_container_is_subset_array(ptr noundef %0, ptr noundef %1) #1 {
  %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 %4, align 8, !tbaa !5
  %13 = call i32 @run_container_cardinality(ptr noundef %12)
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.array_container_s, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp sgt i32 %13, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %117

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 -1, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 -1, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !12
  br label %20

20:                                               ; preds = %110, %19
  %21 = load i32, ptr %8, align 4, !tbaa !12
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.run_container_s, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !13
  %25 = icmp slt i32 %21, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %20
  store i32 2, ptr %9, align 4
  br label %113

27:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.run_container_s, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = load i32, ptr %8, align 4, !tbaa !12
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.rle16_s, ptr %30, i64 %32
  %34 = getelementptr inbounds %struct.rle16_s, ptr %33, i32 0, i32 0
  %35 = load i16, ptr %34, align 2, !tbaa !16
  %36 = zext i16 %35 to i32
  store i32 %36, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %37 = load i32, ptr %10, align 4, !tbaa !12
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.run_container_s, ptr %38, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = load i32, ptr %8, align 4, !tbaa !12
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds %struct.rle16_s, ptr %40, i64 %42
  %44 = getelementptr inbounds %struct.rle16_s, ptr %43, i32 0, i32 1
  %45 = load i16, ptr %44, align 2, !tbaa !19
  %46 = zext i16 %45 to i32
  %47 = add nsw i32 %37, %46
  store i32 %47, ptr %11, align 4, !tbaa !12
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.array_container_s, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !20
  %51 = load i32, ptr %7, align 4, !tbaa !12
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.array_container_s, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !9
  %55 = load i32, ptr %10, align 4, !tbaa !12
  %56 = trunc i32 %55 to i16
  %57 = call i32 @advanceUntil(ptr noundef %50, i32 noundef %51, i32 noundef %54, i16 noundef zeroext %56)
  store i32 %57, ptr %6, align 4, !tbaa !12
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.array_container_s, ptr %58, i32 0, i32 2
  %60 = load ptr, ptr %59, align 8, !tbaa !20
  %61 = load i32, ptr %7, align 4, !tbaa !12
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.array_container_s, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !9
  %65 = load i32, ptr %11, align 4, !tbaa !12
  %66 = trunc i32 %65 to i16
  %67 = call i32 @advanceUntil(ptr noundef %60, i32 noundef %61, i32 noundef %64, i16 noundef zeroext %66)
  store i32 %67, ptr %7, align 4, !tbaa !12
  %68 = load i32, ptr %6, align 4, !tbaa !12
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.array_container_s, ptr %69, i32 0, i32 0
  %71 = load i32, ptr %70, align 8, !tbaa !9
  %72 = icmp eq i32 %68, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %27
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %107

74:                                               ; preds = %27
  %75 = load i32, ptr %7, align 4, !tbaa !12
  %76 = load i32, ptr %6, align 4, !tbaa !12
  %77 = sub nsw i32 %75, %76
  %78 = load i32, ptr %11, align 4, !tbaa !12
  %79 = load i32, ptr %10, align 4, !tbaa !12
  %80 = sub nsw i32 %78, %79
  %81 = icmp ne i32 %77, %80
  br i1 %81, label %104, label %82

82:                                               ; preds = %74
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.array_container_s, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !20
  %86 = load i32, ptr %6, align 4, !tbaa !12
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i16, ptr %85, i64 %87
  %89 = load i16, ptr %88, align 2, !tbaa !21
  %90 = zext i16 %89 to i32
  %91 = load i32, ptr %10, align 4, !tbaa !12
  %92 = icmp ne i32 %90, %91
  br i1 %92, label %104, label %93

93:                                               ; preds = %82
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.array_container_s, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !20
  %97 = load i32, ptr %7, align 4, !tbaa !12
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds i16, ptr %96, i64 %98
  %100 = load i16, ptr %99, align 2, !tbaa !21
  %101 = zext i16 %100 to i32
  %102 = load i32, ptr %11, align 4, !tbaa !12
  %103 = icmp ne i32 %101, %102
  br i1 %103, label %104, label %105

104:                                              ; preds = %93, %82, %74
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %107

105:                                              ; preds = %93
  br label %106

106:                                              ; preds = %105
  store i32 0, ptr %9, align 4
  br label %107

107:                                              ; preds = %106, %104, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %108 = load i32, ptr %9, align 4
  switch i32 %108, label %113 [
    i32 0, label %109
  ]

109:                                              ; preds = %107
  br label %110

110:                                              ; preds = %109
  %111 = load i32, ptr %8, align 4, !tbaa !12
  %112 = add nsw i32 %111, 1
  store i32 %112, ptr %8, align 4, !tbaa !12
  br label %20, !llvm.loop !22

113:                                              ; preds = %107, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %114 = load i32, ptr %9, align 4
  switch i32 %114, label %116 [
    i32 2, label %115
  ]

115:                                              ; preds = %113
  store i1 true, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %116

116:                                              ; preds = %115, %113
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %117

117:                                              ; preds = %116, %18
  %118 = load i1, ptr %3, align 1
  ret i1 %118
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @advanceUntil(ptr noundef, i32 noundef, i32 noundef, i16 noundef zeroext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !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 = !{!"array_container_s", !11, i64 0, !11, i64 4, !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 = !{!10, !6, i64 8}
!21 = !{!18, !18, i64 0}
!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: nounwind uwtable
define dso_local noundef zeroext i1 @run_container_is_subset_array(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call i32 @run_container_cardinality(ptr noundef %0)
  %4 = load i32, ptr %1, align 8, !tbaa !5
  %5 = icmp sgt i32 %3, %4
  br i1 %5, label %.critedge42, label %.preheader

.preheader:                                       ; preds = %2
  %6 = load i32, ptr %0, align 8, !tbaa !11
  %.not40.not43 = icmp sgt i32 %6, 0
  br i1 %.not40.not43, label %.lr.ph, label %.critedge42

.lr.ph:                                           ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %.pre = load ptr, ptr %8, align 8, !tbaa !13
  br label %12

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

12:                                               ; preds = %.lr.ph, %9
  %13 = phi i32 [ %4, %.lr.ph ], [ %28, %9 ]
  %14 = phi ptr [ %.pre, %.lr.ph ], [ %32, %9 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %.03644 = phi i32 [ -1, %.lr.ph ], [ %27, %9 ]
  %15 = load ptr, ptr %7, align 8, !tbaa !16
  %16 = getelementptr inbounds %struct.rle16_s, ptr %15, i64 %indvars.iv
  %17 = load i16, ptr %16, align 2, !tbaa !17
  %18 = zext i16 %17 to i32
  %19 = getelementptr inbounds i8, ptr %16, i64 2
  %20 = load i16, ptr %19, align 2, !tbaa !20
  %21 = zext i16 %20 to i32
  %22 = add nuw nsw i32 %21, %18
  %23 = tail call i32 @advanceUntil(ptr noundef %14, i32 noundef %.03644, i32 noundef %13, i16 noundef zeroext %17)
  %24 = load ptr, ptr %8, align 8, !tbaa !13
  %25 = load i32, ptr %1, align 8, !tbaa !5
  %26 = trunc i32 %22 to i16
  %27 = tail call i32 @advanceUntil(ptr noundef %24, i32 noundef %.03644, i32 noundef %25, i16 noundef zeroext %26)
  %28 = load i32, ptr %1, align 8, !tbaa !5
  %29 = icmp ne i32 %23, %28
  %30 = sub nsw i32 %27, %23
  %.not = icmp eq i32 %30, %21
  %or.cond = select i1 %29, i1 %.not, i1 false
  br i1 %or.cond, label %31, label %.critedge42

31:                                               ; preds = %12
  %32 = load ptr, ptr %8, align 8, !tbaa !13
  %33 = sext i32 %23 to i64
  %34 = getelementptr inbounds i16, ptr %32, i64 %33
  %35 = load i16, ptr %34, align 2, !tbaa !21
  %.not38 = icmp eq i16 %35, %17
  br i1 %.not38, label %.critedge, label %.critedge42

.critedge:                                        ; preds = %31
  %36 = sext i32 %27 to i64
  %37 = getelementptr inbounds i16, ptr %32, i64 %36
  %38 = load i16, ptr %37, align 2, !tbaa !21
  %39 = zext i16 %38 to i32
  %.not39 = icmp eq i32 %22, %39
  br i1 %.not39, label %9, label %.critedge42

.critedge42:                                      ; preds = %12, %.critedge, %31, %9, %.preheader, %2
  %.4 = phi i1 [ false, %2 ], [ true, %.preheader ], [ false, %12 ], [ false, %.critedge ], [ false, %31 ], [ true, %9 ]
  ret i1 %.4
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @advanceUntil(ptr noundef, i32 noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #1

attributes #0 = { 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 = { 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" }

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


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