; 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"

; 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 ptr @roaring_bitmap_or_many(i64 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @test_or_many_memory_leak() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca [2 x ptr], align 16
  %7 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %32, %0
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 10
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %35

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %13 = call ptr @roaring_bitmap_create()
  store ptr %13, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %27, %12
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 10
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %30

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %19 = call ptr @roaring_bitmap_create()
  store ptr %19, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #3
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  store ptr %20, ptr %6, align 8, !tbaa !9
  %21 = getelementptr inbounds ptr, ptr %6, i64 1
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  store ptr %22, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %23 = getelementptr inbounds [2 x ptr], ptr %6, i64 0, i64 0
  %24 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef %23)
  store ptr %24, ptr %7, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %25)
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %26)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %27

27:                                               ; preds = %18
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %4, align 4, !tbaa !5
  br label %14, !llvm.loop !11

30:                                               ; preds = %17
  %31 = load ptr, ptr %3, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %31)
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %32

32:                                               ; preds = %30
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %1, align 4, !tbaa !5
  br label %8, !llvm.loop !13

35:                                               ; preds = %11
  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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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"

; Function Attrs: mustprogress 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) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @roaring_bitmap_create() local_unnamed_addr #1

declare ptr @roaring_bitmap_or_many(i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @test_or_many_memory_leak() local_unnamed_addr #2 {
  %1 = alloca [2 x ptr], align 16
  %2 = getelementptr inbounds i8, ptr %1, i64 8
  br label %4

3:                                                ; preds = %4
  ret void

4:                                                ; preds = %0, %4
  %.010 = phi i32 [ 0, %0 ], [ %26, %4 ]
  %5 = call ptr @roaring_bitmap_create() #3
  %6 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %6, ptr %2, align 8, !tbaa !5
  %7 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %6) #3
  call void @roaring_bitmap_free(ptr noundef %7) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %8 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %8, ptr %2, align 8, !tbaa !5
  %9 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %8) #3
  call void @roaring_bitmap_free(ptr noundef %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %10 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %10, ptr %2, align 8, !tbaa !5
  %11 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %10) #3
  call void @roaring_bitmap_free(ptr noundef %11) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %12 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %12, ptr %2, align 8, !tbaa !5
  %13 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %12) #3
  call void @roaring_bitmap_free(ptr noundef %13) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %14 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %14, ptr %2, align 8, !tbaa !5
  %15 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %14) #3
  call void @roaring_bitmap_free(ptr noundef %15) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %16 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %16, ptr %2, align 8, !tbaa !5
  %17 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %16) #3
  call void @roaring_bitmap_free(ptr noundef %17) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %18 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %18, ptr %2, align 8, !tbaa !5
  %19 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %18) #3
  call void @roaring_bitmap_free(ptr noundef %19) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %20 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %20, ptr %2, align 8, !tbaa !5
  %21 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %20) #3
  call void @roaring_bitmap_free(ptr noundef %21) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %22 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %22, ptr %2, align 8, !tbaa !5
  %23 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %22) #3
  call void @roaring_bitmap_free(ptr noundef %23) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  %24 = call ptr @roaring_bitmap_create() #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  store ptr %5, ptr %1, align 16, !tbaa !5
  store ptr %24, ptr %2, align 8, !tbaa !5
  %25 = call ptr @roaring_bitmap_or_many(i64 noundef 2, ptr noundef nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %24) #3
  call void @roaring_bitmap_free(ptr noundef %25) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  call void @roaring_bitmap_free(ptr noundef %5) #3
  %26 = add nuw nsw i32 %.010, 1
  %exitcond.not = icmp eq i32 %26, 10
  br i1 %exitcond.not, label %3, label %4, !llvm.loop !9
}

attributes #0 = { mustprogress 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass