; 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.119 = external hidden unnamed_addr constant [10 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 i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

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

declare ptr @roaring_bitmap_flip(ptr noundef, i64 noundef, i64 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_negation_array2() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  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
  %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 2569)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %7

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

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

11:                                               ; preds = %7
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = load i32, ptr %2, align 4, !tbaa !9
  %14 = mul i32 2, %13
  call void @roaring_bitmap_add(ptr noundef %12, i32 noundef %14)
  %15 = load ptr, ptr %1, align 8, !tbaa !5
  %16 = load i32, ptr %2, align 4, !tbaa !9
  %17 = mul i32 2, %16
  %18 = add i32 327680, %17
  call void @roaring_bitmap_add(ptr noundef %15, i32 noundef %18)
  br label %19

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

22:                                               ; preds = %10
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %23)
  call void @_assert_int_equal(i64 noundef %24, i64 noundef 200, ptr noundef @.str.2, i32 noundef 2576)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = call ptr @roaring_bitmap_flip(ptr noundef %25, i64 noundef 0, i64 noundef 100000)
  store ptr %26, ptr %3, align 8, !tbaa !5
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = ptrtoint ptr %27 to i64
  call void @_assert_true(i64 noundef %28, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2580)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %29)
  call void @_assert_int_equal(i64 noundef 100000, i64 noundef %30, ptr noundef @.str.2, i32 noundef 2583)
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %31)
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  %33 = call ptr @roaring_bitmap_flip(ptr noundef %32, i64 noundef 0, i64 noundef 1000000)
  store ptr %33, ptr %3, align 8, !tbaa !5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = ptrtoint ptr %34 to i64
  call void @_assert_true(i64 noundef %35, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2588)
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %36)
  call void @_assert_int_equal(i64 noundef 999800, i64 noundef %37, ptr noundef @.str.2, i32 noundef 2589)
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %38)
  %39 = load ptr, ptr %1, align 8, !tbaa !5
  %40 = call ptr @roaring_bitmap_flip(ptr noundef %39, i64 noundef 100000, i64 noundef 200000)
  store ptr %40, ptr %3, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = ptrtoint ptr %41 to i64
  call void @_assert_true(i64 noundef %42, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2594)
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %43)
  call void @_assert_int_equal(i64 noundef 100200, i64 noundef %44, ptr noundef @.str.2, i32 noundef 2595)
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %45)
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  %47 = call ptr @roaring_bitmap_flip(ptr noundef %46, i64 noundef 1, i64 noundef 393216)
  store ptr %47, ptr %3, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = ptrtoint ptr %48 to i64
  call void @_assert_true(i64 noundef %49, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2600)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %50)
  call void @_assert_int_equal(i64 noundef 393017, i64 noundef %51, ptr noundef @.str.2, i32 noundef 2602)
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %52)
  %53 = load ptr, ptr %1, align 8, !tbaa !5
  %54 = call ptr @roaring_bitmap_flip(ptr noundef %53, i64 noundef 1, i64 noundef 327680)
  store ptr %54, ptr %3, align 8, !tbaa !5
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = ptrtoint ptr %55 to i64
  call void @_assert_true(i64 noundef %56, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2607)
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %57)
  call void @_assert_int_equal(i64 noundef 327681, i64 noundef %58, ptr noundef @.str.2, i32 noundef 2609)
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %59)
  %60 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %60)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  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 = { 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"}


; 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.119 = external hidden unnamed_addr constant [10 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 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 ptr @roaring_bitmap_flip(ptr noundef, i64 noundef, i64 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_negation_array2() local_unnamed_addr #1 {
  %1 = tail call ptr @roaring_bitmap_create() #2
  %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 2569) #2
  br label %20

3:                                                ; preds = %20
  %4 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %1) #2
  tail call void @_assert_int_equal(i64 noundef %4, i64 noundef 200, ptr noundef nonnull @.str.2, i32 noundef 2576) #2
  %5 = tail call ptr @roaring_bitmap_flip(ptr noundef %1, i64 noundef 0, i64 noundef 100000) #2
  %6 = ptrtoint ptr %5 to i64
  tail call void @_assert_true(i64 noundef %6, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2580) #2
  %7 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %5) #2
  tail call void @_assert_int_equal(i64 noundef 100000, i64 noundef %7, ptr noundef nonnull @.str.2, i32 noundef 2583) #2
  tail call void @roaring_bitmap_free(ptr noundef %5) #2
  %8 = tail call ptr @roaring_bitmap_flip(ptr noundef %1, i64 noundef 0, i64 noundef 1000000) #2
  %9 = ptrtoint ptr %8 to i64
  tail call void @_assert_true(i64 noundef %9, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2588) #2
  %10 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %8) #2
  tail call void @_assert_int_equal(i64 noundef 999800, i64 noundef %10, ptr noundef nonnull @.str.2, i32 noundef 2589) #2
  tail call void @roaring_bitmap_free(ptr noundef %8) #2
  %11 = tail call ptr @roaring_bitmap_flip(ptr noundef %1, i64 noundef 100000, i64 noundef 200000) #2
  %12 = ptrtoint ptr %11 to i64
  tail call void @_assert_true(i64 noundef %12, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2594) #2
  %13 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %11) #2
  tail call void @_assert_int_equal(i64 noundef 100200, i64 noundef %13, ptr noundef nonnull @.str.2, i32 noundef 2595) #2
  tail call void @roaring_bitmap_free(ptr noundef %11) #2
  %14 = tail call ptr @roaring_bitmap_flip(ptr noundef %1, i64 noundef 1, i64 noundef 393216) #2
  %15 = ptrtoint ptr %14 to i64
  tail call void @_assert_true(i64 noundef %15, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2600) #2
  %16 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %14) #2
  tail call void @_assert_int_equal(i64 noundef 393017, i64 noundef %16, ptr noundef nonnull @.str.2, i32 noundef 2602) #2
  tail call void @roaring_bitmap_free(ptr noundef %14) #2
  %17 = tail call ptr @roaring_bitmap_flip(ptr noundef %1, i64 noundef 1, i64 noundef 327680) #2
  %18 = ptrtoint ptr %17 to i64
  tail call void @_assert_true(i64 noundef %18, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2607) #2
  %19 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %17) #2
  tail call void @_assert_int_equal(i64 noundef 327681, i64 noundef %19, ptr noundef nonnull @.str.2, i32 noundef 2609) #2
  tail call void @roaring_bitmap_free(ptr noundef %17) #2
  tail call void @roaring_bitmap_free(ptr noundef %1) #2
  ret void

20:                                               ; preds = %0, %20
  %.028 = phi i32 [ 0, %0 ], [ %23, %20 ]
  %21 = shl nuw nsw i32 %.028, 1
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef %21) #2
  %22 = or disjoint i32 %21, 327680
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef %22) #2
  %23 = add nuw nsw i32 %.028, 1
  %exitcond.not = icmp eq i32 %23, 100
  br i1 %exitcond.not, label %3, label %20, !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 = { 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"}


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