; 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
@.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 void @roaring_bitmap_add(ptr noundef, i32 noundef) #1

declare ptr @roaring_bitmap_flip(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_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 2667)
  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 2676)
  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_flip(ptr noundef %47, i64 noundef 0, i64 noundef 100000)
  store ptr %48, ptr %9, align 8, !tbaa !11
  %49 = load ptr, ptr %9, align 8, !tbaa !11
  %50 = ptrtoint ptr %49 to i64
  call void @_assert_true(i64 noundef %50, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2683)
  %51 = load ptr, ptr %9, align 8, !tbaa !11
  %52 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %51)
  call void @_assert_int_equal(i64 noundef 100000, i64 noundef %52, ptr noundef @.str.2, i32 noundef 2686)
  %53 = load ptr, ptr %9, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %53)
  %54 = load ptr, ptr %5, align 8, !tbaa !11
  %55 = call ptr @roaring_bitmap_flip(ptr noundef %54, i64 noundef 0, i64 noundef 1000000)
  store ptr %55, ptr %9, align 8, !tbaa !11
  %56 = load ptr, ptr %9, align 8, !tbaa !11
  %57 = ptrtoint ptr %56 to i64
  call void @_assert_true(i64 noundef %57, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2691)
  %58 = load i32, ptr %8, align 4, !tbaa !9
  %59 = sub nsw i32 1000000, %58
  %60 = sext i32 %59 to i64
  %61 = load ptr, ptr %9, align 8, !tbaa !11
  %62 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %61)
  call void @_assert_int_equal(i64 noundef %60, i64 noundef %62, ptr noundef @.str.2, i32 noundef 2693)
  %63 = load ptr, ptr %9, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %63)
  %64 = load ptr, ptr %5, align 8, !tbaa !11
  %65 = call ptr @roaring_bitmap_flip(ptr noundef %64, i64 noundef 100000, i64 noundef 200000)
  store ptr %65, ptr %9, align 8, !tbaa !11
  %66 = load ptr, ptr %9, align 8, !tbaa !11
  %67 = ptrtoint ptr %66 to i64
  call void @_assert_true(i64 noundef %67, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2698)
  %68 = load i32, ptr %8, align 4, !tbaa !9
  %69 = add nsw i32 100000, %68
  %70 = sext i32 %69 to i64
  %71 = load ptr, ptr %9, align 8, !tbaa !11
  %72 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %71)
  call void @_assert_int_equal(i64 noundef %70, i64 noundef %72, ptr noundef @.str.2, i32 noundef 2700)
  %73 = load ptr, ptr %9, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %73)
  %74 = load ptr, ptr %5, align 8, !tbaa !11
  %75 = call ptr @roaring_bitmap_flip(ptr noundef %74, i64 noundef 1, i64 noundef 393216)
  store ptr %75, ptr %9, align 8, !tbaa !11
  %76 = load ptr, ptr %9, align 8, !tbaa !11
  %77 = ptrtoint ptr %76 to i64
  call void @_assert_true(i64 noundef %77, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2705)
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = sub nsw i32 393215, %78
  %80 = sext i32 %79 to i64
  %81 = load ptr, ptr %9, align 8, !tbaa !11
  %82 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %81)
  call void @_assert_int_equal(i64 noundef %80, i64 noundef %82, ptr noundef @.str.2, i32 noundef 2707)
  %83 = load ptr, ptr %9, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %83)
  %84 = load ptr, ptr %5, align 8, !tbaa !11
  %85 = call ptr @roaring_bitmap_flip(ptr noundef %84, i64 noundef 1, i64 noundef 327680)
  store ptr %85, ptr %9, align 8, !tbaa !11
  %86 = load ptr, ptr %9, align 8, !tbaa !11
  %87 = ptrtoint ptr %86 to i64
  call void @_assert_true(i64 noundef %87, ptr noundef @.str.119, ptr noundef @.str.2, i32 noundef 2712)
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = sdiv i32 %88, 2
  %90 = sub nsw i32 327679, %89
  %91 = load i32, ptr %8, align 4, !tbaa !9
  %92 = sdiv i32 %91, 2
  %93 = add nsw i32 %90, %92
  %94 = sext i32 %93 to i64
  %95 = load ptr, ptr %9, align 8, !tbaa !11
  %96 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %95)
  call void @_assert_int_equal(i64 noundef %94, i64 noundef %96, ptr noundef @.str.2, i32 noundef 2714)
  %97 = load ptr, ptr %9, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %97)
  %98 = load ptr, ptr %5, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %98)
  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.119 = external hidden unnamed_addr constant [10 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 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 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_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 2667) #2
  br label %6

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

6:                                                ; preds = %2, %11
  %.040 = phi i32 [ 0, %2 ], [ %12, %11 ]
  %.lhs.trunc = trunc nuw i32 %.040 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 %.040) #2
  %10 = or disjoint i32 %.040, 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 %.040, 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 2676) #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_flip(ptr noundef %3, i64 noundef 0, i64 noundef 100000) #2
  %19 = ptrtoint ptr %18 to i64
  tail call void @_assert_true(i64 noundef %19, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2683) #2
  %20 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %18) #2
  tail call void @_assert_int_equal(i64 noundef 100000, i64 noundef %20, ptr noundef nonnull @.str.2, i32 noundef 2686) #2
  tail call void @roaring_bitmap_free(ptr noundef %18) #2
  %21 = tail call ptr @roaring_bitmap_flip(ptr noundef %3, i64 noundef 0, i64 noundef 1000000) #2
  %22 = ptrtoint ptr %21 to i64
  tail call void @_assert_true(i64 noundef %22, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2691) #2
  %23 = shl i64 %17, 32
  %sext = sub i64 4294967296000000, %23
  %24 = ashr exact i64 %sext, 32
  %25 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %21) #2
  tail call void @_assert_int_equal(i64 noundef %24, i64 noundef %25, ptr noundef nonnull @.str.2, i32 noundef 2693) #2
  tail call void @roaring_bitmap_free(ptr noundef %21) #2
  %26 = tail call ptr @roaring_bitmap_flip(ptr noundef %3, i64 noundef 100000, i64 noundef 200000) #2
  %27 = ptrtoint ptr %26 to i64
  tail call void @_assert_true(i64 noundef %27, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2698) #2
  %sext38 = add i64 %23, 429496729600000
  %28 = ashr exact i64 %sext38, 32
  %29 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %26) #2
  tail call void @_assert_int_equal(i64 noundef %28, i64 noundef %29, ptr noundef nonnull @.str.2, i32 noundef 2700) #2
  tail call void @roaring_bitmap_free(ptr noundef %26) #2
  %30 = tail call ptr @roaring_bitmap_flip(ptr noundef %3, i64 noundef 1, i64 noundef 393216) #2
  %31 = ptrtoint ptr %30 to i64
  tail call void @_assert_true(i64 noundef %31, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2705) #2
  %sext39 = sub i64 1688845565296640, %23
  %32 = ashr exact i64 %sext39, 32
  %33 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %30) #2
  tail call void @_assert_int_equal(i64 noundef %32, i64 noundef %33, ptr noundef nonnull @.str.2, i32 noundef 2707) #2
  tail call void @roaring_bitmap_free(ptr noundef %30) #2
  %34 = tail call ptr @roaring_bitmap_flip(ptr noundef %3, i64 noundef 1, i64 noundef 327680) #2
  %35 = ptrtoint ptr %34 to i64
  tail call void @_assert_true(i64 noundef %35, ptr noundef nonnull @.str.119, ptr noundef nonnull @.str.2, i32 noundef 2712) #2
  %36 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %34) #2
  tail call void @_assert_int_equal(i64 noundef 327679, i64 noundef %36, ptr noundef nonnull @.str.2, i32 noundef 2714) #2
  tail call void @roaring_bitmap_free(ptr noundef %34) #2
  tail call void @roaring_bitmap_free(ptr noundef %3) #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