; LLVM IR from jermp/2i_bench :: external/CRoaring/tests (bitset_container_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.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 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

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

declare ptr @bitset_container_create() #1

declare void @bitset_container_free(ptr noundef) #1

declare void @_assert_true(i64 noundef, ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @bitset_container_set(ptr noundef, i16 noundef zeroext) #2

declare void @_assert_int_equal(i64 noundef, i64 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @bitset_container_cardinality(ptr noundef) #2

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

9:                                                ; preds = %72, %0
  %10 = load i64, ptr %1, align 8, !tbaa !5
  %11 = icmp ult i64 %10, 128
  br i1 %11, label %13, label %12

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

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %14 = call ptr @bitset_container_create()
  store ptr %14, ptr %3, align 8, !tbaa !9
  %15 = load ptr, ptr %3, align 8, !tbaa !9
  %16 = ptrtoint ptr %15 to i64
  call void @_assert_true(i64 noundef %16, ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 205)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  store i64 0, ptr %4, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %25, %13
  %18 = load i64, ptr %4, align 8, !tbaa !5
  %19 = icmp ult i64 %18, 65536
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %17
  %22 = load ptr, ptr %3, align 8, !tbaa !9
  %23 = load i64, ptr %4, align 8, !tbaa !5
  %24 = trunc i64 %23 to i16
  call void @bitset_container_set(ptr noundef %22, i16 noundef zeroext %24)
  br label %25

25:                                               ; preds = %21
  %26 = load i64, ptr %1, align 8, !tbaa !5
  %27 = load i64, ptr %4, align 8, !tbaa !5
  %28 = add i64 %27, %26
  store i64 %28, ptr %4, align 8, !tbaa !5
  br label %17, !llvm.loop !11

29:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %30 = load ptr, ptr %3, align 8, !tbaa !9
  %31 = call i32 @bitset_container_cardinality(ptr noundef %30)
  store i32 %31, ptr %5, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %32 = load i32, ptr %5, align 4, !tbaa !13
  %33 = sext i32 %32 to i64
  %34 = mul i64 4, %33
  %35 = call noalias ptr @malloc(i64 noundef %34) #7
  store ptr %35, ptr %6, align 8, !tbaa !9
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = ptrtoint ptr %36 to i64
  call void @_assert_true(i64 noundef %37, ptr noundef @.str.14, ptr noundef @.str.1, i32 noundef 214)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  %39 = load ptr, ptr %3, align 8, !tbaa !9
  %40 = call i32 @bitset_container_to_uint32_array(ptr noundef %38, ptr noundef %39, i32 noundef 0)
  store i32 %40, ptr %7, align 4, !tbaa !13
  %41 = load i32, ptr %5, align 4, !tbaa !13
  %42 = sext i32 %41 to i64
  %43 = load i32, ptr %7, align 4, !tbaa !13
  %44 = sext i32 %43 to i64
  call void @_assert_int_equal(i64 noundef %42, i64 noundef %44, ptr noundef @.str.1, i32 noundef 218)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 1, ptr %8, align 4, !tbaa !13
  br label %45

45:                                               ; preds = %66, %29
  %46 = load i32, ptr %8, align 4, !tbaa !13
  %47 = load i32, ptr %7, align 4, !tbaa !13
  %48 = icmp slt i32 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %69

50:                                               ; preds = %45
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = load i32, ptr %8, align 4, !tbaa !13
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %51, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !13
  %56 = zext i32 %55 to i64
  %57 = load i64, ptr %1, align 8, !tbaa !5
  %58 = load ptr, ptr %6, align 8, !tbaa !9
  %59 = load i32, ptr %8, align 4, !tbaa !13
  %60 = sub nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i32, ptr %58, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !13
  %64 = zext i32 %63 to i64
  %65 = add i64 %57, %64
  call void @_assert_int_equal(i64 noundef %56, i64 noundef %65, ptr noundef @.str.1, i32 noundef 221)
  br label %66

66:                                               ; preds = %50
  %67 = load i32, ptr %8, align 4, !tbaa !13
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %8, align 4, !tbaa !13
  br label %45, !llvm.loop !15

69:                                               ; preds = %49
  %70 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %70) #6
  %71 = load ptr, ptr %3, align 8, !tbaa !9
  call void @bitset_container_free(ptr noundef %71)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  br label %72

72:                                               ; preds = %69
  %73 = load i64, ptr %1, align 8, !tbaa !5
  %74 = mul i64 %73, 2
  store i64 %74, ptr %1, align 8, !tbaa !5
  br label %9, !llvm.loop !16

75:                                               ; preds = %12
  ret void
}

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

declare i32 @bitset_container_to_uint32_array(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

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 = { inlinehint 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 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 #4 = { nounwind allocsize(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 #5 = { nounwind "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }

!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 = !{!"long", !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 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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"

@.str.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 x i8], align 1

declare ptr @bitset_container_create() local_unnamed_addr #0

declare void @bitset_container_free(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @bitset_container_set(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @bitset_container_cardinality(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @to_uint32_array_test() local_unnamed_addr #2 {
  br label %2

1:                                                ; preds = %._crit_edge
  ret void

2:                                                ; preds = %0, %._crit_edge
  %.02428 = phi i64 [ 1, %0 ], [ %18, %._crit_edge ]
  %3 = tail call ptr @bitset_container_create() #5
  %4 = ptrtoint ptr %3 to i64
  tail call void @_assert_true(i64 noundef %4, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 205) #5
  br label %14

5:                                                ; preds = %14
  %6 = tail call i32 @bitset_container_cardinality(ptr noundef %3)
  %7 = sext i32 %6 to i64
  %8 = shl nsw i64 %7, 2
  %9 = tail call noalias ptr @malloc(i64 noundef %8) #6
  %10 = ptrtoint ptr %9 to i64
  tail call void @_assert_true(i64 noundef %10, ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.1, i32 noundef 214) #5
  %11 = tail call i32 @bitset_container_to_uint32_array(ptr noundef %9, ptr noundef %3, i32 noundef 0) #5
  %12 = sext i32 %11 to i64
  tail call void @_assert_int_equal(i64 noundef %7, i64 noundef %12, ptr noundef nonnull @.str.1, i32 noundef 218) #5
  %13 = icmp sgt i32 %11, 1
  br i1 %13, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = zext nneg i32 %11 to i64
  br label %.lr.ph

14:                                               ; preds = %2, %14
  %.02526 = phi i64 [ 0, %2 ], [ %16, %14 ]
  %15 = trunc nuw i64 %.02526 to i16
  tail call void @bitset_container_set(ptr noundef %3, i16 noundef zeroext %15)
  %16 = add nuw nsw i64 %.02526, %.02428
  %17 = icmp ult i64 %16, 65536
  br i1 %17, label %14, label %5, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %5
  tail call void @free(ptr noundef %9) #5
  tail call void @bitset_container_free(ptr noundef %3) #5
  %18 = shl nuw nsw i64 %.02428, 1
  %19 = icmp ult i64 %.02428, 64
  br i1 %19, label %2, label %1, !llvm.loop !7

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %20 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %21 = load i32, ptr %20, align 4, !tbaa !8
  %22 = zext i32 %21 to i64
  %23 = getelementptr i8, ptr %20, i64 -4
  %24 = load i32, ptr %23, align 4, !tbaa !8
  %25 = zext i32 %24 to i64
  %26 = add nuw nsw i64 %.02428, %25
  tail call void @_assert_int_equal(i64 noundef %22, i64 noundef %26, ptr noundef nonnull @.str.1, i32 noundef 221) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

declare i32 @bitset_container_to_uint32_array(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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 = { inlinehint 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 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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"}
!7 = distinct !{!7, !6}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = distinct !{!12, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass