; 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.39 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [64 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 zeroext i1 @roaring_bitmap_contains_range(ptr noundef, i64 noundef, i64 noundef) #1

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 i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare void @roaring_bitmap_add_range(ptr noundef, i64 noundef, i64 noundef) #2

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

4:                                                ; preds = %57, %0
  %5 = load i64, ptr %2, align 8, !tbaa !5
  %6 = icmp ult i64 %5, 1048576
  br i1 %6, label %8, label %7

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

8:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %9 = call ptr @roaring_bitmap_create()
  store ptr %9, ptr %3, align 8, !tbaa !9
  %10 = load ptr, ptr %3, align 8, !tbaa !9
  %11 = load i64, ptr %1, align 8, !tbaa !5
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %13 = sub i64 %11, %12
  %14 = load i64, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_add_range(ptr noundef %10, i64 noundef %13, i64 noundef %14)
  %15 = load ptr, ptr %3, align 8, !tbaa !9
  %16 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %15)
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = icmp eq i64 %16, %17
  %19 = zext i1 %18 to i32
  %20 = sext i32 %19 to i64
  call void @_assert_true(i64 noundef %20, ptr noundef @.str.39, ptr noundef @.str.2, i32 noundef 401)
  %21 = load i64, ptr %2, align 8, !tbaa !5
  %22 = icmp ugt i64 %21, 0
  br i1 %22, label %23, label %32

23:                                               ; preds = %8
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = load i64, ptr %1, align 8, !tbaa !5
  %26 = load i64, ptr %2, align 8, !tbaa !5
  %27 = sub i64 %25, %26
  %28 = load i64, ptr %1, align 8, !tbaa !5
  %29 = sub i64 %28, 1
  %30 = call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %24, i64 noundef %27, i64 noundef %29)
  %31 = zext i1 %30 to i64
  call void @_assert_true(i64 noundef %31, ptr noundef @.str.41, ptr noundef @.str.2, i32 noundef 403)
  br label %32

32:                                               ; preds = %23, %8
  %33 = load ptr, ptr %3, align 8, !tbaa !9
  %34 = load i64, ptr %1, align 8, !tbaa !5
  %35 = load i64, ptr %2, align 8, !tbaa !5
  %36 = sub i64 %34, %35
  %37 = load i64, ptr %1, align 8, !tbaa !5
  %38 = call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %33, i64 noundef %36, i64 noundef %37)
  %39 = zext i1 %38 to i64
  call void @_assert_true(i64 noundef %39, ptr noundef @.str.42, ptr noundef @.str.2, i32 noundef 405)
  %40 = load ptr, ptr %3, align 8, !tbaa !9
  %41 = load i64, ptr %1, align 8, !tbaa !5
  %42 = load i64, ptr %2, align 8, !tbaa !5
  %43 = sub i64 %41, %42
  %44 = sub i64 %43, 1
  %45 = load i64, ptr %1, align 8, !tbaa !5
  %46 = call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %40, i64 noundef %44, i64 noundef %45)
  %47 = xor i1 %46, true
  %48 = zext i1 %47 to i32
  %49 = sext i32 %48 to i64
  call void @_assert_true(i64 noundef %49, ptr noundef @.str.43, ptr noundef @.str.2, i32 noundef 406)
  %50 = load ptr, ptr %3, align 8, !tbaa !9
  %51 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %50)
  %52 = load i64, ptr %2, align 8, !tbaa !5
  %53 = icmp eq i64 %51, %52
  %54 = zext i1 %53 to i32
  %55 = sext i32 %54 to i64
  call void @_assert_true(i64 noundef %55, ptr noundef @.str.39, ptr noundef @.str.2, i32 noundef 407)
  %56 = load ptr, ptr %3, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %56)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %57

57:                                               ; preds = %32
  %58 = load i64, ptr %2, align 8, !tbaa !5
  %59 = add i64 %58, 1
  store i64 %59, ptr %2, align 8, !tbaa !5
  br label %4, !llvm.loop !11

60:                                               ; preds = %7
  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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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.39 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [64 x i8], align 1

declare zeroext i1 @roaring_bitmap_contains_range(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

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 i64 @roaring_bitmap_get_cardinality(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare void @roaring_bitmap_add_range(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @check_range_contains_from_end() local_unnamed_addr #2 {
.peel.next:
  %0 = tail call ptr @roaring_bitmap_create() #3
  tail call void @roaring_bitmap_add_range(ptr noundef %0, i64 noundef 4294967296, i64 noundef 4294967296)
  %1 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %0) #3
  %2 = icmp eq i64 %1, 0
  %3 = zext i1 %2 to i64
  tail call void @_assert_true(i64 noundef %3, ptr noundef nonnull @.str.39, ptr noundef nonnull @.str.2, i32 noundef 401) #3
  %4 = tail call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %0, i64 noundef 4294967296, i64 noundef 4294967296) #3
  %5 = zext i1 %4 to i64
  tail call void @_assert_true(i64 noundef %5, ptr noundef nonnull @.str.42, ptr noundef nonnull @.str.2, i32 noundef 405) #3
  %6 = tail call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %0, i64 noundef 4294967295, i64 noundef 4294967296) #3
  %7 = xor i1 %6, true
  %8 = zext i1 %7 to i64
  tail call void @_assert_true(i64 noundef %8, ptr noundef nonnull @.str.43, ptr noundef nonnull @.str.2, i32 noundef 406) #3
  %9 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %0) #3
  %10 = icmp eq i64 %9, 0
  %11 = zext i1 %10 to i64
  tail call void @_assert_true(i64 noundef %11, ptr noundef nonnull @.str.39, ptr noundef nonnull @.str.2, i32 noundef 407) #3
  tail call void @roaring_bitmap_free(ptr noundef %0) #3
  br label %12

.loopexit:                                        ; preds = %12
  ret void

12:                                               ; preds = %.peel.next, %12
  %.023 = phi i64 [ 1, %.peel.next ], [ %29, %12 ]
  %13 = tail call ptr @roaring_bitmap_create() #3
  %14 = sub nuw nsw i64 4294967296, %.023
  tail call void @roaring_bitmap_add_range(ptr noundef %13, i64 noundef %14, i64 noundef 4294967296)
  %15 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %13) #3
  %16 = icmp eq i64 %15, %.023
  %17 = zext i1 %16 to i64
  tail call void @_assert_true(i64 noundef %17, ptr noundef nonnull @.str.39, ptr noundef nonnull @.str.2, i32 noundef 401) #3
  %18 = tail call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %13, i64 noundef %14, i64 noundef 4294967295) #3
  %19 = zext i1 %18 to i64
  tail call void @_assert_true(i64 noundef %19, ptr noundef nonnull @.str.41, ptr noundef nonnull @.str.2, i32 noundef 403) #3
  %20 = tail call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %13, i64 noundef %14, i64 noundef 4294967296) #3
  %21 = zext i1 %20 to i64
  tail call void @_assert_true(i64 noundef %21, ptr noundef nonnull @.str.42, ptr noundef nonnull @.str.2, i32 noundef 405) #3
  %22 = sub nuw nsw i64 4294967295, %.023
  %23 = tail call zeroext i1 @roaring_bitmap_contains_range(ptr noundef %13, i64 noundef %22, i64 noundef 4294967296) #3
  %24 = xor i1 %23, true
  %25 = zext i1 %24 to i64
  tail call void @_assert_true(i64 noundef %25, ptr noundef nonnull @.str.43, ptr noundef nonnull @.str.2, i32 noundef 406) #3
  %26 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %13) #3
  %27 = icmp eq i64 %26, %.023
  %28 = zext i1 %27 to i64
  tail call void @_assert_true(i64 noundef %28, ptr noundef nonnull @.str.39, ptr noundef nonnull @.str.2, i32 noundef 407) #3
  tail call void @roaring_bitmap_free(ptr noundef %13) #3
  %29 = add nuw nsw i64 %.023, 1
  %exitcond.not = icmp eq i64 %29, 1048576
  br i1 %exitcond.not, label %.loopexit, label %12, !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 = { 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, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopFullUnrollPass,LoopRotatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass