; LLVM IR from jermp/2i_bench :: external/CRoaring/tests (mixed_container_unit)

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

@.str = external hidden unnamed_addr constant [95 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [43 x i8], align 1

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

declare ptr @array_container_create() #1

declare ptr @bitset_container_create() #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @array_container_add(ptr noundef, i16 noundef zeroext) #2

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

declare void @_assert_int_equal(i64 noundef, i64 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @bitset_container_cardinality(ptr noundef) #2

declare void @_assert_true(i64 noundef, ptr noundef, ptr noundef, i32 noundef) #1

declare void @bitset_container_free(ptr noundef) #1

declare void @array_container_free(ptr noundef) #1

declare void @array_container_negation(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @array_negation_test() #3 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %6 = call ptr @array_container_create()
  store ptr %6, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %7 = call ptr @bitset_container_create()
  store ptr %7, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %19, %0
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 65536
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %22

12:                                               ; preds = %8
  %13 = load ptr, ptr %2, align 8, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = trunc i32 %14 to i16
  %16 = call zeroext i1 @array_container_add(ptr noundef %13, i16 noundef zeroext %15)
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %1, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %12
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = add nsw i32 %20, 29
  store i32 %21, ptr %4, align 4, !tbaa !5
  br label %8, !llvm.loop !11

22:                                               ; preds = %11
  %23 = load ptr, ptr %2, align 8, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  call void @array_container_negation(ptr noundef %23, ptr noundef %24)
  %25 = load ptr, ptr %3, align 8, !tbaa !9
  %26 = call i32 @bitset_container_cardinality(ptr noundef %25)
  %27 = sext i32 %26 to i64
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = sub nsw i32 65536, %28
  %30 = sext i32 %29 to i64
  call void @_assert_int_equal(i64 noundef %27, i64 noundef %30, ptr noundef @.str, i32 noundef 1390)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %60, %22
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp slt i32 %32, 65536
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %63

35:                                               ; preds = %31
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = srem i32 %36, 29
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %47

39:                                               ; preds = %35
  %40 = load ptr, ptr %3, align 8, !tbaa !9
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = trunc i32 %41 to i16
  %43 = call zeroext i1 @bitset_container_contains(ptr noundef %40, i16 noundef zeroext %42)
  %44 = xor i1 %43, true
  %45 = zext i1 %44 to i32
  %46 = sext i32 %45 to i64
  call void @_assert_true(i64 noundef %46, ptr noundef @.str.47, ptr noundef @.str, i32 noundef 1394)
  br label %53

47:                                               ; preds = %35
  %48 = load ptr, ptr %3, align 8, !tbaa !9
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = trunc i32 %49 to i16
  %51 = call zeroext i1 @bitset_container_contains(ptr noundef %48, i16 noundef zeroext %50)
  %52 = zext i1 %51 to i64
  call void @_assert_true(i64 noundef %52, ptr noundef @.str.47, ptr noundef @.str, i32 noundef 1396)
  br label %53

53:                                               ; preds = %47, %39
  %54 = load ptr, ptr %2, align 8, !tbaa !9
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = trunc i32 %55 to i16
  %57 = call zeroext i1 @array_container_add(ptr noundef %54, i16 noundef zeroext %56)
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %1, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %53
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %5, align 4, !tbaa !5
  br label %31, !llvm.loop !13

63:                                               ; preds = %34
  %64 = load ptr, ptr %2, align 8, !tbaa !9
  call void @array_container_free(ptr noundef %64)
  %65 = load ptr, ptr %3, align 8, !tbaa !9
  call void @bitset_container_free(ptr noundef %65)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

; Function Attrs: inlinehint nounwind uwtable
declare zeroext i1 @bitset_container_contains(ptr noundef, i16 noundef zeroext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@.str = external hidden unnamed_addr constant [95 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [43 x i8], align 1

declare ptr @array_container_create() local_unnamed_addr #0

declare ptr @bitset_container_create() local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @array_container_add(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @bitset_container_cardinality(ptr noundef) local_unnamed_addr #1

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

declare void @bitset_container_free(ptr noundef) local_unnamed_addr #0

declare void @array_container_free(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @array_negation_test() local_unnamed_addr #2 {
  %1 = tail call ptr @array_container_create() #3
  %2 = tail call ptr @bitset_container_create() #3
  br label %6

3:                                                ; preds = %6
  tail call void @array_container_negation(ptr noundef %1, ptr noundef %2) #3
  %4 = tail call i32 @bitset_container_cardinality(ptr noundef %2)
  %5 = sext i32 %4 to i64
  tail call void @_assert_int_equal(i64 noundef %5, i64 noundef 63276, ptr noundef nonnull @.str, i32 noundef 1390) #3
  br label %12

6:                                                ; preds = %0, %6
  %.02023 = phi i32 [ 0, %0 ], [ %10, %6 ]
  %.02122 = phi i32 [ 0, %0 ], [ %9, %6 ]
  %7 = trunc nuw i32 %.02023 to i16
  %8 = tail call zeroext i1 @array_container_add(ptr noundef %1, i16 noundef zeroext %7)
  %9 = add nuw nsw i32 %.02122, 1
  %10 = add nuw nsw i32 %.02023, 29
  %exitcond.not = icmp eq i32 %9, 2260
  br i1 %exitcond.not, label %3, label %6, !llvm.loop !5

11:                                               ; preds = %12
  tail call void @array_container_free(ptr noundef %1) #3
  tail call void @bitset_container_free(ptr noundef %2) #3
  ret void

12:                                               ; preds = %3, %12
  %.024 = phi i32 [ 0, %3 ], [ %18, %12 ]
  %.lhs.trunc = trunc nuw i32 %.024 to i16
  %13 = urem i16 %.lhs.trunc, 29
  %14 = icmp eq i16 %13, 0
  %15 = tail call zeroext i1 @bitset_container_contains(ptr noundef %2, i16 noundef zeroext %.lhs.trunc)
  %spec.select = xor i1 %15, %14
  %spec.select28 = select i1 %14, i32 1394, i32 1396
  %16 = zext i1 %spec.select to i64
  tail call void @_assert_true(i64 noundef %16, ptr noundef nonnull @.str.47, ptr noundef nonnull @.str, i32 noundef %spec.select28) #3
  %17 = tail call zeroext i1 @array_container_add(ptr noundef %1, i16 noundef zeroext %.lhs.trunc)
  %18 = add nuw nsw i32 %.024, 1
  %exitcond25.not = icmp eq i32 %18, 65536
  br i1 %exitcond25.not, label %11, label %12, !llvm.loop !7
}

; Function Attrs: inlinehint nounwind uwtable
declare zeroext i1 @bitset_container_contains(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass