; 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: inlinehint nounwind uwtable
declare hidden i32 @run_container_cardinality(ptr noundef) #1

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

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

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

19:                                               ; preds = %86, %18
  %20 = load i32, ptr %6, align 4, !tbaa !12
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.array_container_s, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !9
  %24 = icmp slt i32 %20, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %19
  %26 = load i32, ptr %7, align 4, !tbaa !12
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.run_container_s, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !13
  %30 = icmp slt i32 %26, %29
  br label %31

31:                                               ; preds = %25, %19
  %32 = phi i1 [ false, %19 ], [ %30, %25 ]
  br i1 %32, label %33, label %87

33:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.run_container_s, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load i32, ptr %7, align 4, !tbaa !12
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.rle16_s, ptr %36, i64 %38
  %40 = getelementptr inbounds %struct.rle16_s, ptr %39, i32 0, i32 0
  %41 = load i16, ptr %40, align 2, !tbaa !16
  %42 = zext i16 %41 to i32
  store i32 %42, ptr %8, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %43 = load i32, ptr %8, align 4, !tbaa !12
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.run_container_s, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = load i32, ptr %7, align 4, !tbaa !12
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds %struct.rle16_s, ptr %46, i64 %48
  %50 = getelementptr inbounds %struct.rle16_s, ptr %49, i32 0, i32 1
  %51 = load i16, ptr %50, align 2, !tbaa !19
  %52 = zext i16 %51 to i32
  %53 = add i32 %43, %52
  store i32 %53, ptr %9, align 4, !tbaa !12
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.array_container_s, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !20
  %57 = load i32, ptr %6, align 4, !tbaa !12
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds i16, ptr %56, i64 %58
  %60 = load i16, ptr %59, align 2, !tbaa !21
  %61 = zext i16 %60 to i32
  %62 = load i32, ptr %8, align 4, !tbaa !12
  %63 = icmp ult i32 %61, %62
  br i1 %63, label %64, label %65

64:                                               ; preds = %33
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %84

65:                                               ; preds = %33
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.array_container_s, ptr %66, i32 0, i32 2
  %68 = load ptr, ptr %67, align 8, !tbaa !20
  %69 = load i32, ptr %6, align 4, !tbaa !12
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds i16, ptr %68, i64 %70
  %72 = load i16, ptr %71, align 2, !tbaa !21
  %73 = zext i16 %72 to i32
  %74 = load i32, ptr %9, align 4, !tbaa !12
  %75 = icmp ugt i32 %73, %74
  br i1 %75, label %76, label %79

76:                                               ; preds = %65
  %77 = load i32, ptr %7, align 4, !tbaa !12
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %7, align 4, !tbaa !12
  br label %82

79:                                               ; preds = %65
  %80 = load i32, ptr %6, align 4, !tbaa !12
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %6, align 4, !tbaa !12
  br label %82

82:                                               ; preds = %79, %76
  br label %83

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

84:                                               ; preds = %83, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %85 = load i32, ptr %10, align 4
  switch i32 %85, label %95 [
    i32 0, label %86
  ]

86:                                               ; preds = %84
  br label %19, !llvm.loop !22

87:                                               ; preds = %31
  %88 = load i32, ptr %6, align 4, !tbaa !12
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.array_container_s, ptr %89, i32 0, i32 0
  %91 = load i32, ptr %90, align 8, !tbaa !9
  %92 = icmp eq i32 %88, %91
  br i1 %92, label %93, label %94

93:                                               ; preds = %87
  store i1 true, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %95

94:                                               ; preds = %87
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %95

95:                                               ; preds = %94, %93, %84
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %96

96:                                               ; preds = %95, %17
  %97 = load i1, ptr %3, align 1
  ret i1 %97
}

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 = { 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: inlinehint nounwind uwtable
declare hidden i32 @run_container_cardinality(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @array_container_is_subset_run(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = tail call i32 @run_container_cardinality(ptr noundef %1)
  %5 = icmp sgt i32 %3, %4
  br i1 %5, label %.thread, label %.preheader

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

.lr.ph:                                           ; preds = %.preheader
  %8 = load i32, ptr %1, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  br label %11

11:                                               ; preds = %.lr.ph, %22
  %.02335 = phi i32 [ 0, %.lr.ph ], [ %.124, %22 ]
  %.02634 = phi i32 [ 0, %.lr.ph ], [ %.127, %22 ]
  %12 = icmp slt i32 %.02634, %8
  br i1 %12, label %13, label %.critedge

13:                                               ; preds = %11
  %14 = load ptr, ptr %9, align 8, !tbaa !13
  %15 = zext nneg i32 %.02634 to i64
  %16 = getelementptr inbounds %struct.rle16_s, ptr %14, i64 %15
  %17 = load i16, ptr %16, align 2, !tbaa !14
  %18 = load ptr, ptr %10, align 8, !tbaa !17
  %19 = zext nneg i32 %.02335 to i64
  %20 = getelementptr inbounds i16, ptr %18, i64 %19
  %21 = load i16, ptr %20, align 2, !tbaa !18
  %.not = icmp ult i16 %21, %17
  br i1 %.not, label %.thread, label %22

22:                                               ; preds = %13
  %23 = zext i16 %17 to i32
  %24 = zext i16 %21 to i32
  %25 = getelementptr inbounds i8, ptr %16, i64 2
  %26 = load i16, ptr %25, align 2, !tbaa !19
  %27 = zext i16 %26 to i32
  %28 = add nuw nsw i32 %27, %23
  %29 = icmp ult i32 %28, %24
  %30 = zext i1 %29 to i32
  %.127 = add nuw nsw i32 %.02634, %30
  %not. = xor i1 %29, true
  %31 = zext i1 %not. to i32
  %.124 = add nuw nsw i32 %.02335, %31
  %32 = icmp slt i32 %.124, %6
  br i1 %32, label %11, label %.critedge

.critedge:                                        ; preds = %11, %22, %.preheader
  %.023.lcssa = phi i32 [ 0, %.preheader ], [ %.124, %22 ], [ %.02335, %11 ]
  %33 = icmp eq i32 %.023.lcssa, %6
  br label %.thread

.thread:                                          ; preds = %13, %.critedge, %2
  %.3 = phi i1 [ false, %2 ], [ %33, %.critedge ], [ false, %13 ]
  ret i1 %.3
}

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 = !{!"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 = !{!12, !10, i64 8}
!14 = !{!15, !16, i64 0}
!15 = !{!"rle16_s", !16, i64 0, !16, i64 2}
!16 = !{!"short", !8, i64 0}
!17 = !{!6, !10, i64 8}
!18 = !{!16, !16, i64 0}
!19 = !{!15, !16, i64 2}


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