; 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_intersection_bitset_x_bitset_inplace = external hidden unnamed_addr constant [49 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 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 void @_assert_int_equal(i64 noundef, i64 noundef, ptr noundef, i32 noundef) #1

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

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

7:                                                ; preds = %0
  br label %9

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

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

13:                                               ; preds = %9
  br label %15

14:                                               ; preds = %9
  call void @__assert_fail(ptr noundef @.str.48, ptr noundef @.str.2, i32 noundef 1418, ptr noundef @__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset_inplace) #5
  unreachable

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

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

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %59

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

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

59:                                               ; preds = %19
  %60 = load ptr, ptr %1, align 8, !tbaa !5
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  call void @roaring_bitmap_and_inplace(ptr noundef %60, ptr noundef %61)
  %62 = load ptr, ptr %1, align 8, !tbaa !5
  %63 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %62)
  call void @_assert_int_equal(i64 noundef %63, i64 noundef 26666, ptr noundef @.str.2, i32 noundef 1434)
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %64)
  %65 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %65)
  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
@__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset_inplace = external hidden unnamed_addr constant [49 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 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 void @_assert_int_equal(i64 noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @test_intersection_bitset_x_bitset_inplace() 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 1416, ptr noundef nonnull @__PRETTY_FUNCTION__.test_intersection_bitset_x_bitset_inplace) #4
  unreachable

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

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

6:                                                ; preds = %.preheader
  tail call void @roaring_bitmap_and_inplace(ptr noundef nonnull %1, ptr noundef nonnull %4) #3
  %7 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %1) #3
  tail call void @_assert_int_equal(i64 noundef %7, i64 noundef 26666, ptr noundef nonnull @.str.2, i32 noundef 1434) #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 ]
  %8 = shl nuw nsw i64 %indvars.iv, 1
  %9 = trunc nuw nsw i64 %8 to i32
  tail call void @roaring_bitmap_add(ptr noundef nonnull %1, i32 noundef %9) #3
  %10 = mul nuw nsw i64 %indvars.iv, 3
  %11 = trunc nuw nsw i64 %10 to i32
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %11) #3
  %12 = trunc i64 %10 to i32
  %13 = add i32 %12, 1
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %13) #3
  %14 = trunc i64 %8 to i32
  %15 = or i32 %14, 327680
  tail call void @roaring_bitmap_add(ptr noundef nonnull %1, i32 noundef %15) #3
  %16 = trunc i64 %10 to i32
  %17 = add i32 %16, 327680
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %17) #3
  %18 = trunc i64 %10 to i32
  %19 = add i32 %18, 327681
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %19) #3
  %20 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %1) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = shl nuw nsw i64 %indvars.iv.next, 1
  tail call void @_assert_int_equal(i64 noundef %20, i64 noundef %21, ptr noundef nonnull @.str.2, i32 noundef 1428) #3
  %22 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %4) #3
  %23 = shl nuw nsw i64 %indvars.iv.next, 2
  tail call void @_assert_int_equal(i64 noundef %22, i64 noundef %23, ptr noundef nonnull @.str.2, i32 noundef 1429) #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