; 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.85 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [41 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

; Function Attrs: nounwind uwtable
define dso_local void @test_add_checked() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  %3 = call ptr @roaring_bitmap_create()
  store ptr %3, ptr %1, align 8, !tbaa !5
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = ptrtoint ptr %4 to i64
  call void @_assert_true(i64 noundef %5, ptr noundef @.str.23, ptr noundef @.str.2, i32 noundef 1242)
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  %7 = call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %6, i32 noundef 999)
  %8 = zext i1 %7 to i64
  call void @_assert_true(i64 noundef %8, ptr noundef @.str.85, ptr noundef @.str.2, i32 noundef 1244)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %26, %0
  %10 = load i32, ptr %2, align 4, !tbaa !9
  %11 = icmp ult i32 %10, 125
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %9
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !9
  %16 = mul i32 3823, %15
  %17 = call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %14, i32 noundef %16)
  %18 = zext i1 %17 to i64
  call void @_assert_true(i64 noundef %18, ptr noundef @.str.86, ptr noundef @.str.2, i32 noundef 1246)
  %19 = load ptr, ptr %1, align 8, !tbaa !5
  %20 = load i32, ptr %2, align 4, !tbaa !9
  %21 = mul i32 3823, %20
  %22 = call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %19, i32 noundef %21)
  %23 = xor i1 %22, true
  %24 = zext i1 %23 to i32
  %25 = sext i32 %24 to i64
  call void @_assert_true(i64 noundef %25, ptr noundef @.str.86, ptr noundef @.str.2, i32 noundef 1247)
  br label %26

26:                                               ; preds = %13
  %27 = load i32, ptr %2, align 4, !tbaa !9
  %28 = add i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !9
  br label %9, !llvm.loop !11

29:                                               ; preds = %12
  %30 = load ptr, ptr %1, align 8, !tbaa !5
  %31 = call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %30, i32 noundef 999)
  %32 = xor i1 %31, true
  %33 = zext i1 %32 to i32
  %34 = sext i32 %33 to i64
  call void @_assert_true(i64 noundef %34, ptr noundef @.str.85, ptr noundef @.str.2, i32 noundef 1249)
  %35 = load ptr, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_free(ptr noundef %35)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  ret void
}

declare zeroext i1 @roaring_bitmap_add_checked(ptr noundef, i32 noundef) #1

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.85 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.86 = external hidden unnamed_addr constant [41 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

; Function Attrs: nounwind uwtable
define dso_local void @test_add_checked() 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 1242) #2
  %3 = tail call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %1, i32 noundef 999) #2
  %4 = zext i1 %3 to i64
  tail call void @_assert_true(i64 noundef %4, ptr noundef nonnull @.str.85, ptr noundef nonnull @.str.2, i32 noundef 1244) #2
  br label %9

5:                                                ; preds = %9
  %6 = tail call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %1, i32 noundef 999) #2
  %7 = xor i1 %6, true
  %8 = zext i1 %7 to i64
  tail call void @_assert_true(i64 noundef %8, ptr noundef nonnull @.str.85, ptr noundef nonnull @.str.2, i32 noundef 1249) #2
  tail call void @roaring_bitmap_free(ptr noundef %1) #2
  ret void

9:                                                ; preds = %0, %9
  %.09 = phi i32 [ 0, %0 ], [ %16, %9 ]
  %10 = mul nuw nsw i32 %.09, 3823
  %11 = tail call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %1, i32 noundef %10) #2
  %12 = zext i1 %11 to i64
  tail call void @_assert_true(i64 noundef %12, ptr noundef nonnull @.str.86, ptr noundef nonnull @.str.2, i32 noundef 1246) #2
  %13 = tail call zeroext i1 @roaring_bitmap_add_checked(ptr noundef %1, i32 noundef %10) #2
  %14 = xor i1 %13, true
  %15 = zext i1 %14 to i64
  tail call void @_assert_true(i64 noundef %15, ptr noundef nonnull @.str.86, ptr noundef nonnull @.str.2, i32 noundef 1247) #2
  %16 = add nuw nsw i32 %.09, 1
  %exitcond.not = icmp eq i32 %16, 125
  br i1 %exitcond.not, label %5, label %9, !llvm.loop !5
}

declare zeroext i1 @roaring_bitmap_add_checked(ptr noundef, i32 noundef) local_unnamed_addr #0

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