; 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

; 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

; Function Attrs: inlinehint nounwind uwtable
declare zeroext i1 @roaring_bitmap_contains(ptr noundef, i32 noundef) #2

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

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_contains() #3 {
  %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) #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 = ptrtoint ptr %5 to i64
  call void @_assert_true(i64 noundef %6, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 1272)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %7

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

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %27

11:                                               ; preds = %7
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %12)
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = zext i32 %14 to i64
  call void @_assert_int_equal(i64 noundef %13, i64 noundef %15, ptr noundef @.str.2, i32 noundef 1275)
  %16 = load ptr, ptr %1, align 8, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !9
  %18 = mul i32 200, %17
  call void @roaring_bitmap_add(ptr noundef %16, i32 noundef %18)
  %19 = load ptr, ptr %1, align 8, !tbaa !5
  %20 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %19)
  %21 = load i32, ptr %2, align 4, !tbaa !9
  %22 = add i32 %21, 1
  %23 = zext i32 %22 to i64
  call void @_assert_int_equal(i64 noundef %20, i64 noundef %23, ptr noundef @.str.2, i32 noundef 1277)
  br label %24

24:                                               ; preds = %11
  %25 = load i32, ptr %2, align 4, !tbaa !9
  %26 = add i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !9
  br label %7, !llvm.loop !11

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

28:                                               ; preds = %42, %27
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = icmp ult i32 %29, 2000000
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %45

32:                                               ; preds = %28
  %33 = load ptr, ptr %1, align 8, !tbaa !5
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = call zeroext i1 @roaring_bitmap_contains(ptr noundef %33, i32 noundef %34)
  %36 = zext i1 %35 to i64
  %37 = load i32, ptr %3, align 4, !tbaa !9
  %38 = urem i32 %37, 200
  %39 = icmp eq i32 %38, 0
  %40 = zext i1 %39 to i32
  %41 = sext i32 %40 to i64
  call void @_assert_int_equal(i64 noundef %36, i64 noundef %41, ptr noundef @.str.2, i32 noundef 1281)
  br label %42

42:                                               ; preds = %32
  %43 = load i32, ptr %3, align 4, !tbaa !9
  %44 = add i32 %43, 1
  store i32 %44, ptr %3, align 4, !tbaa !9
  br label %28, !llvm.loop !13

45:                                               ; preds = %31
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %46)
  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 = { inlinehint 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 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 }

!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.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [3 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

; Function Attrs: inlinehint nounwind uwtable
declare zeroext i1 @roaring_bitmap_contains(ptr noundef, i32 noundef) local_unnamed_addr #1

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

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_contains() local_unnamed_addr #2 {
  %1 = tail call ptr @roaring_bitmap_create() #3
  %2 = ptrtoint ptr %1 to i64
  tail call void @_assert_true(i64 noundef %2, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 1272) #3
  br label %3

3:                                                ; preds = %0, %3
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %3 ]
  %4 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %1) #3
  tail call void @_assert_int_equal(i64 noundef %4, i64 noundef %indvars.iv, ptr noundef nonnull @.str.2, i32 noundef 1275) #3
  %5 = trunc i64 %indvars.iv to i32
  %6 = mul i32 %5, 200
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef %6) #3
  %7 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %1) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  tail call void @_assert_int_equal(i64 noundef %7, i64 noundef %indvars.iv.next, ptr noundef nonnull @.str.2, i32 noundef 1277) #3
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10000
  br i1 %exitcond.not, label %.preheader, label %3, !llvm.loop !5

8:                                                ; preds = %.preheader
  tail call void @roaring_bitmap_free(ptr noundef %1) #3
  ret void

.preheader:                                       ; preds = %3, %.preheader
  %.016 = phi i32 [ %14, %.preheader ], [ 0, %3 ]
  %9 = tail call zeroext i1 @roaring_bitmap_contains(ptr noundef %1, i32 noundef %.016)
  %10 = zext i1 %9 to i64
  %11 = urem i32 %.016, 200
  %12 = icmp eq i32 %11, 0
  %13 = zext i1 %12 to i64
  tail call void @_assert_int_equal(i64 noundef %10, i64 noundef %13, ptr noundef nonnull @.str.2, i32 noundef 1281) #3
  %14 = add nuw nsw i32 %.016, 1
  %exitcond18.not = icmp eq i32 %14, 2000000
  br i1 %exitcond18.not, label %8, label %.preheader, !llvm.loop !7
}

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 = { inlinehint 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 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 = 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