; 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.23 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [3 x i8], align 1
@__PRETTY_FUNCTION__.test_union = external hidden unnamed_addr constant [23 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [82 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 ptr @roaring_bitmap_create() #1

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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

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

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

declare void @roaring_bitmap_add(ptr noundef, i32 noundef) #1

declare ptr @roaring_bitmap_or(ptr noundef, ptr noundef) #1

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

declare i64 @roaring_bitmap_or_cardinality(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_union(i1 noundef zeroext %0) #4 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = zext i1 %0 to i8
  store i8 %7, ptr %2, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %8 = call ptr @roaring_bitmap_create()
  store ptr %8, ptr %3, align 8, !tbaa !9
  %9 = load ptr, ptr %3, align 8, !tbaa !9
  %10 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %11 = trunc i8 %10 to i1
  call void @roaring_bitmap_set_copy_on_write(ptr noundef %9, i1 noundef zeroext %11)
  %12 = load ptr, ptr %3, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %1
  br label %16

15:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 1442, ptr noundef @__PRETTY_FUNCTION__.test_union) #6
  unreachable

16:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %17 = call ptr @roaring_bitmap_create()
  store ptr %17, ptr %4, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !9
  %19 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %20 = trunc i8 %19 to i1
  call void @roaring_bitmap_set_copy_on_write(ptr noundef %18, i1 noundef zeroext %20)
  %21 = load ptr, ptr %4, align 8, !tbaa !9
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %16
  br label %25

24:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.48, ptr noundef @.str.2, i32 noundef 1445, ptr noundef @__PRETTY_FUNCTION__.test_union) #6
  unreachable

25:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %26

26:                                               ; preds = %47, %25
  %27 = load i32, ptr %5, align 4, !tbaa !13
  %28 = icmp ult i32 %27, 100
  br i1 %28, label %30, label %29

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

30:                                               ; preds = %26
  %31 = load ptr, ptr %3, align 8, !tbaa !9
  %32 = load i32, ptr %5, align 4, !tbaa !13
  %33 = mul i32 2, %32
  call void @roaring_bitmap_add(ptr noundef %31, i32 noundef %33)
  %34 = load ptr, ptr %4, align 8, !tbaa !9
  %35 = load i32, ptr %5, align 4, !tbaa !13
  %36 = mul i32 3, %35
  call void @roaring_bitmap_add(ptr noundef %34, i32 noundef %36)
  %37 = load ptr, ptr %4, align 8, !tbaa !9
  %38 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %37)
  %39 = load i32, ptr %5, align 4, !tbaa !13
  %40 = add i32 %39, 1
  %41 = zext i32 %40 to i64
  call void @_assert_int_equal(i64 noundef %38, i64 noundef %41, ptr noundef @.str.2, i32 noundef 1450)
  %42 = load ptr, ptr %3, align 8, !tbaa !9
  %43 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %42)
  %44 = load i32, ptr %5, align 4, !tbaa !13
  %45 = add i32 %44, 1
  %46 = zext i32 %45 to i64
  call void @_assert_int_equal(i64 noundef %43, i64 noundef %46, ptr noundef @.str.2, i32 noundef 1451)
  br label %47

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

50:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %51 = load ptr, ptr %3, align 8, !tbaa !9
  %52 = load ptr, ptr %4, align 8, !tbaa !9
  %53 = call ptr @roaring_bitmap_or(ptr noundef %51, ptr noundef %52)
  store ptr %53, ptr %6, align 8, !tbaa !9
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  %55 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %54)
  %56 = load ptr, ptr %3, align 8, !tbaa !9
  %57 = load ptr, ptr %4, align 8, !tbaa !9
  %58 = call i64 @roaring_bitmap_or_cardinality(ptr noundef %56, ptr noundef %57)
  %59 = icmp eq i64 %55, %58
  %60 = zext i1 %59 to i32
  %61 = sext i32 %60 to i64
  call void @_assert_true(i64 noundef %61, ptr noundef @.str.95, ptr noundef @.str.2, i32 noundef 1456)
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = load i8, ptr %2, align 1, !tbaa !5, !range !11, !noundef !12
  %64 = trunc i8 %63 to i1
  call void @roaring_bitmap_set_copy_on_write(ptr noundef %62, i1 noundef zeroext %64)
  %65 = load ptr, ptr %6, align 8, !tbaa !9
  %66 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %65)
  call void @_assert_int_equal(i64 noundef %66, i64 noundef 166, ptr noundef @.str.2, i32 noundef 1459)
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %67)
  %68 = load ptr, ptr %4, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %68)
  %69 = load ptr, ptr %3, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %69)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #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 = { 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 = { 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 #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 = { 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 = !{!"_Bool", !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 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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.23 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [3 x i8], align 1
@__PRETTY_FUNCTION__.test_union = external hidden unnamed_addr constant [23 x i8], align 1
@.str.95 = external hidden unnamed_addr constant [82 x i8], align 1

declare void @roaring_bitmap_free(ptr noundef) local_unnamed_addr #0

declare ptr @roaring_bitmap_create() 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: inlinehint nounwind uwtable
declare void @roaring_bitmap_set_copy_on_write(ptr noundef, i1 noundef zeroext) local_unnamed_addr #1

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

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

declare ptr @roaring_bitmap_or(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_union(i1 noundef zeroext %0) local_unnamed_addr #3 {
  %2 = tail call ptr @roaring_bitmap_create() #4
  tail call void @roaring_bitmap_set_copy_on_write(ptr noundef %2, i1 noundef zeroext %0)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %3, label %4

3:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 1442, ptr noundef nonnull @__PRETTY_FUNCTION__.test_union) #5
  unreachable

4:                                                ; preds = %1
  %5 = tail call ptr @roaring_bitmap_create() #4
  tail call void @roaring_bitmap_set_copy_on_write(ptr noundef %5, i1 noundef zeroext %0)
  %.not28 = icmp eq ptr %5, null
  br i1 %.not28, label %6, label %.preheader

6:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.48, ptr noundef nonnull @.str.2, i32 noundef 1445, ptr noundef nonnull @__PRETTY_FUNCTION__.test_union) #5
  unreachable

7:                                                ; preds = %.preheader
  %8 = tail call ptr @roaring_bitmap_or(ptr noundef nonnull %2, ptr noundef nonnull %5) #4
  %9 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %8) #4
  %10 = tail call i64 @roaring_bitmap_or_cardinality(ptr noundef nonnull %2, ptr noundef nonnull %5) #4
  %11 = icmp eq i64 %9, %10
  %12 = zext i1 %11 to i64
  tail call void @_assert_true(i64 noundef %12, ptr noundef nonnull @.str.95, ptr noundef nonnull @.str.2, i32 noundef 1456) #4
  tail call void @roaring_bitmap_set_copy_on_write(ptr noundef %8, i1 noundef zeroext %0)
  %13 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %8) #4
  tail call void @_assert_int_equal(i64 noundef %13, i64 noundef 166, ptr noundef nonnull @.str.2, i32 noundef 1459) #4
  tail call void @roaring_bitmap_free(ptr noundef %8) #4
  tail call void @roaring_bitmap_free(ptr noundef nonnull %5) #4
  tail call void @roaring_bitmap_free(ptr noundef nonnull %2) #4
  ret void

.preheader:                                       ; preds = %4, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %4 ]
  %indvars.iv.tr = trunc i64 %indvars.iv to i32
  %14 = shl i32 %indvars.iv.tr, 1
  tail call void @roaring_bitmap_add(ptr noundef nonnull %2, i32 noundef %14) #4
  %15 = trunc i64 %indvars.iv to i32
  %16 = mul i32 %15, 3
  tail call void @roaring_bitmap_add(ptr noundef nonnull %5, i32 noundef %16) #4
  %17 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %5) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  tail call void @_assert_int_equal(i64 noundef %17, i64 noundef %indvars.iv.next, ptr noundef nonnull @.str.2, i32 noundef 1450) #4
  %18 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %2) #4
  tail call void @_assert_int_equal(i64 noundef %18, i64 noundef %indvars.iv.next, ptr noundef nonnull @.str.2, i32 noundef 1451) #4
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100
  br i1 %exitcond.not, label %7, label %.preheader, !llvm.loop !5
}

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass