; LLVM IR from jermp/2i_bench :: external/CRoaring/tests (array_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 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.16 = 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

declare ptr @array_container_create() #1

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

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

declare void @array_container_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 void @_assert_int_equal(i64 noundef, i64 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @array_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 = %74, %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 %77

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %14 = call ptr @array_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, ptr noundef @.str.1, i32 noundef 133)
  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 = %27, %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 %31

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
  %25 = call zeroext i1 @array_container_add(ptr noundef %22, i16 noundef zeroext %24)
  %26 = zext i1 %25 to i64
  call void @_assert_true(i64 noundef %26, ptr noundef @.str.15, ptr noundef @.str.1, i32 noundef 136)
  br label %27

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

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

47:                                               ; preds = %68, %31
  %48 = load i32, ptr %8, align 4, !tbaa !13
  %49 = load i32, ptr %7, align 4, !tbaa !13
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %52, label %51

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

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

68:                                               ; preds = %52
  %69 = load i32, ptr %8, align 4, !tbaa !13
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %8, align 4, !tbaa !13
  br label %47, !llvm.loop !15

71:                                               ; preds = %51
  %72 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %72) #6
  %73 = load ptr, ptr %3, align 8, !tbaa !9
  call void @array_container_free(ptr noundef %73)
  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 %74

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

77:                                               ; preds = %12
  ret void
}

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

declare i32 @array_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 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [95 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [4 x i8], align 1

declare ptr @array_container_create() 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 zeroext i1 @array_container_add(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

declare void @array_container_free(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: inlinehint nounwind uwtable
declare hidden i32 @array_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 ], [ %20, %._crit_edge ]
  %3 = tail call ptr @array_container_create() #5
  %4 = ptrtoint ptr %3 to i64
  tail call void @_assert_true(i64 noundef %4, ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 133) #5
  br label %14

5:                                                ; preds = %14
  %6 = tail call i32 @array_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.16, ptr noundef nonnull @.str.1, i32 noundef 141) #5
  %11 = tail call i32 @array_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 144) #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 ], [ %18, %14 ]
  %15 = trunc nuw i64 %.02526 to i16
  %16 = tail call zeroext i1 @array_container_add(ptr noundef %3, i16 noundef zeroext %15)
  %17 = zext i1 %16 to i64
  tail call void @_assert_true(i64 noundef %17, ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i32 noundef 136) #5
  %18 = add nuw nsw i64 %.02526, %.02428
  %19 = icmp ult i64 %18, 65536
  br i1 %19, label %14, label %5, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %5
  tail call void @free(ptr noundef %9) #5
  tail call void @array_container_free(ptr noundef %3) #5
  %20 = shl nuw nsw i64 %.02428, 1
  %21 = icmp ult i64 %.02428, 64
  br i1 %21, 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 ]
  %22 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !8
  %24 = zext i32 %23 to i64
  %25 = getelementptr i8, ptr %22, i64 -4
  %26 = load i32, ptr %25, align 4, !tbaa !8
  %27 = zext i32 %26 to i64
  %28 = add nuw nsw i64 %.02428, %27
  tail call void @_assert_int_equal(i64 noundef %24, i64 noundef %28, ptr noundef nonnull @.str.1, i32 noundef 147) #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 @array_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