; 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.1 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [52 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 zeroext i1 @roaring_bitmap_is_empty(ptr noundef) #1

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

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

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

6:                                                ; preds = %13, %0
  %7 = load i32, ptr %2, align 4, !tbaa !9
  %8 = icmp ult i32 %7, 147849
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = load ptr, ptr %1, align 8, !tbaa !5
  %12 = load i32, ptr %2, align 4, !tbaa !9
  call void @roaring_bitmap_add(ptr noundef %11, i32 noundef %12)
  br label %13

13:                                               ; preds = %10
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = add i32 %14, 8
  store i32 %15, ptr %2, align 4, !tbaa !9
  br label %6, !llvm.loop !11

16:                                               ; preds = %9
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_clear(ptr noundef %17)
  %18 = load ptr, ptr %1, align 8, !tbaa !5
  %19 = call zeroext i1 @roaring_bitmap_is_empty(ptr noundef %18)
  %20 = zext i1 %19 to i64
  call void @_assert_true(i64 noundef %20, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 807)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 33057, ptr %4, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %30, %16
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = icmp ult i32 %22, 147849
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %33

25:                                               ; preds = %21
  %26 = load ptr, ptr %1, align 8, !tbaa !5
  %27 = load i32, ptr %4, align 4, !tbaa !9
  call void @roaring_bitmap_add(ptr noundef %26, i32 noundef %27)
  %28 = load i64, ptr %3, align 8, !tbaa !13
  %29 = add i64 %28, 1
  store i64 %29, ptr %3, align 8, !tbaa !13
  br label %30

30:                                               ; preds = %25
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = add i32 %31, 8
  store i32 %32, ptr %4, align 4, !tbaa !9
  br label %21, !llvm.loop !15

33:                                               ; preds = %24
  %34 = load ptr, ptr %1, align 8, !tbaa !5
  %35 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %34)
  %36 = load i64, ptr %3, align 8, !tbaa !13
  %37 = icmp eq i64 %35, %36
  %38 = zext i1 %37 to i32
  %39 = sext i32 %38 to i64
  call void @_assert_true(i64 noundef %39, ptr noundef @.str.68, ptr noundef @.str.2, i32 noundef 813)
  %40 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_clear(ptr noundef %40)
  %41 = load ptr, ptr %1, align 8, !tbaa !5
  %42 = call zeroext i1 @roaring_bitmap_is_empty(ptr noundef %41)
  %43 = zext i1 %42 to i64
  call void @_assert_true(i64 noundef %43, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 815)
  %44 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %44)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

declare void @roaring_bitmap_clear(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 = { 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 }

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


; 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.1 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.68 = external hidden unnamed_addr constant [52 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 zeroext i1 @roaring_bitmap_is_empty(ptr noundef) local_unnamed_addr #0

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @test_clear() local_unnamed_addr #1 {
  %1 = tail call ptr @roaring_bitmap_create() #2
  br label %5

2:                                                ; preds = %5
  tail call void @roaring_bitmap_clear(ptr noundef %1) #2
  %3 = tail call zeroext i1 @roaring_bitmap_is_empty(ptr noundef %1) #2
  %4 = zext i1 %3 to i64
  tail call void @_assert_true(i64 noundef %4, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 807) #2
  br label %14

5:                                                ; preds = %0, %5
  %.01617 = phi i32 [ 33057, %0 ], [ %6, %5 ]
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef %.01617) #2
  %6 = add nuw nsw i32 %.01617, 8
  %7 = icmp ult i32 %.01617, 147841
  br i1 %7, label %5, label %2, !llvm.loop !5

8:                                                ; preds = %14
  %9 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %1) #2
  %10 = icmp eq i64 %9, 14349
  %11 = zext i1 %10 to i64
  tail call void @_assert_true(i64 noundef %11, ptr noundef nonnull @.str.68, ptr noundef nonnull @.str.2, i32 noundef 813) #2
  tail call void @roaring_bitmap_clear(ptr noundef %1) #2
  %12 = tail call zeroext i1 @roaring_bitmap_is_empty(ptr noundef %1) #2
  %13 = zext i1 %12 to i64
  tail call void @_assert_true(i64 noundef %13, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 815) #2
  tail call void @roaring_bitmap_free(ptr noundef %1) #2
  ret void

14:                                               ; preds = %2, %14
  %.019 = phi i32 [ 33057, %2 ], [ %16, %14 ]
  %.01518 = phi i64 [ 0, %2 ], [ %15, %14 ]
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef %.019) #2
  %15 = add nuw nsw i64 %.01518, 1
  %16 = add nuw nsw i32 %.019, 8
  %exitcond.not = icmp eq i64 %15, 14349
  br i1 %exitcond.not, label %8, label %14, !llvm.loop !7
}

declare void @roaring_bitmap_clear(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 = { 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 = { 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"}
!7 = distinct !{!7, !6}


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