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

; 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 void @array_run_container_lazy_xor(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.array_container_s, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.run_container_s, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !12
  %16 = add nsw i32 %12, %15
  call void @run_container_grow(ptr noundef %9, i32 noundef %16, i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !14
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.run_container_s, ptr %17, i32 0, i32 0
  store i32 0, ptr %18, align 8, !tbaa !12
  br label %19

19:                                               ; preds = %83, %3
  %20 = load i32, ptr %7, align 4, !tbaa !14
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.run_container_s, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !12
  %24 = icmp slt i32 %20, %23
  br i1 %24, label %25, label %31

25:                                               ; preds = %19
  %26 = load i32, ptr %8, align 4, !tbaa !14
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.array_container_s, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %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 %84

33:                                               ; preds = %31
  %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 !14
  %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
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.array_container_s, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  %46 = load i32, ptr %8, align 4, !tbaa !14
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i16, ptr %45, i64 %47
  %49 = load i16, ptr %48, align 2, !tbaa !20
  %50 = zext i16 %49 to i32
  %51 = icmp sle i32 %42, %50
  br i1 %51, label %52, label %72

52:                                               ; preds = %33
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.run_container_s, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = load i32, ptr %7, align 4, !tbaa !14
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.rle16_s, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.rle16_s, ptr %59, i32 0, i32 0
  %61 = load i16, ptr %60, align 2, !tbaa !16
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.run_container_s, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !15
  %65 = load i32, ptr %7, align 4, !tbaa !14
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds %struct.rle16_s, ptr %64, i64 %66
  %68 = getelementptr inbounds %struct.rle16_s, ptr %67, i32 0, i32 1
  %69 = load i16, ptr %68, align 2, !tbaa !21
  call void @run_container_smart_append_exclusive(ptr noundef %53, i16 noundef zeroext %61, i16 noundef zeroext %69)
  %70 = load i32, ptr %7, align 4, !tbaa !14
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %7, align 4, !tbaa !14
  br label %83

72:                                               ; preds = %33
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.array_container_s, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !19
  %77 = load i32, ptr %8, align 4, !tbaa !14
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds i16, ptr %76, i64 %78
  %80 = load i16, ptr %79, align 2, !tbaa !20
  call void @run_container_smart_append_exclusive(ptr noundef %73, i16 noundef zeroext %80, i16 noundef zeroext 0)
  %81 = load i32, ptr %8, align 4, !tbaa !14
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %8, align 4, !tbaa !14
  br label %83

83:                                               ; preds = %72, %52
  br label %19, !llvm.loop !22

84:                                               ; preds = %31
  br label %85

85:                                               ; preds = %91, %84
  %86 = load i32, ptr %8, align 4, !tbaa !14
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.array_container_s, ptr %87, i32 0, i32 0
  %89 = load i32, ptr %88, align 8, !tbaa !9
  %90 = icmp slt i32 %86, %89
  br i1 %90, label %91, label %102

91:                                               ; preds = %85
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.array_container_s, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !19
  %96 = load i32, ptr %8, align 4, !tbaa !14
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds i16, ptr %95, i64 %97
  %99 = load i16, ptr %98, align 2, !tbaa !20
  call void @run_container_smart_append_exclusive(ptr noundef %92, i16 noundef zeroext %99, i16 noundef zeroext 0)
  %100 = load i32, ptr %8, align 4, !tbaa !14
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %8, align 4, !tbaa !14
  br label %85, !llvm.loop !24

102:                                              ; preds = %85
  br label %103

103:                                              ; preds = %109, %102
  %104 = load i32, ptr %7, align 4, !tbaa !14
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.run_container_s, ptr %105, i32 0, i32 0
  %107 = load i32, ptr %106, align 8, !tbaa !12
  %108 = icmp slt i32 %104, %107
  br i1 %108, label %109, label %129

109:                                              ; preds = %103
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.run_container_s, ptr %111, i32 0, i32 2
  %113 = load ptr, ptr %112, align 8, !tbaa !15
  %114 = load i32, ptr %7, align 4, !tbaa !14
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds %struct.rle16_s, ptr %113, i64 %115
  %117 = getelementptr inbounds %struct.rle16_s, ptr %116, i32 0, i32 0
  %118 = load i16, ptr %117, align 2, !tbaa !16
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.run_container_s, ptr %119, i32 0, i32 2
  %121 = load ptr, ptr %120, align 8, !tbaa !15
  %122 = load i32, ptr %7, align 4, !tbaa !14
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds %struct.rle16_s, ptr %121, i64 %123
  %125 = getelementptr inbounds %struct.rle16_s, ptr %124, i32 0, i32 1
  %126 = load i16, ptr %125, align 2, !tbaa !21
  call void @run_container_smart_append_exclusive(ptr noundef %110, i16 noundef zeroext %118, i16 noundef zeroext %126)
  %127 = load i32, ptr %7, align 4, !tbaa !14
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %7, align 4, !tbaa !14
  br label %103, !llvm.loop !25

129:                                              ; preds = %103
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

declare void @run_container_grow(ptr noundef, i32 noundef, i1 noundef zeroext) #2

declare void @run_container_smart_append_exclusive(ptr noundef, i16 noundef zeroext, 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 = { "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 = !{!13, !11, i64 0}
!13 = !{!"run_container_s", !11, i64 0, !11, i64 4, !6, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!17, !18, i64 0}
!17 = !{!"rle16_s", !18, i64 0, !18, i64 2}
!18 = !{!"short", !7, i64 0}
!19 = !{!10, !6, i64 8}
!20 = !{!18, !18, i64 0}
!21 = !{!17, !18, i64 2}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = distinct !{!25, !23}


; 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 void @array_run_container_lazy_xor(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = load i32, ptr %1, align 8, !tbaa !11
  %6 = add nsw i32 %5, %4
  tail call void @run_container_grow(ptr noundef %2, i32 noundef %6, i1 noundef zeroext false) #2
  store i32 0, ptr %2, align 8, !tbaa !11
  %7 = load i32, ptr %1, align 8, !tbaa !11
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %3
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load i32, ptr %0, align 8, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph54, label %.critedge

13:                                               ; preds = %30
  %14 = load i32, ptr %0, align 8, !tbaa !5
  %15 = icmp slt i32 %.1, %14
  br i1 %15, label %.lr.ph54, label %.critedge, !llvm.loop !13

.lr.ph54:                                         ; preds = %.lr.ph, %13
  %.0353853 = phi i32 [ %.136, %13 ], [ 0, %.lr.ph ]
  %.03952 = phi i32 [ %.1, %13 ], [ 0, %.lr.ph ]
  %16 = load ptr, ptr %9, align 8, !tbaa !15
  %17 = sext i32 %.0353853 to i64
  %18 = getelementptr inbounds %struct.rle16_s, ptr %16, i64 %17
  %19 = load i16, ptr %18, align 2, !tbaa !16
  %20 = load ptr, ptr %10, align 8, !tbaa !19
  %21 = sext i32 %.03952 to i64
  %22 = getelementptr inbounds i16, ptr %20, i64 %21
  %23 = load i16, ptr %22, align 2, !tbaa !20
  %.not = icmp ugt i16 %19, %23
  br i1 %.not, label %28, label %24

24:                                               ; preds = %.lr.ph54
  %25 = getelementptr inbounds i8, ptr %18, i64 2
  %26 = load i16, ptr %25, align 2, !tbaa !21
  tail call void @run_container_smart_append_exclusive(ptr noundef nonnull %2, i16 noundef zeroext %19, i16 noundef zeroext %26) #2
  %27 = add nsw i32 %.0353853, 1
  br label %30

28:                                               ; preds = %.lr.ph54
  tail call void @run_container_smart_append_exclusive(ptr noundef nonnull %2, i16 noundef zeroext %23, i16 noundef zeroext 0) #2
  %29 = add nsw i32 %.03952, 1
  br label %30

30:                                               ; preds = %28, %24
  %.136 = phi i32 [ %27, %24 ], [ %.0353853, %28 ]
  %.1 = phi i32 [ %.03952, %24 ], [ %29, %28 ]
  %31 = load i32, ptr %1, align 8, !tbaa !11
  %32 = icmp slt i32 %.136, %31
  br i1 %32, label %13, label %.critedge, !llvm.loop !13

.critedge:                                        ; preds = %30, %13, %.lr.ph, %3
  %33 = phi i32 [ %7, %3 ], [ %7, %.lr.ph ], [ %31, %13 ], [ %31, %30 ]
  %.035.lcssa = phi i32 [ 0, %3 ], [ 0, %.lr.ph ], [ %.136, %13 ], [ %.136, %30 ]
  %.0.lcssa = phi i32 [ 0, %3 ], [ 0, %.lr.ph ], [ %.1, %13 ], [ %.1, %30 ]
  %34 = load i32, ptr %0, align 8, !tbaa !5
  %35 = icmp slt i32 %.0.lcssa, %34
  br i1 %35, label %.lr.ph45, label %.preheader

.lr.ph45:                                         ; preds = %.critedge
  %36 = getelementptr inbounds i8, ptr %0, i64 8
  %37 = sext i32 %.0.lcssa to i64
  br label %42

.preheader.loopexit:                              ; preds = %42
  %.pre = load i32, ptr %1, align 8, !tbaa !11
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.critedge
  %38 = phi i32 [ %.pre, %.preheader.loopexit ], [ %33, %.critedge ]
  %39 = icmp slt i32 %.035.lcssa, %38
  br i1 %39, label %.lr.ph47, label %._crit_edge

.lr.ph47:                                         ; preds = %.preheader
  %40 = getelementptr inbounds i8, ptr %1, i64 8
  %41 = sext i32 %.035.lcssa to i64
  br label %49

42:                                               ; preds = %.lr.ph45, %42
  %indvars.iv = phi i64 [ %37, %.lr.ph45 ], [ %indvars.iv.next, %42 ]
  %43 = load ptr, ptr %36, align 8, !tbaa !19
  %44 = getelementptr inbounds i16, ptr %43, i64 %indvars.iv
  %45 = load i16, ptr %44, align 2, !tbaa !20
  tail call void @run_container_smart_append_exclusive(ptr noundef nonnull %2, i16 noundef zeroext %45, i16 noundef zeroext 0) #2
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %46 = load i32, ptr %0, align 8, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = icmp slt i64 %indvars.iv.next, %47
  br i1 %48, label %42, label %.preheader.loopexit, !llvm.loop !22

49:                                               ; preds = %.lr.ph47, %49
  %indvars.iv49 = phi i64 [ %41, %.lr.ph47 ], [ %indvars.iv.next50, %49 ]
  %50 = load ptr, ptr %40, align 8, !tbaa !15
  %51 = getelementptr inbounds %struct.rle16_s, ptr %50, i64 %indvars.iv49
  %52 = load i16, ptr %51, align 2, !tbaa !16
  %53 = getelementptr inbounds i8, ptr %51, i64 2
  %54 = load i16, ptr %53, align 2, !tbaa !21
  tail call void @run_container_smart_append_exclusive(ptr noundef nonnull %2, i16 noundef zeroext %52, i16 noundef zeroext %54) #2
  %indvars.iv.next50 = add nsw i64 %indvars.iv49, 1
  %55 = load i32, ptr %1, align 8, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = icmp slt i64 %indvars.iv.next50, %56
  br i1 %57, label %49, label %._crit_edge, !llvm.loop !23

._crit_edge:                                      ; preds = %49, %.preheader
  ret void
}

declare void @run_container_grow(ptr noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #1

declare void @run_container_smart_append_exclusive(ptr noundef, i16 noundef zeroext, 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 = { "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 }

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


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