; 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
@.str.93 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset = external hidden unnamed_addr constant [41 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_intersection_bitset_x_bitset() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %5 = call ptr @roaring_bitmap_create()
  store ptr %5, ptr %1, align 8, !tbaa !5
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %0
  br label %10

9:                                                ; preds = %0
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 1384, ptr noundef @__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset) #5
  unreachable

10:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %11 = call ptr @roaring_bitmap_create()
  store ptr %11, ptr %2, align 8, !tbaa !5
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %10
  br label %16

15:                                               ; preds = %10
  call void @__assert_fail(ptr noundef @.str.48, ptr noundef @.str.2, i32 noundef 1386, ptr noundef @__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset) #5
  unreachable

16:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %57, %16
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = icmp ult i32 %18, 20000
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %60

21:                                               ; preds = %17
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = mul i32 2, %23
  call void @roaring_bitmap_add(ptr noundef %22, i32 noundef %24)
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = mul i32 3, %26
  call void @roaring_bitmap_add(ptr noundef %25, i32 noundef %27)
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = mul i32 3, %29
  %31 = add i32 %30, 1
  call void @roaring_bitmap_add(ptr noundef %28, i32 noundef %31)
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = load i32, ptr %3, align 4, !tbaa !9
  %34 = mul i32 2, %33
  %35 = add i32 327680, %34
  call void @roaring_bitmap_add(ptr noundef %32, i32 noundef %35)
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = mul i32 3, %37
  %39 = add i32 327680, %38
  call void @roaring_bitmap_add(ptr noundef %36, i32 noundef %39)
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load i32, ptr %3, align 4, !tbaa !9
  %42 = mul i32 3, %41
  %43 = add i32 327680, %42
  %44 = add i32 %43, 1
  call void @roaring_bitmap_add(ptr noundef %40, i32 noundef %44)
  %45 = load ptr, ptr %1, align 8, !tbaa !5
  %46 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %45)
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = add i32 %47, 1
  %49 = mul i32 2, %48
  %50 = zext i32 %49 to i64
  call void @_assert_int_equal(i64 noundef %46, i64 noundef %50, ptr noundef @.str.2, i32 noundef 1396)
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %51)
  %53 = load i32, ptr %3, align 4, !tbaa !9
  %54 = add i32 %53, 1
  %55 = mul i32 4, %54
  %56 = zext i32 %55 to i64
  call void @_assert_int_equal(i64 noundef %52, i64 noundef %56, ptr noundef @.str.2, i32 noundef 1397)
  br label %57

57:                                               ; preds = %21
  %58 = load i32, ptr %3, align 4, !tbaa !9
  %59 = add i32 %58, 1
  store i32 %59, ptr %3, align 4, !tbaa !9
  br label %17, !llvm.loop !11

60:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %61 = load ptr, ptr %1, align 8, !tbaa !5
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = call ptr @roaring_bitmap_and(ptr noundef %61, ptr noundef %62)
  store ptr %63, ptr %4, align 8, !tbaa !5
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %64)
  %66 = load ptr, ptr %1, align 8, !tbaa !5
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = call i64 @roaring_bitmap_and_cardinality(ptr noundef %66, ptr noundef %67)
  %69 = icmp eq i64 %65, %68
  %70 = zext i1 %69 to i32
  %71 = sext i32 %70 to i64
  call void @_assert_true(i64 noundef %71, ptr noundef @.str.93, ptr noundef @.str.2, i32 noundef 1402)
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = ptrtoint ptr %72 to i64
  call void @_assert_true(i64 noundef %73, ptr noundef @.str.94, ptr noundef @.str.2, i32 noundef 1404)
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %74)
  call void @_assert_int_equal(i64 noundef %75, i64 noundef 26666, ptr noundef @.str.2, i32 noundef 1407)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %76)
  %77 = load ptr, ptr %2, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %77)
  %78 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %78)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  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 = { 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 = !{!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 = distinct !{!11, !12}
!12 = !{!"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
@.str.93 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.94 = external hidden unnamed_addr constant [10 x i8], align 1
@__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset = external hidden unnamed_addr constant [41 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

declare ptr @roaring_bitmap_and(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_and_cardinality(ptr noundef, ptr noundef) local_unnamed_addr #0

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

2:                                                ; preds = %0
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 1384, ptr noundef nonnull @__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset) #4
  unreachable

3:                                                ; preds = %0
  %4 = tail call ptr @roaring_bitmap_create() #3
  %.not31 = icmp eq ptr %4, null
  br i1 %.not31, label %5, label %.preheader

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

6:                                                ; preds = %.preheader
  %7 = tail call ptr @roaring_bitmap_and(ptr noundef nonnull %1, ptr noundef nonnull %4) #3
  %8 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %7) #3
  %9 = tail call i64 @roaring_bitmap_and_cardinality(ptr noundef nonnull %1, ptr noundef nonnull %4) #3
  %10 = icmp eq i64 %8, %9
  %11 = zext i1 %10 to i64
  tail call void @_assert_true(i64 noundef %11, ptr noundef nonnull @.str.93, ptr noundef nonnull @.str.2, i32 noundef 1402) #3
  %12 = ptrtoint ptr %7 to i64
  tail call void @_assert_true(i64 noundef %12, ptr noundef nonnull @.str.94, ptr noundef nonnull @.str.2, i32 noundef 1404) #3
  %13 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %7) #3
  tail call void @_assert_int_equal(i64 noundef %13, i64 noundef 26666, ptr noundef nonnull @.str.2, i32 noundef 1407) #3
  tail call void @roaring_bitmap_free(ptr noundef %7) #3
  tail call void @roaring_bitmap_free(ptr noundef nonnull %4) #3
  tail call void @roaring_bitmap_free(ptr noundef nonnull %1) #3
  ret void

.preheader:                                       ; preds = %3, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %3 ]
  %14 = shl nuw nsw i64 %indvars.iv, 1
  %15 = trunc nuw nsw i64 %14 to i32
  tail call void @roaring_bitmap_add(ptr noundef nonnull %1, i32 noundef %15) #3
  %16 = mul nuw nsw i64 %indvars.iv, 3
  %17 = trunc nuw nsw i64 %16 to i32
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %17) #3
  %18 = trunc i64 %16 to i32
  %19 = add i32 %18, 1
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %19) #3
  %20 = trunc i64 %14 to i32
  %21 = or i32 %20, 327680
  tail call void @roaring_bitmap_add(ptr noundef nonnull %1, i32 noundef %21) #3
  %22 = trunc i64 %16 to i32
  %23 = add i32 %22, 327680
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %23) #3
  %24 = trunc i64 %16 to i32
  %25 = add i32 %24, 327681
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %25) #3
  %26 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %1) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = shl nuw nsw i64 %indvars.iv.next, 1
  tail call void @_assert_int_equal(i64 noundef %26, i64 noundef %27, ptr noundef nonnull @.str.2, i32 noundef 1396) #3
  %28 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %4) #3
  %29 = shl nuw nsw i64 %indvars.iv.next, 2
  tail call void @_assert_int_equal(i64 noundef %28, i64 noundef %29, ptr noundef nonnull @.str.2, i32 noundef 1397) #3
  %exitcond.not = icmp eq i64 %indvars.iv.next, 20000
  br i1 %exitcond.not, label %6, 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 = { 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 = { 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 }
attributes #4 = { 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