; 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.array_container_s = type { i32, 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: inlinehint nounwind uwtable
declare hidden i32 @advanceUntil(ptr noundef, i32 noundef, i32 noundef, i16 noundef zeroext) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @array_run_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
  %9 = alloca i16, align 2
  %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 %5, align 8, !tbaa !5
  %12 = call zeroext i1 @run_container_is_full(ptr noundef %11)
  br i1 %12, label %13, label %17

13:                                               ; preds = %2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call zeroext i1 @array_container_empty(ptr noundef %14)
  %16 = xor i1 %15, true
  store i1 %16, ptr %3, align 1
  br label %96

17:                                               ; preds = %2
  %18 = load ptr, ptr %5, 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 !9
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %23

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

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %24 = load ptr, ptr %5, 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 !12
  %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
  br label %30

30:                                               ; preds = %93, %23
  %31 = load i32, ptr %7, align 4, !tbaa !12
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.array_container_s, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !17
  %35 = icmp slt i32 %31, %34
  br i1 %35, label %36, label %94

36:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 2, ptr %9) #4
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.array_container_s, ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !19
  %40 = load i32, ptr %7, align 4, !tbaa !12
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i16, ptr %39, i64 %41
  %43 = load i16, ptr %42, align 2, !tbaa !15
  store i16 %43, ptr %9, align 2, !tbaa !15
  br label %44

44:                                               ; preds = %64, %36
  %45 = getelementptr inbounds %struct.rle16_s, ptr %8, i32 0, i32 0
  %46 = load i16, ptr %45, align 2, !tbaa !20
  %47 = zext i16 %46 to i32
  %48 = getelementptr inbounds %struct.rle16_s, ptr %8, i32 0, i32 1
  %49 = load i16, ptr %48, align 2, !tbaa !22
  %50 = zext i16 %49 to i32
  %51 = add nsw i32 %47, %50
  %52 = load i16, ptr %9, align 2, !tbaa !15
  %53 = zext i16 %52 to i32
  %54 = icmp slt i32 %51, %53
  br i1 %54, label %55, label %71

55:                                               ; preds = %44
  %56 = load i32, ptr %6, align 4, !tbaa !12
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %6, align 4, !tbaa !12
  %58 = load i32, ptr %6, align 4, !tbaa !12
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.run_container_s, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !9
  %62 = icmp eq i32 %58, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %55
  store i1 false, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %91

64:                                               ; preds = %55
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.run_container_s, ptr %65, i32 0, i32 2
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = load i32, ptr %6, align 4, !tbaa !12
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds %struct.rle16_s, ptr %67, i64 %69
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %8, ptr align 2 %70, i64 4, i1 false), !tbaa.struct !14
  br label %44, !llvm.loop !23

71:                                               ; preds = %44
  %72 = getelementptr inbounds %struct.rle16_s, ptr %8, i32 0, i32 0
  %73 = load i16, ptr %72, align 2, !tbaa !20
  %74 = zext i16 %73 to i32
  %75 = load i16, ptr %9, align 2, !tbaa !15
  %76 = zext i16 %75 to i32
  %77 = icmp sgt i32 %74, %76
  br i1 %77, label %78, label %89

78:                                               ; preds = %71
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.array_container_s, ptr %79, i32 0, i32 2
  %81 = load ptr, ptr %80, align 8, !tbaa !19
  %82 = load i32, ptr %7, align 4, !tbaa !12
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.array_container_s, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !17
  %86 = getelementptr inbounds %struct.rle16_s, ptr %8, i32 0, i32 0
  %87 = load i16, ptr %86, align 2, !tbaa !20
  %88 = call i32 @advanceUntil(ptr noundef %81, i32 noundef %82, i32 noundef %85, i16 noundef zeroext %87)
  store i32 %88, ptr %7, align 4, !tbaa !12
  br label %90

89:                                               ; preds = %71
  store i1 true, ptr %3, align 1
  store i32 1, ptr %10, align 4
  br label %91

90:                                               ; preds = %78
  store i32 0, ptr %10, align 4
  br label %91

91:                                               ; preds = %90, %89, %63
  call void @llvm.lifetime.end.p0(i64 2, ptr %9) #4
  %92 = load i32, ptr %10, align 4
  switch i32 %92, label %95 [
    i32 0, label %93
  ]

93:                                               ; preds = %91
  br label %30, !llvm.loop !25

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @array_container_empty(ptr 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, !11, i64 0}
!10 = !{!"run_container_s", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !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, !11, i64 0}
!18 = !{!"array_container_s", !11, i64 0, !11, i64 4, !6, i64 8}
!19 = !{!18, !6, i64 8}
!20 = !{!21, !16, i64 0}
!21 = !{!"rle16_s", !16, i64 0, !16, i64 2}
!22 = !{!21, !16, i64 2}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


; 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: inlinehint nounwind uwtable
declare hidden i32 @advanceUntil(ptr noundef, i32 noundef, i32 noundef, i16 noundef zeroext) local_unnamed_addr #0

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

4:                                                ; preds = %2
  %5 = tail call zeroext i1 @array_container_empty(ptr noundef %0)
  %6 = xor i1 %5, true
  br label %.thread

7:                                                ; preds = %2
  %8 = load i32, ptr %1, align 8, !tbaa !5
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %.thread, label %10

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load i32, ptr %0, align 8, !tbaa !11
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph50, label %.thread

.lr.ph50:                                         ; preds = %10
  %14 = load ptr, ptr %11, align 8, !tbaa !13
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %14, i64 2
  %.sroa.7.0.copyload = load i16, ptr %.sroa.7.0..sroa_idx, align 2, !tbaa !14
  %.sroa.0.0.copyload = load i16, ptr %14, align 2, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  br label %16

16:                                               ; preds = %.lr.ph50, %39
  %17 = phi i32 [ %12, %.lr.ph50 ], [ %41, %39 ]
  %.sroa.0.048 = phi i16 [ %.sroa.0.0.copyload, %.lr.ph50 ], [ %.sroa.0.1.lcssa, %39 ]
  %.sroa.7.047 = phi i16 [ %.sroa.7.0.copyload, %.lr.ph50 ], [ %.sroa.7.1.lcssa, %39 ]
  %.02646 = phi i32 [ 0, %.lr.ph50 ], [ %40, %39 ]
  %.02845 = phi i32 [ 0, %.lr.ph50 ], [ %.129.lcssa, %39 ]
  %18 = load ptr, ptr %15, align 8, !tbaa !16
  %19 = sext i32 %.02646 to i64
  %20 = getelementptr inbounds i16, ptr %18, i64 %19
  %21 = load i16, ptr %20, align 2, !tbaa !14
  %22 = zext i16 %21 to i32
  %23 = zext i16 %.sroa.0.048 to i32
  %24 = zext i16 %.sroa.7.047 to i32
  %25 = add nuw nsw i32 %23, %24
  %26 = icmp ult i32 %25, %22
  br i1 %26, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %16
  %27 = load i32, ptr %1, align 8, !tbaa !5
  %28 = sext i32 %.02845 to i64
  br label %29

29:                                               ; preds = %.lr.ph, %32
  %indvars.iv = phi i64 [ %28, %.lr.ph ], [ %indvars.iv.next, %32 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %30 = trunc nsw i64 %indvars.iv.next to i32
  %31 = icmp eq i32 %27, %30
  br i1 %31, label %.thread, label %32

32:                                               ; preds = %29
  %33 = load ptr, ptr %11, align 8, !tbaa !13
  %34 = getelementptr inbounds %struct.rle16_s, ptr %33, i64 %indvars.iv.next
  %.sroa.0.0.copyload5 = load i16, ptr %34, align 2, !tbaa !14
  %.sroa.7.0..sroa_idx6 = getelementptr inbounds i8, ptr %34, i64 2
  %.sroa.7.0.copyload7 = load i16, ptr %.sroa.7.0..sroa_idx6, align 2, !tbaa !14
  %35 = zext i16 %.sroa.0.0.copyload5 to i32
  %36 = zext i16 %.sroa.7.0.copyload7 to i32
  %37 = add nuw nsw i32 %35, %36
  %38 = icmp ult i32 %37, %22
  br i1 %38, label %29, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %32, %16
  %.129.lcssa = phi i32 [ %.02845, %16 ], [ %30, %32 ]
  %.sroa.7.1.lcssa = phi i16 [ %.sroa.7.047, %16 ], [ %.sroa.7.0.copyload7, %32 ]
  %.sroa.0.1.lcssa = phi i16 [ %.sroa.0.048, %16 ], [ %.sroa.0.0.copyload5, %32 ]
  %.not = icmp ule i16 %.sroa.0.1.lcssa, %21
  br i1 %.not, label %.thread, label %39

39:                                               ; preds = %._crit_edge
  %40 = tail call i32 @advanceUntil(ptr noundef %18, i32 noundef %.02646, i32 noundef %17, i16 noundef zeroext %.sroa.0.1.lcssa)
  %41 = load i32, ptr %0, align 8, !tbaa !11
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %16, label %.thread, !llvm.loop !19

.thread:                                          ; preds = %39, %._crit_edge, %29, %10, %7, %4
  %.3 = phi i1 [ %6, %4 ], [ false, %7 ], [ false, %10 ], [ false, %29 ], [ %.not, %._crit_edge ], [ %.not, %39 ]
  ret i1 %.3
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @array_container_empty(ptr 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 = !{!12, !7, i64 0}
!12 = !{!"array_container_s", !7, i64 0, !7, i64 4, !10, i64 8}
!13 = !{!6, !10, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !8, i64 0}
!16 = !{!12, !10, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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