; 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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

declare ptr @roaring_bitmap_copy(ptr noundef) #1

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

declare void @roaring_bitmap_flip_inplace(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_inplace_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 2765)
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %23 = load ptr, ptr %1, align 8, !tbaa !5
  %24 = call ptr @roaring_bitmap_copy(ptr noundef %23)
  store ptr %24, ptr %3, align 8, !tbaa !5
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %25)
  call void @_assert_int_equal(i64 noundef %26, i64 noundef 200, ptr noundef @.str.2, i32 noundef 2773)
  %27 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_flip_inplace(ptr noundef %27, i64 noundef 0, i64 noundef 100000)
  %28 = load ptr, ptr %1, align 8, !tbaa !5
  %29 = ptrtoint ptr %28 to i64
  call void @_assert_true(i64 noundef %29, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2777)
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  %31 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %30)
  call void @_assert_int_equal(i64 noundef 100000, i64 noundef %31, ptr noundef @.str.2, i32 noundef 2780)
  %32 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %32)
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = call ptr @roaring_bitmap_copy(ptr noundef %33)
  store ptr %34, ptr %1, align 8, !tbaa !5
  %35 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_flip_inplace(ptr noundef %35, i64 noundef 0, i64 noundef 1000000)
  %36 = load ptr, ptr %1, align 8, !tbaa !5
  %37 = ptrtoint ptr %36 to i64
  call void @_assert_true(i64 noundef %37, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2786)
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  %39 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %38)
  call void @_assert_int_equal(i64 noundef 999800, i64 noundef %39, ptr noundef @.str.2, i32 noundef 2787)
  %40 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %40)
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call ptr @roaring_bitmap_copy(ptr noundef %41)
  store ptr %42, ptr %1, align 8, !tbaa !5
  %43 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_flip_inplace(ptr noundef %43, i64 noundef 100000, i64 noundef 200000)
  %44 = load ptr, ptr %1, align 8, !tbaa !5
  %45 = ptrtoint ptr %44 to i64
  call void @_assert_true(i64 noundef %45, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2793)
  %46 = load ptr, ptr %1, align 8, !tbaa !5
  %47 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %46)
  call void @_assert_int_equal(i64 noundef 100200, i64 noundef %47, ptr noundef @.str.2, i32 noundef 2794)
  %48 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %48)
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = call ptr @roaring_bitmap_copy(ptr noundef %49)
  store ptr %50, ptr %1, align 8, !tbaa !5
  %51 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_flip_inplace(ptr noundef %51, i64 noundef 1, i64 noundef 393216)
  %52 = load ptr, ptr %1, align 8, !tbaa !5
  %53 = ptrtoint ptr %52 to i64
  call void @_assert_true(i64 noundef %53, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2800)
  %54 = load ptr, ptr %1, align 8, !tbaa !5
  %55 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %54)
  call void @_assert_int_equal(i64 noundef 393017, i64 noundef %55, ptr noundef @.str.2, i32 noundef 2801)
  %56 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %56)
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = call ptr @roaring_bitmap_copy(ptr noundef %57)
  store ptr %58, ptr %1, align 8, !tbaa !5
  %59 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_flip_inplace(ptr noundef %59, i64 noundef 1, i64 noundef 327680)
  %60 = load ptr, ptr %1, align 8, !tbaa !5
  %61 = ptrtoint ptr %60 to i64
  call void @_assert_true(i64 noundef %61, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2807)
  %62 = load ptr, ptr %1, align 8, !tbaa !5
  %63 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %62)
  call void @_assert_int_equal(i64 noundef 327681, i64 noundef %63, ptr noundef @.str.2, i32 noundef 2809)
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %64)
  %65 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %65)
  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

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

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

declare void @roaring_bitmap_flip_inplace(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_inplace_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 2765) #2
  br label %19

3:                                                ; preds = %19
  %4 = tail call ptr @roaring_bitmap_copy(ptr noundef %1) #2
  %5 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %1) #2
  tail call void @_assert_int_equal(i64 noundef %5, i64 noundef 200, ptr noundef nonnull @.str.2, i32 noundef 2773) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %1, i64 noundef 0, i64 noundef 100000) #2
  tail call void @_assert_true(i64 noundef %2, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2777) #2
  %6 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %1) #2
  tail call void @_assert_int_equal(i64 noundef 100000, i64 noundef %6, ptr noundef nonnull @.str.2, i32 noundef 2780) #2
  tail call void @roaring_bitmap_free(ptr noundef %1) #2
  %7 = tail call ptr @roaring_bitmap_copy(ptr noundef %4) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %7, i64 noundef 0, i64 noundef 1000000) #2
  %8 = ptrtoint ptr %7 to i64
  tail call void @_assert_true(i64 noundef %8, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2786) #2
  %9 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %7) #2
  tail call void @_assert_int_equal(i64 noundef 999800, i64 noundef %9, ptr noundef nonnull @.str.2, i32 noundef 2787) #2
  tail call void @roaring_bitmap_free(ptr noundef %7) #2
  %10 = tail call ptr @roaring_bitmap_copy(ptr noundef %4) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %10, i64 noundef 100000, i64 noundef 200000) #2
  %11 = ptrtoint ptr %10 to i64
  tail call void @_assert_true(i64 noundef %11, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2793) #2
  %12 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %10) #2
  tail call void @_assert_int_equal(i64 noundef 100200, i64 noundef %12, ptr noundef nonnull @.str.2, i32 noundef 2794) #2
  tail call void @roaring_bitmap_free(ptr noundef %10) #2
  %13 = tail call ptr @roaring_bitmap_copy(ptr noundef %4) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %13, i64 noundef 1, i64 noundef 393216) #2
  %14 = ptrtoint ptr %13 to i64
  tail call void @_assert_true(i64 noundef %14, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2800) #2
  %15 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %13) #2
  tail call void @_assert_int_equal(i64 noundef 393017, i64 noundef %15, ptr noundef nonnull @.str.2, i32 noundef 2801) #2
  tail call void @roaring_bitmap_free(ptr noundef %13) #2
  %16 = tail call ptr @roaring_bitmap_copy(ptr noundef %4) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %16, i64 noundef 1, i64 noundef 327680) #2
  %17 = ptrtoint ptr %16 to i64
  tail call void @_assert_true(i64 noundef %17, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2807) #2
  %18 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %16) #2
  tail call void @_assert_int_equal(i64 noundef 327681, i64 noundef %18, ptr noundef nonnull @.str.2, i32 noundef 2809) #2
  tail call void @roaring_bitmap_free(ptr noundef %4) #2
  tail call void @roaring_bitmap_free(ptr noundef %16) #2
  ret void

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