; 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.120 = external hidden unnamed_addr constant [7 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 zeroext i1 @roaring_bitmap_run_optimize(ptr 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_helper(i1 noundef zeroext %0, i32 noundef %1) #2 {
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = zext i1 %0 to i8
  store i8 %10, ptr %3, align 1, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %11 = call ptr @roaring_bitmap_create()
  store ptr %11, ptr %5, align 8, !tbaa !11
  %12 = load ptr, ptr %5, align 8, !tbaa !11
  %13 = ptrtoint ptr %12 to i64
  call void @_assert_true(i64 noundef %13, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2871)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %30, %2
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = icmp ult i32 %15, 65536
  br i1 %16, label %18, label %17

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

18:                                               ; preds = %14
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = urem i32 %19, 147
  %21 = load i32, ptr %4, align 4, !tbaa !9
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %18
  br label %30

24:                                               ; preds = %18
  %25 = load ptr, ptr %5, align 8, !tbaa !11
  %26 = load i32, ptr %6, align 4, !tbaa !9
  call void @roaring_bitmap_add(ptr noundef %25, i32 noundef %26)
  %27 = load ptr, ptr %5, align 8, !tbaa !11
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = add i32 327680, %28
  call void @roaring_bitmap_add(ptr noundef %27, i32 noundef %29)
  br label %30

30:                                               ; preds = %24, %23
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = add i32 %31, 1
  store i32 %32, ptr %6, align 4, !tbaa !9
  br label %14, !llvm.loop !13

33:                                               ; preds = %17
  %34 = load i8, ptr %3, align 1, !tbaa !5, !range !15, !noundef !16
  %35 = trunc i8 %34 to i1
  br i1 %35, label %36, label %43

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  %37 = load ptr, ptr %5, align 8, !tbaa !11
  %38 = call zeroext i1 @roaring_bitmap_run_optimize(ptr noundef %37)
  %39 = zext i1 %38 to i8
  store i8 %39, ptr %7, align 1, !tbaa !5
  %40 = load i8, ptr %7, align 1, !tbaa !5, !range !15, !noundef !16
  %41 = trunc i8 %40 to i1
  %42 = zext i1 %41 to i64
  call void @_assert_true(i64 noundef %42, ptr noundef @.str.120, ptr noundef @.str.2, i32 noundef 2880)
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  br label %43

43:                                               ; preds = %36, %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %44 = load ptr, ptr %5, align 8, !tbaa !11
  %45 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %44)
  %46 = trunc i64 %45 to i32
  store i32 %46, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %47 = load ptr, ptr %5, align 8, !tbaa !11
  %48 = call ptr @roaring_bitmap_copy(ptr noundef %47)
  store ptr %48, ptr %9, align 8, !tbaa !11
  %49 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_flip_inplace(ptr noundef %49, i64 noundef 0, i64 noundef 100000)
  %50 = load ptr, ptr %5, align 8, !tbaa !11
  %51 = ptrtoint ptr %50 to i64
  call void @_assert_true(i64 noundef %51, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2888)
  %52 = load ptr, ptr %5, align 8, !tbaa !11
  %53 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %52)
  call void @_assert_int_equal(i64 noundef 100000, i64 noundef %53, ptr noundef @.str.2, i32 noundef 2891)
  %54 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %54)
  %55 = load ptr, ptr %9, align 8, !tbaa !11
  %56 = call ptr @roaring_bitmap_copy(ptr noundef %55)
  store ptr %56, ptr %5, align 8, !tbaa !11
  %57 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_flip_inplace(ptr noundef %57, i64 noundef 0, i64 noundef 1000000)
  %58 = load ptr, ptr %5, align 8, !tbaa !11
  %59 = ptrtoint ptr %58 to i64
  call void @_assert_true(i64 noundef %59, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2897)
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = sub nsw i32 1000000, %60
  %62 = sext i32 %61 to i64
  %63 = load ptr, ptr %5, align 8, !tbaa !11
  %64 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %63)
  call void @_assert_int_equal(i64 noundef %62, i64 noundef %64, ptr noundef @.str.2, i32 noundef 2898)
  %65 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %65)
  %66 = load ptr, ptr %9, align 8, !tbaa !11
  %67 = call ptr @roaring_bitmap_copy(ptr noundef %66)
  store ptr %67, ptr %5, align 8, !tbaa !11
  %68 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_flip_inplace(ptr noundef %68, i64 noundef 100000, i64 noundef 200000)
  %69 = load ptr, ptr %5, align 8, !tbaa !11
  %70 = ptrtoint ptr %69 to i64
  call void @_assert_true(i64 noundef %70, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2904)
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = add nsw i32 100000, %71
  %73 = sext i32 %72 to i64
  %74 = load ptr, ptr %5, align 8, !tbaa !11
  %75 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %74)
  call void @_assert_int_equal(i64 noundef %73, i64 noundef %75, ptr noundef @.str.2, i32 noundef 2905)
  %76 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %76)
  %77 = load ptr, ptr %9, align 8, !tbaa !11
  %78 = call ptr @roaring_bitmap_copy(ptr noundef %77)
  store ptr %78, ptr %5, align 8, !tbaa !11
  %79 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_flip_inplace(ptr noundef %79, i64 noundef 1, i64 noundef 393216)
  %80 = load ptr, ptr %5, align 8, !tbaa !11
  %81 = ptrtoint ptr %80 to i64
  call void @_assert_true(i64 noundef %81, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2911)
  %82 = load i32, ptr %8, align 4, !tbaa !9
  %83 = sub nsw i32 393215, %82
  %84 = sext i32 %83 to i64
  %85 = load ptr, ptr %5, align 8, !tbaa !11
  %86 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %85)
  call void @_assert_int_equal(i64 noundef %84, i64 noundef %86, ptr noundef @.str.2, i32 noundef 2913)
  %87 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %87)
  %88 = load ptr, ptr %9, align 8, !tbaa !11
  %89 = call ptr @roaring_bitmap_copy(ptr noundef %88)
  store ptr %89, ptr %5, align 8, !tbaa !11
  %90 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_flip_inplace(ptr noundef %90, i64 noundef 1, i64 noundef 327680)
  %91 = load ptr, ptr %5, align 8, !tbaa !11
  %92 = ptrtoint ptr %91 to i64
  call void @_assert_true(i64 noundef %92, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 2919)
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = sdiv i32 %93, 2
  %95 = sub nsw i32 327679, %94
  %96 = load i32, ptr %8, align 4, !tbaa !9
  %97 = sdiv i32 %96, 2
  %98 = add nsw i32 %95, %97
  %99 = sext i32 %98 to i64
  %100 = load ptr, ptr %5, align 8, !tbaa !11
  %101 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %100)
  call void @_assert_int_equal(i64 noundef %99, i64 noundef %101, ptr noundef @.str.2, i32 noundef 2921)
  %102 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %102)
  %103 = load ptr, ptr %9, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %103)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #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 = !{!"_Bool", !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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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.120 = external hidden unnamed_addr constant [7 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 zeroext i1 @roaring_bitmap_run_optimize(ptr 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_helper(i1 noundef zeroext %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = tail call ptr @roaring_bitmap_create() #2
  %4 = ptrtoint ptr %3 to i64
  tail call void @_assert_true(i64 noundef %4, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2871) #2
  br label %6

5:                                                ; preds = %11
  br i1 %0, label %13, label %16

6:                                                ; preds = %2, %11
  %.045 = phi i32 [ 0, %2 ], [ %12, %11 ]
  %.lhs.trunc = trunc nuw i32 %.045 to i16
  %7 = urem i16 %.lhs.trunc, 147
  %.zext = zext nneg i16 %7 to i32
  %8 = icmp ult i32 %.zext, %1
  br i1 %8, label %11, label %9

9:                                                ; preds = %6
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %.045) #2
  %10 = or disjoint i32 %.045, 327680
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %10) #2
  br label %11

11:                                               ; preds = %6, %9
  %12 = add nuw nsw i32 %.045, 1
  %exitcond.not = icmp eq i32 %12, 65536
  br i1 %exitcond.not, label %5, label %6, !llvm.loop !5

13:                                               ; preds = %5
  %14 = tail call zeroext i1 @roaring_bitmap_run_optimize(ptr noundef %3) #2
  %15 = zext i1 %14 to i64
  tail call void @_assert_true(i64 noundef %15, ptr noundef nonnull @.str.120, ptr noundef nonnull @.str.2, i32 noundef 2880) #2
  br label %16

16:                                               ; preds = %13, %5
  %17 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %3) #2
  %18 = tail call ptr @roaring_bitmap_copy(ptr noundef %3) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %3, i64 noundef 0, i64 noundef 100000) #2
  tail call void @_assert_true(i64 noundef %4, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2888) #2
  %19 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %3) #2
  tail call void @_assert_int_equal(i64 noundef 100000, i64 noundef %19, ptr noundef nonnull @.str.2, i32 noundef 2891) #2
  tail call void @roaring_bitmap_free(ptr noundef %3) #2
  %20 = tail call ptr @roaring_bitmap_copy(ptr noundef %18) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %20, i64 noundef 0, i64 noundef 1000000) #2
  %21 = ptrtoint ptr %20 to i64
  tail call void @_assert_true(i64 noundef %21, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2897) #2
  %22 = shl i64 %17, 32
  %sext = sub i64 4294967296000000, %22
  %23 = ashr exact i64 %sext, 32
  %24 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %20) #2
  tail call void @_assert_int_equal(i64 noundef %23, i64 noundef %24, ptr noundef nonnull @.str.2, i32 noundef 2898) #2
  tail call void @roaring_bitmap_free(ptr noundef %20) #2
  %25 = tail call ptr @roaring_bitmap_copy(ptr noundef %18) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %25, i64 noundef 100000, i64 noundef 200000) #2
  %26 = ptrtoint ptr %25 to i64
  tail call void @_assert_true(i64 noundef %26, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2904) #2
  %sext43 = add i64 %22, 429496729600000
  %27 = ashr exact i64 %sext43, 32
  %28 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %25) #2
  tail call void @_assert_int_equal(i64 noundef %27, i64 noundef %28, ptr noundef nonnull @.str.2, i32 noundef 2905) #2
  tail call void @roaring_bitmap_free(ptr noundef %25) #2
  %29 = tail call ptr @roaring_bitmap_copy(ptr noundef %18) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %29, i64 noundef 1, i64 noundef 393216) #2
  %30 = ptrtoint ptr %29 to i64
  tail call void @_assert_true(i64 noundef %30, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2911) #2
  %sext44 = sub i64 1688845565296640, %22
  %31 = ashr exact i64 %sext44, 32
  %32 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %29) #2
  tail call void @_assert_int_equal(i64 noundef %31, i64 noundef %32, ptr noundef nonnull @.str.2, i32 noundef 2913) #2
  tail call void @roaring_bitmap_free(ptr noundef %29) #2
  %33 = tail call ptr @roaring_bitmap_copy(ptr noundef %18) #2
  tail call void @roaring_bitmap_flip_inplace(ptr noundef %33, i64 noundef 1, i64 noundef 327680) #2
  %34 = ptrtoint ptr %33 to i64
  tail call void @_assert_true(i64 noundef %34, ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.2, i32 noundef 2919) #2
  %35 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %33) #2
  tail call void @_assert_int_equal(i64 noundef 327679, i64 noundef %35, ptr noundef nonnull @.str.2, i32 noundef 2921) #2
  tail call void @roaring_bitmap_free(ptr noundef %33) #2
  tail call void @roaring_bitmap_free(ptr noundef %18) #2
  ret void
}

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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass