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

@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.116 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__.test_bitset_to_run = external hidden unnamed_addr constant [26 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 void @roaring_bitmap_free(ptr noundef) #1

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

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

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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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

; Function Attrs: nounwind uwtable
declare hidden i32 @array_equals(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #5

declare zeroext i1 @roaring_bitmap_run_optimize(ptr noundef) #1

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #6

; Function Attrs: nounwind uwtable
declare hidden ptr @make_roaring_from_array(ptr noundef, i32 noundef) #5

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

8:                                                ; preds = %24, %0
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = icmp ult i32 %9, 50000
  br i1 %10, label %12, label %11

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

12:                                               ; preds = %8
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = icmp ne i32 %13, 300
  br i1 %14, label %15, label %23

15:                                               ; preds = %12
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = add i32 65536, %16
  %18 = load ptr, ptr %2, align 8, !tbaa !9
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %1, align 4, !tbaa !5
  %21 = sext i32 %19 to i64
  %22 = getelementptr inbounds i32, ptr %18, i64 %21
  store i32 %17, ptr %22, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %15, %12
  br label %24

24:                                               ; preds = %23
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = add i32 %25, 1
  store i32 %26, ptr %3, align 4, !tbaa !5
  br label %8, !llvm.loop !11

27:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %28 = load ptr, ptr %2, align 8, !tbaa !9
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = call ptr @make_roaring_from_array(ptr noundef %28, i32 noundef %29)
  store ptr %30, ptr %4, align 8, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = call zeroext i1 @roaring_bitmap_run_optimize(ptr noundef %31)
  br i1 %32, label %33, label %34

33:                                               ; preds = %27
  br label %35

34:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str.116, ptr noundef @.str.2, i32 noundef 2441, ptr noundef @__PRETTY_FUNCTION__.test_bitset_to_run) #9
  unreachable

35:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %36 = load ptr, ptr %4, align 8, !tbaa !9
  %37 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %36)
  store i64 %37, ptr %5, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %38 = load i64, ptr %5, align 8, !tbaa !13
  %39 = mul i64 %38, 4
  %40 = call noalias ptr @malloc(i64 noundef %39) #10
  store ptr %40, ptr %6, align 8, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  call void @roaring_bitmap_to_uint32_array(ptr noundef %41, ptr noundef %42)
  %43 = load ptr, ptr %6, align 8, !tbaa !9
  %44 = load i64, ptr %5, align 8, !tbaa !13
  %45 = trunc i64 %44 to i32
  %46 = load ptr, ptr %2, align 8, !tbaa !9
  %47 = load i32, ptr %1, align 4, !tbaa !5
  %48 = call i32 @array_equals(ptr noundef %43, i32 noundef %45, ptr noundef %46, i32 noundef %47)
  %49 = sext i32 %48 to i64
  call void @_assert_true(i64 noundef %49, ptr noundef @.str.115, ptr noundef @.str.2, i32 noundef 2447)
  %50 = load ptr, ptr %4, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %50)
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %51) #7
  %52 = load ptr, ptr %2, align 8, !tbaa !9
  call void @free(ptr noundef %52) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #7
  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 allocsize(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 "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 #5 = { 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 #6 = { nounwind allocsize(0,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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind allocsize(0) }

!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 = !{!14, !14, i64 0}
!14 = !{!"long", !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"

@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.116 = external hidden unnamed_addr constant [32 x i8], align 1
@__PRETTY_FUNCTION__.test_bitset_to_run = external hidden unnamed_addr constant [26 x i8], align 1

declare void @roaring_bitmap_free(ptr noundef) local_unnamed_addr #0

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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden i32 @array_equals(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare zeroext i1 @roaring_bitmap_run_optimize(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden ptr @make_roaring_from_array(ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @test_bitset_to_run() local_unnamed_addr #4 {
  %1 = tail call noalias dereferenceable_or_null(400000) ptr @calloc(i64 noundef 100000, i64 noundef 4) #6
  br label %5

2:                                                ; preds = %11
  %3 = tail call ptr @make_roaring_from_array(ptr noundef %1, i32 noundef %13)
  %4 = tail call zeroext i1 @roaring_bitmap_run_optimize(ptr noundef %3) #7
  br i1 %4, label %18, label %17

5:                                                ; preds = %11, %0
  %.021 = phi i32 [ 0, %0 ], [ %13, %11 ]
  %.01920 = phi i32 [ 0, %0 ], [ %16, %11 ]
  %.not = icmp eq i32 %.01920, 300
  br i1 %.not, label %11, label %6

6:                                                ; preds = %5
  %7 = or disjoint i32 %.01920, 65536
  %8 = add nsw i32 %.021, 1
  %9 = sext i32 %.021 to i64
  %10 = getelementptr inbounds i32, ptr %1, i64 %9
  store i32 %7, ptr %10, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %6, %5
  %.1 = phi i32 [ %8, %6 ], [ %.021, %5 ]
  %12 = or i32 %.01920, 65537
  %13 = add nsw i32 %.1, 1
  %14 = sext i32 %.1 to i64
  %15 = getelementptr inbounds i32, ptr %1, i64 %14
  store i32 %12, ptr %15, align 4, !tbaa !5
  %16 = add nuw nsw i32 %.01920, 2
  %exitcond.not.1 = icmp eq i32 %16, 50000
  br i1 %exitcond.not.1, label %2, label %5, !llvm.loop !9

17:                                               ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.116, ptr noundef nonnull @.str.2, i32 noundef 2441, ptr noundef nonnull @__PRETTY_FUNCTION__.test_bitset_to_run) #8
  unreachable

18:                                               ; preds = %2
  %19 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %3) #7
  %20 = shl i64 %19, 2
  %21 = tail call noalias ptr @malloc(i64 noundef %20) #9
  tail call void @roaring_bitmap_to_uint32_array(ptr noundef %3, ptr noundef %21) #7
  %22 = trunc i64 %19 to i32
  %23 = tail call i32 @array_equals(ptr noundef %21, i32 noundef %22, ptr noundef %1, i32 noundef %13)
  %24 = sext i32 %23 to i64
  tail call void @_assert_true(i64 noundef %24, ptr noundef nonnull @.str.115, ptr noundef nonnull @.str.2, i32 noundef 2447) #7
  tail call void @roaring_bitmap_free(ptr noundef %3) #7
  tail call void @free(ptr noundef %21) #7
  tail call void @free(ptr noundef %1) #7
  ret void
}

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 = { 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 #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { nounwind allocsize(0,1) }
attributes #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind allocsize(0) }

!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"}


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