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

; 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.bitset_container_s = type { i32, ptr }

declare void @bitset_set_list(ptr noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #2

declare ptr @array_container_create_given_capacity(i32 noundef) #0

declare void @array_container_union(ptr noundef, ptr noundef, ptr noundef) #0

declare ptr @bitset_container_create() #0

declare i64 @fast_union_uint16(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @array_array_container_lazy_inplace_union(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.array_container_s, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.array_container_s, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = add nsw i32 %14, %17
  store i32 %18, ptr %8, align 4, !tbaa !12
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %19, align 8, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !12
  %21 = icmp sle i32 %20, 1024
  br i1 %21, label %22, label %86

22:                                               ; preds = %3
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.array_container_s, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !13
  %26 = load i32, ptr %8, align 4, !tbaa !12
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %28, label %43

28:                                               ; preds = %22
  %29 = load i32, ptr %8, align 4, !tbaa !12
  %30 = mul nsw i32 2, %29
  %31 = call ptr @array_container_create_given_capacity(i32 noundef %30)
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %31, ptr %32, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %41

36:                                               ; preds = %28
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = load ptr, ptr %39, align 8, !tbaa !5
  call void @array_container_union(ptr noundef %37, ptr noundef %38, ptr noundef %40)
  br label %42

41:                                               ; preds = %28
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %120

42:                                               ; preds = %36
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %120

43:                                               ; preds = %22
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.array_container_s, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !14
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.array_container_s, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds i16, ptr %46, i64 %50
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.array_container_s, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !14
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.array_container_s, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = mul i64 %58, 2
  call void @llvm.memmove.p0.p0.i64(ptr align 2 %51, ptr align 2 %54, i64 %59, i1 false)
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.array_container_s, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !14
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.array_container_s, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i16, ptr %62, i64 %66
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.array_container_s, ptr %68, i32 0, i32 0
  %70 = load i32, ptr %69, align 8, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.array_container_s, ptr %72, i32 0, i32 2
  %74 = load ptr, ptr %73, align 8, !tbaa !14
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.array_container_s, ptr %75, i32 0, i32 0
  %77 = load i32, ptr %76, align 8, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = load ptr, ptr %5, 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 !14
  %82 = call i64 @fast_union_uint16(ptr noundef %67, i64 noundef %71, ptr noundef %74, i64 noundef %78, ptr noundef %81)
  %83 = trunc i64 %82 to i32
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.array_container_s, ptr %84, i32 0, i32 0
  store i32 %83, ptr %85, align 8, !tbaa !9
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %120

86:                                               ; preds = %3
  %87 = call ptr @bitset_container_create()
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %87, ptr %88, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  store i8 1, ptr %10, align 1, !tbaa !15
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = load ptr, ptr %89, align 8, !tbaa !5
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %117

92:                                               ; preds = %86
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  %94 = load ptr, ptr %93, align 8, !tbaa !5
  store ptr %94, ptr %11, align 8, !tbaa !5
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.bitset_container_s, ptr %95, i32 0, i32 1
  %97 = load ptr, ptr %96, align 8, !tbaa !17
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.array_container_s, ptr %98, i32 0, i32 2
  %100 = load ptr, ptr %99, align 8, !tbaa !14
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.array_container_s, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 8, !tbaa !9
  %104 = sext i32 %103 to i64
  call void @bitset_set_list(ptr noundef %97, ptr noundef %100, i64 noundef %104)
  %105 = load ptr, ptr %11, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.bitset_container_s, ptr %105, i32 0, i32 1
  %107 = load ptr, ptr %106, align 8, !tbaa !17
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.array_container_s, ptr %108, i32 0, i32 2
  %110 = load ptr, ptr %109, align 8, !tbaa !14
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.array_container_s, ptr %111, i32 0, i32 0
  %113 = load i32, ptr %112, align 8, !tbaa !9
  %114 = sext i32 %113 to i64
  call void @bitset_set_list(ptr noundef %107, ptr noundef %110, i64 noundef %114)
  %115 = load ptr, ptr %11, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.bitset_container_s, ptr %115, i32 0, i32 0
  store i32 -1, ptr %116, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %117

117:                                              ; preds = %92, %86
  %118 = load i8, ptr %10, align 1, !tbaa !15, !range !20, !noundef !21
  %119 = trunc i8 %118 to i1
  store i1 %119, ptr %4, align 1
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  br label %120

120:                                              ; preds = %117, %43, %42, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %121 = load i1, ptr %4, align 1
  ret i1 %121
}

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"array_container_s", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 4}
!14 = !{!10, !6, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{!18, !6, i64 8}
!18 = !{!"bitset_container_s", !11, i64 0, !6, i64 8}
!19 = !{!18, !11, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}


; 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"

declare void @bitset_set_list(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

declare ptr @array_container_create_given_capacity(i32 noundef) local_unnamed_addr #0

declare void @array_container_union(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @bitset_container_create() local_unnamed_addr #0

declare i64 @fast_union_uint16(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @array_array_container_lazy_inplace_union(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = load i32, ptr %1, align 8, !tbaa !5
  %6 = add nsw i32 %5, %4
  store ptr null, ptr %2, align 8, !tbaa !11
  %7 = icmp slt i32 %6, 1025
  br i1 %7, label %8, label %33

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !12
  %11 = icmp slt i32 %10, %6
  br i1 %11, label %12, label %16

12:                                               ; preds = %8
  %13 = shl nsw i32 %6, 1
  %14 = tail call ptr @array_container_create_given_capacity(i32 noundef %13) #3
  store ptr %14, ptr %2, align 8, !tbaa !11
  %.not37 = icmp eq ptr %14, null
  br i1 %.not37, label %47, label %15

15:                                               ; preds = %12
  tail call void @array_container_union(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %14) #3
  br label %47

16:                                               ; preds = %8
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = sext i32 %5 to i64
  %20 = getelementptr inbounds i16, ptr %18, i64 %19
  %21 = sext i32 %4 to i64
  %22 = shl nsw i64 %21, 1
  tail call void @llvm.memmove.p0.p0.i64(ptr align 2 %20, ptr align 2 %18, i64 %22, i1 false)
  %23 = load ptr, ptr %17, align 8, !tbaa !13
  %24 = load i32, ptr %1, align 8, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds i16, ptr %23, i64 %25
  %27 = load i32, ptr %0, align 8, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = tail call i64 @fast_union_uint16(ptr noundef %26, i64 noundef %28, ptr noundef %30, i64 noundef %25, ptr noundef %23) #3
  %32 = trunc i64 %31 to i32
  store i32 %32, ptr %0, align 8, !tbaa !5
  br label %47

33:                                               ; preds = %3
  %34 = tail call ptr @bitset_container_create() #3
  store ptr %34, ptr %2, align 8, !tbaa !11
  %.not = icmp eq ptr %34, null
  br i1 %.not, label %47, label %35

35:                                               ; preds = %33
  %36 = getelementptr inbounds i8, ptr %34, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %0, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = load i32, ptr %0, align 8, !tbaa !5
  %41 = sext i32 %40 to i64
  tail call void @bitset_set_list(ptr noundef %37, ptr noundef %39, i64 noundef %41) #3
  %42 = load ptr, ptr %36, align 8, !tbaa !14
  %43 = getelementptr inbounds i8, ptr %1, i64 8
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = load i32, ptr %1, align 8, !tbaa !5
  %46 = sext i32 %45 to i64
  tail call void @bitset_set_list(ptr noundef %42, ptr noundef %44, i64 noundef %46) #3
  store i32 -1, ptr %34, align 8, !tbaa !16
  br label %47

47:                                               ; preds = %33, %35, %12, %16, %15
  %.0 = phi i1 [ false, %15 ], [ false, %16 ], [ true, %12 ], [ true, %35 ], [ true, %33 ]
  ret i1 %.0
}

attributes #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!10, !10, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 8}
!14 = !{!15, !10, i64 8}
!15 = !{!"bitset_container_s", !7, i64 0, !10, i64 8}
!16 = !{!15, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass