; 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_array_x_array_inplace = external hidden unnamed_addr constant [47 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

; Function Attrs: nounwind uwtable
define dso_local void @test_intersection_array_x_array_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 1361, ptr noundef @__PRETTY_FUNCTION__.test_intersection_array_x_array_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 1363, ptr noundef @__PRETTY_FUNCTION__.test_intersection_array_x_array_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 = %47, %15
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = icmp ult i32 %17, 100
  br i1 %18, label %20, label %19

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

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 %1, align 8, !tbaa !5
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = mul i32 2, %28
  %30 = add i32 327680, %29
  call void @roaring_bitmap_add(ptr noundef %27, i32 noundef %30)
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !9
  %33 = mul i32 3, %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 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %35)
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = add i32 %37, 1
  %39 = mul i32 2, %38
  %40 = zext i32 %39 to i64
  call void @_assert_int_equal(i64 noundef %36, i64 noundef %40, ptr noundef @.str.2, i32 noundef 1371)
  %41 = load ptr, ptr %1, align 8, !tbaa !5
  %42 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %41)
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = add i32 %43, 1
  %45 = mul i32 2, %44
  %46 = zext i32 %45 to i64
  call void @_assert_int_equal(i64 noundef %42, i64 noundef %46, ptr noundef @.str.2, i32 noundef 1372)
  br label %47

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

50:                                               ; preds = %19
  %51 = load ptr, ptr %1, align 8, !tbaa !5
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  call void @roaring_bitmap_and_inplace(ptr noundef %51, ptr noundef %52)
  %53 = load ptr, ptr %1, align 8, !tbaa !5
  %54 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %53)
  call void @_assert_int_equal(i64 noundef %54, i64 noundef 68, ptr noundef @.str.2, i32 noundef 1376)
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %55)
  %56 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %56)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

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

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_array_x_array_inplace = external hidden unnamed_addr constant [47 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

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

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

5:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.48, ptr noundef nonnull @.str.2, i32 noundef 1363, ptr noundef nonnull @__PRETTY_FUNCTION__.test_intersection_array_x_array_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 68, ptr noundef nonnull @.str.2, i32 noundef 1376) #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 %8 to i32
  %13 = or i32 %12, 327680
  tail call void @roaring_bitmap_add(ptr noundef nonnull %1, i32 noundef %13) #3
  %14 = trunc i64 %10 to i32
  %15 = or i32 %14, 327680
  tail call void @roaring_bitmap_add(ptr noundef nonnull %4, i32 noundef %15) #3
  %16 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %4) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = shl nuw nsw i64 %indvars.iv.next, 1
  tail call void @_assert_int_equal(i64 noundef %16, i64 noundef %17, ptr noundef nonnull @.str.2, i32 noundef 1371) #3
  %18 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef nonnull %1) #3
  tail call void @_assert_int_equal(i64 noundef %18, i64 noundef %17, ptr noundef nonnull @.str.2, i32 noundef 1372) #3
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100
  br i1 %exitcond.not, label %6, label %.preheader, !llvm.loop !5
}

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

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