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

; 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.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 i32 @run_container_negation_range(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp sle i32 %14, %15
  br i1 %16, label %17, label %21

17:                                               ; preds = %4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call ptr @run_container_clone(ptr noundef %18)
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %19, ptr %20, align 8, !tbaa !5
  store i32 3, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %115

21:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %22 = load ptr, ptr %6, 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 !11
  %25 = add nsw i32 %24, 1
  %26 = call ptr @run_container_create_given_capacity(i32 noundef %25)
  store ptr %26, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %64, %21
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.run_container_s, ptr %29, i32 0, i32 0
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = icmp slt i32 %28, %31
  br i1 %32, label %33, label %45

33:                                               ; preds = %27
  %34 = load ptr, ptr %6, 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 !13
  %37 = load i32, ptr %13, align 4, !tbaa !9
  %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 !14
  %42 = zext i16 %41 to i32
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = icmp slt i32 %42, %43
  br label %45

45:                                               ; preds = %33, %27
  %46 = phi i1 [ false, %27 ], [ %44, %33 ]
  br i1 %46, label %47, label %67

47:                                               ; preds = %45
  %48 = load ptr, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.run_container_s, ptr %48, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !13
  %51 = load i32, ptr %13, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.rle16_s, ptr %50, i64 %52
  %54 = load ptr, ptr %6, 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 !13
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.rle16_s, ptr %56, i64 %58
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %53, ptr align 2 %59, i64 4, i1 false), !tbaa.struct !17
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.run_container_s, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !11
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %61, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %47
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %13, align 4, !tbaa !9
  br label %27, !llvm.loop !19

67:                                               ; preds = %45
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load i32, ptr %7, align 4, !tbaa !9
  %70 = trunc i32 %69 to i16
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = load i32, ptr %7, align 4, !tbaa !9
  %73 = sub nsw i32 %71, %72
  %74 = sub nsw i32 %73, 1
  %75 = trunc i32 %74 to i16
  call void @run_container_smart_append_exclusive(ptr noundef %68, i16 noundef zeroext %70, i16 noundef zeroext %75)
  br label %76

76:                                               ; preds = %100, %67
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.run_container_s, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !11
  %81 = icmp slt i32 %77, %80
  br i1 %81, label %82, label %103

82:                                               ; preds = %76
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.run_container_s, ptr %84, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !13
  %87 = load i32, ptr %13, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds %struct.rle16_s, ptr %86, i64 %88
  %90 = getelementptr inbounds %struct.rle16_s, ptr %89, i32 0, i32 0
  %91 = load i16, ptr %90, align 2, !tbaa !14
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.run_container_s, ptr %92, i32 0, i32 2
  %94 = load ptr, ptr %93, align 8, !tbaa !13
  %95 = load i32, ptr %13, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds %struct.rle16_s, ptr %94, i64 %96
  %98 = getelementptr inbounds %struct.rle16_s, ptr %97, i32 0, i32 1
  %99 = load i16, ptr %98, align 2, !tbaa !21
  call void @run_container_smart_append_exclusive(ptr noundef %83, i16 noundef zeroext %91, i16 noundef zeroext %99)
  br label %100

100:                                              ; preds = %82
  %101 = load i32, ptr %13, align 4, !tbaa !9
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %13, align 4, !tbaa !9
  br label %76, !llvm.loop !22

103:                                              ; preds = %76
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  %105 = call ptr @convert_run_to_efficient_container(ptr noundef %104, ptr noundef %10)
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %105, ptr %106, align 8, !tbaa !5
  %107 = load i8, ptr %10, align 1, !tbaa !23
  %108 = zext i8 %107 to i32
  %109 = icmp ne i32 %108, 3
  br i1 %109, label %110, label %112

110:                                              ; preds = %103
  %111 = load ptr, ptr %12, align 8, !tbaa !5
  call void @run_container_free(ptr noundef %111)
  br label %112

112:                                              ; preds = %110, %103
  %113 = load i8, ptr %10, align 1, !tbaa !23
  %114 = zext i8 %113 to i32
  store i32 %114, ptr %5, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  br label %115

115:                                              ; preds = %112, %17
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  %116 = load i32, ptr %5, align 4
  ret i32 %116
}

; 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

declare ptr @run_container_clone(ptr noundef) #3

declare ptr @run_container_create_given_capacity(i32 noundef) #3

declare void @run_container_smart_append_exclusive(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) #3

declare ptr @convert_run_to_efficient_container(ptr noundef, ptr noundef) #3

declare void @run_container_free(ptr noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"run_container_s", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !16, i64 0}
!15 = !{!"rle16_s", !16, i64 0, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = !{i64 0, i64 2, !18, i64 2, i64 2, !18}
!18 = !{!16, !16, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!15, !16, i64 2}
!22 = distinct !{!22, !20}
!23 = !{!7, !7, i64 0}


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

; Function Attrs: mustprogress 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 range(i32 0, 256) i32 @run_container_negation_range(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 {
  %5 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #3
  %.not = icmp sgt i32 %2, %1
  br i1 %.not, label %8, label %6

6:                                                ; preds = %4
  %7 = tail call ptr @run_container_clone(ptr noundef %0) #3
  store ptr %7, ptr %3, align 8, !tbaa !5
  br label %51

8:                                                ; preds = %4
  %9 = load i32, ptr %0, align 8, !tbaa !9
  %10 = add nsw i32 %9, 1
  %11 = tail call ptr @run_container_create_given_capacity(i32 noundef %10) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i32, ptr %0, align 8, !tbaa !9
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %8
  %15 = getelementptr inbounds i8, ptr %11, i64 8
  br label %16

16:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %17 = load ptr, ptr %12, align 8, !tbaa !12
  %18 = getelementptr inbounds %struct.rle16_s, ptr %17, i64 %indvars.iv
  %19 = load i16, ptr %18, align 2, !tbaa !13
  %20 = zext i16 %19 to i32
  %21 = icmp slt i32 %20, %1
  br i1 %21, label %22, label %.critedge.loopexit

22:                                               ; preds = %16
  %23 = load ptr, ptr %15, align 8, !tbaa !12
  %24 = getelementptr inbounds %struct.rle16_s, ptr %23, i64 %indvars.iv
  %25 = load i32, ptr %18, align 2
  store i32 %25, ptr %24, align 2
  %26 = load i32, ptr %11, align 8, !tbaa !9
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %11, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %0, align 8, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = icmp slt i64 %indvars.iv.next, %29
  br i1 %30, label %16, label %.critedge.loopexit, !llvm.loop !16

.critedge.loopexit:                               ; preds = %22, %16
  %.0.lcssa.ph.in = phi i64 [ %indvars.iv, %16 ], [ %indvars.iv.next, %22 ]
  %.0.lcssa.ph = trunc i64 %.0.lcssa.ph.in to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %8
  %.0.lcssa = phi i32 [ 0, %8 ], [ %.0.lcssa.ph, %.critedge.loopexit ]
  %31 = trunc i32 %1 to i16
  %32 = xor i32 %1, -1
  %33 = add i32 %32, %2
  %34 = trunc i32 %33 to i16
  tail call void @run_container_smart_append_exclusive(ptr noundef %11, i16 noundef zeroext %31, i16 noundef zeroext %34) #3
  %35 = load i32, ptr %0, align 8, !tbaa !9
  %36 = icmp slt i32 %.0.lcssa, %35
  br i1 %36, label %.lr.ph39, label %._crit_edge

.lr.ph39:                                         ; preds = %.critedge
  %37 = zext nneg i32 %.0.lcssa to i64
  br label %38

38:                                               ; preds = %.lr.ph39, %38
  %indvars.iv41 = phi i64 [ %37, %.lr.ph39 ], [ %indvars.iv.next42, %38 ]
  %39 = load ptr, ptr %12, align 8, !tbaa !12
  %40 = getelementptr inbounds %struct.rle16_s, ptr %39, i64 %indvars.iv41
  %41 = load i16, ptr %40, align 2, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %40, i64 2
  %43 = load i16, ptr %42, align 2, !tbaa !18
  tail call void @run_container_smart_append_exclusive(ptr noundef %11, i16 noundef zeroext %41, i16 noundef zeroext %43) #3
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %44 = load i32, ptr %0, align 8, !tbaa !9
  %45 = trunc nuw i64 %indvars.iv.next42 to i32
  %46 = icmp sgt i32 %44, %45
  br i1 %46, label %38, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %38, %.critedge
  %47 = call ptr @convert_run_to_efficient_container(ptr noundef %11, ptr noundef nonnull %5) #3
  store ptr %47, ptr %3, align 8, !tbaa !5
  %48 = load i8, ptr %5, align 1, !tbaa !20
  %.not34 = icmp eq i8 %48, 3
  br i1 %.not34, label %51, label %49

49:                                               ; preds = %._crit_edge
  call void @run_container_free(ptr noundef %11) #3
  %.pre = load i8, ptr %5, align 1, !tbaa !20
  %50 = zext i8 %.pre to i32
  br label %51

51:                                               ; preds = %._crit_edge, %49, %6
  %.031 = phi i32 [ 3, %6 ], [ %50, %49 ], [ 3, %._crit_edge ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #3
  ret i32 %.031
}

declare ptr @run_container_clone(ptr noundef) local_unnamed_addr #2

declare ptr @run_container_create_given_capacity(i32 noundef) local_unnamed_addr #2

declare void @run_container_smart_append_exclusive(ptr noundef, i16 noundef zeroext, i16 noundef zeroext) local_unnamed_addr #2

declare ptr @convert_run_to_efficient_container(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @run_container_free(ptr noundef) local_unnamed_addr #2

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


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