; LLVM IR from jermp/2i_bench :: external/CRoaring/tests (toplevel_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"

%struct.sbs_s = type { ptr, ptr, i32 }

@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [18 x i8], align 1
@__const.test_remove_many.values = external hidden unnamed_addr constant [8 x i32], align 16
@__const.test_remove_many.values.163 = external hidden unnamed_addr constant [8 x i32], align 16
@__const.test_remove_many.values.164 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.165 = external hidden unnamed_addr constant [56 x i8], align 1
@__PRETTY_FUNCTION__.test_remove_many = external hidden unnamed_addr constant [24 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

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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @sbs_create() #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_free(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_add_value(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_add_range(ptr noundef, i64 noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_remove_many(ptr noundef, i64 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @sbs_is_empty(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_compare(ptr noundef) #3

; 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) #4

; Function Attrs: nounwind uwtable
define dso_local void @test_remove_many() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca [8 x i32], align 16
  %3 = alloca ptr, align 8
  %4 = alloca [8 x i32], align 16
  %5 = alloca ptr, align 8
  %6 = alloca [2 x i32], align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  %9 = call ptr @sbs_create()
  store ptr %9, ptr %1, align 8, !tbaa !5
  %10 = load ptr, ptr %1, align 8, !tbaa !5
  call void @sbs_add_range(ptr noundef %10, i64 noundef 0, i64 noundef 131071)
  call void @llvm.lifetime.start.p0(i64 32, ptr %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_remove_many.values, i64 32, i1 false)
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = getelementptr inbounds [8 x i32], ptr %2, i64 0, i64 0
  call void @sbs_remove_many(ptr noundef %11, i64 noundef 8, ptr noundef %12)
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  call void @sbs_compare(ptr noundef %13)
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  call void @sbs_free(ptr noundef %14)
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %15 = call ptr @sbs_create()
  store ptr %15, ptr %3, align 8, !tbaa !5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  call void @sbs_add_range(ptr noundef %16, i64 noundef 0, i64 noundef 131071)
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %4, ptr align 16 @__const.test_remove_many.values.163, i64 32, i1 false)
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds [8 x i32], ptr %4, i64 0, i64 0
  call void @sbs_remove_many(ptr noundef %17, i64 noundef 8, ptr noundef %18)
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  call void @sbs_compare(ptr noundef %19)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  call void @sbs_free(ptr noundef %20)
  call void @llvm.lifetime.end.p0(i64 32, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %21 = call ptr @sbs_create()
  store ptr %21, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  call void @sbs_add_value(ptr noundef %22, i32 noundef 500)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 @__const.test_remove_many.values.164, i64 8, i1 false)
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 0
  call void @sbs_remove_many(ptr noundef %23, i64 noundef 2, ptr noundef %24)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  call void @sbs_remove_many(ptr noundef %25, i64 noundef 0, ptr noundef null)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  call void @sbs_compare(ptr noundef %26)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  call void @sbs_free(ptr noundef %27)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %28 = call ptr @sbs_create()
  store ptr %28, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sbs_add_range(ptr noundef %29, i64 noundef 0, i64 noundef 65535)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %47, %0
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = icmp ule i32 %31, 65535
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %50

34:                                               ; preds = %30
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sbs_remove_many(ptr noundef %35, i64 noundef 1, ptr noundef %8)
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.sbs_s, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %38)
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = sub i32 65535, %40
  %42 = zext i32 %41 to i64
  %43 = icmp eq i64 %39, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %34
  br label %46

45:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.165, ptr noundef @.str.2, i32 noundef 3896, ptr noundef @__PRETTY_FUNCTION__.test_remove_many) #6
  unreachable

46:                                               ; preds = %44
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = add i32 %48, 1
  store i32 %49, ptr %8, align 4, !tbaa !9
  br label %30, !llvm.loop !13

50:                                               ; preds = %33
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = call zeroext i1 @sbs_is_empty(ptr noundef %51)
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  br label %55

54:                                               ; preds = %50
  call void @__assert_fail(ptr noundef @.str.162, ptr noundef @.str.2, i32 noundef 3898, ptr noundef @__PRETTY_FUNCTION__.test_remove_many) #6
  unreachable

55:                                               ; preds = %53
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  call void @sbs_free(ptr noundef %56)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

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 = { noreturn nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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, !6, i64 0}
!12 = !{!"sbs_s", !6, i64 0, !6, i64 8, !10, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.162 = external hidden unnamed_addr constant [18 x i8], align 1
@__const.test_remove_many.values = external hidden unnamed_addr constant [8 x i32], align 16
@__const.test_remove_many.values.163 = external hidden unnamed_addr constant [8 x i32], align 16
@__const.test_remove_many.values.164 = external hidden unnamed_addr constant [2 x i32], align 4
@.str.165 = external hidden unnamed_addr constant [56 x i8], align 1
@__PRETTY_FUNCTION__.test_remove_many = external hidden unnamed_addr constant [24 x i8], align 1

; 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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @sbs_create() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_free(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_add_value(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_add_range(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_remove_many(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @sbs_is_empty(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @sbs_compare(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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) #4

; Function Attrs: nounwind uwtable
define dso_local void @test_remove_many() local_unnamed_addr #3 {
  %1 = alloca [8 x i32], align 16
  %2 = alloca [8 x i32], align 16
  %3 = alloca [2 x i32], align 8
  %4 = alloca i32, align 4
  %5 = tail call ptr @sbs_create()
  tail call void @sbs_add_range(ptr noundef %5, i64 noundef 0, i64 noundef 131071)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %1, ptr noundef nonnull align 16 dereferenceable(32) @__const.test_remove_many.values, i64 32, i1 false)
  call void @sbs_remove_many(ptr noundef %5, i64 noundef 8, ptr noundef nonnull %1)
  call void @sbs_compare(ptr noundef %5)
  call void @sbs_free(ptr noundef %5)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #5
  %6 = call ptr @sbs_create()
  call void @sbs_add_range(ptr noundef %6, i64 noundef 0, i64 noundef 131071)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %2, ptr noundef nonnull align 16 dereferenceable(32) @__const.test_remove_many.values.163, i64 32, i1 false)
  call void @sbs_remove_many(ptr noundef %6, i64 noundef 8, ptr noundef nonnull %2)
  call void @sbs_compare(ptr noundef %6)
  call void @sbs_free(ptr noundef %6)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #5
  %7 = call ptr @sbs_create()
  call void @sbs_add_value(ptr noundef %7, i32 noundef 500)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %8 = load i64, ptr @__const.test_remove_many.values.164, align 4
  store i64 %8, ptr %3, align 8
  call void @sbs_remove_many(ptr noundef %7, i64 noundef 2, ptr noundef nonnull %3)
  call void @sbs_remove_many(ptr noundef %7, i64 noundef 0, ptr noundef null)
  call void @sbs_compare(ptr noundef %7)
  call void @sbs_free(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %9 = call ptr @sbs_create()
  call void @sbs_add_range(ptr noundef %9, i64 noundef 0, i64 noundef 65535)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %15

10:                                               ; preds = %15
  %11 = add i32 %18, 1
  store i32 %11, ptr %4, align 4, !tbaa !5
  %12 = icmp ult i32 %11, 65536
  br i1 %12, label %15, label %13, !llvm.loop !9

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  %14 = call zeroext i1 @sbs_is_empty(ptr noundef nonnull %9)
  br i1 %14, label %24, label %23

15:                                               ; preds = %0, %10
  call void @sbs_remove_many(ptr noundef %9, i64 noundef 1, ptr noundef nonnull %4)
  %16 = load ptr, ptr %9, align 8, !tbaa !11
  %17 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %16) #5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = sub i32 65535, %18
  %20 = zext i32 %19 to i64
  %21 = icmp eq i64 %17, %20
  br i1 %21, label %10, label %22

22:                                               ; preds = %15
  call void @__assert_fail(ptr noundef nonnull @.str.165, ptr noundef nonnull @.str.2, i32 noundef 3896, ptr noundef nonnull @__PRETTY_FUNCTION__.test_remove_many) #6
  unreachable

23:                                               ; preds = %13
  call void @__assert_fail(ptr noundef nonnull @.str.162, ptr noundef nonnull @.str.2, i32 noundef 3898, ptr noundef nonnull @__PRETTY_FUNCTION__.test_remove_many) #6
  unreachable

24:                                               ; preds = %13
  call void @sbs_free(ptr noundef nonnull %9)
  ret void
}

attributes #0 = { mustprogress 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 = { noreturn nounwind "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { noreturn 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !13, i64 0}
!12 = !{!"sbs_s", !13, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass