; 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.87 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.88 = external hidden unnamed_addr constant [39 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 void @roaring_bitmap_add(ptr noundef, i32 noundef) #1

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

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

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

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

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

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

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

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

21:                                               ; preds = %17
  %22 = load ptr, ptr %1, align 8, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = mul i32 %23, 3533
  %25 = call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %22, i32 noundef %24)
  %26 = zext i1 %25 to i64
  call void @_assert_true(i64 noundef %26, ptr noundef @.str.87, ptr noundef @.str.2, i32 noundef 1260)
  %27 = load ptr, ptr %1, align 8, !tbaa !5
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = mul i32 %28, 3533
  %30 = call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %27, i32 noundef %29)
  %31 = xor i1 %30, true
  %32 = zext i1 %31 to i32
  %33 = sext i32 %32 to i64
  call void @_assert_true(i64 noundef %33, ptr noundef @.str.87, ptr noundef @.str.2, i32 noundef 1261)
  br label %34

34:                                               ; preds = %21
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = add i32 %35, 1
  store i32 %36, ptr %3, align 4, !tbaa !9
  br label %17, !llvm.loop !13

37:                                               ; preds = %20
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  %39 = call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %38, i32 noundef 999)
  %40 = xor i1 %39, true
  %41 = zext i1 %40 to i32
  %42 = sext i32 %41 to i64
  call void @_assert_true(i64 noundef %42, ptr noundef @.str.88, ptr noundef @.str.2, i32 noundef 1263)
  %43 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_add(ptr noundef %43, i32 noundef 999)
  %44 = load ptr, ptr %1, align 8, !tbaa !5
  %45 = call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %44, i32 noundef 999)
  %46 = zext i1 %45 to i64
  call void @_assert_true(i64 noundef %46, ptr noundef @.str.88, ptr noundef @.str.2, i32 noundef 1265)
  %47 = load ptr, ptr %1, align 8, !tbaa !5
  %48 = call zeroext i1 @roaring_bitmap_is_empty(ptr noundef %47)
  %49 = zext i1 %48 to i64
  call void @_assert_true(i64 noundef %49, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 1266)
  %50 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %50)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

declare zeroext i1 @roaring_bitmap_remove_checked(ptr noundef, i32 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 = distinct !{!13, !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.87 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.88 = external hidden unnamed_addr constant [39 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 void @roaring_bitmap_add(ptr noundef, i32 noundef) local_unnamed_addr #0

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

2:                                                ; preds = %0, %2
  %.01415 = phi i32 [ 0, %0 ], [ %4, %2 ]
  %3 = mul nuw nsw i32 %.01415, 3533
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef %3) #2
  %4 = add nuw nsw i32 %.01415, 1
  %exitcond.not = icmp eq i32 %4, 125
  br i1 %exitcond.not, label %.preheader, label %2, !llvm.loop !5

5:                                                ; preds = %.preheader
  %6 = tail call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %1, i32 noundef 999) #2
  %7 = xor i1 %6, true
  %8 = zext i1 %7 to i64
  tail call void @_assert_true(i64 noundef %8, ptr noundef nonnull @.str.88, ptr noundef nonnull @.str.2, i32 noundef 1263) #2
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef 999) #2
  %9 = tail call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %1, i32 noundef 999) #2
  %10 = zext i1 %9 to i64
  tail call void @_assert_true(i64 noundef %10, ptr noundef nonnull @.str.88, ptr noundef nonnull @.str.2, i32 noundef 1265) #2
  %11 = tail call zeroext i1 @roaring_bitmap_is_empty(ptr noundef %1) #2
  %12 = zext i1 %11 to i64
  tail call void @_assert_true(i64 noundef %12, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 1266) #2
  tail call void @roaring_bitmap_free(ptr noundef %1) #2
  ret void

.preheader:                                       ; preds = %2, %.preheader
  %.016 = phi i32 [ %19, %.preheader ], [ 0, %2 ]
  %13 = mul nuw nsw i32 %.016, 3533
  %14 = tail call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %1, i32 noundef %13) #2
  %15 = zext i1 %14 to i64
  tail call void @_assert_true(i64 noundef %15, ptr noundef nonnull @.str.87, ptr noundef nonnull @.str.2, i32 noundef 1260) #2
  %16 = tail call zeroext i1 @roaring_bitmap_remove_checked(ptr noundef %1, i32 noundef %13) #2
  %17 = xor i1 %16, true
  %18 = zext i1 %17 to i64
  tail call void @_assert_true(i64 noundef %18, ptr noundef nonnull @.str.87, ptr noundef nonnull @.str.2, i32 noundef 1261) #2
  %19 = add nuw nsw i32 %.016, 1
  %exitcond17.not = icmp eq i32 %19, 125
  br i1 %exitcond17.not, label %5, label %.preheader, !llvm.loop !7
}

declare zeroext i1 @roaring_bitmap_remove_checked(ptr noundef, i32 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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass