; LLVM IR from jermp/2i_bench :: external/CRoaring/tests (run_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 [93 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 @run_container_create() #1

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

declare zeroext i1 @run_container_add(ptr noundef, i16 noundef zeroext) #1

declare void @run_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 @run_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 i32, align 4
  %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 = %73, %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 %76

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  %14 = call ptr @run_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 126)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %17

17:                                               ; preds = %26, %13
  %18 = load i32, ptr %4, align 4, !tbaa !11
  %19 = icmp slt i32 %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 4, ptr %4) #6
  br label %32

21:                                               ; preds = %17
  %22 = load ptr, ptr %3, align 8, !tbaa !9
  %23 = load i32, ptr %4, align 4, !tbaa !11
  %24 = trunc i32 %23 to i16
  %25 = call zeroext i1 @run_container_add(ptr noundef %22, i16 noundef zeroext %24)
  br label %26

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

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

46:                                               ; preds = %67, %32
  %47 = load i32, ptr %8, align 4, !tbaa !11
  %48 = load i32, ptr %7, align 4, !tbaa !11
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %51, label %50

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

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

67:                                               ; preds = %51
  %68 = load i32, ptr %8, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %8, align 4, !tbaa !11
  br label %46, !llvm.loop !15

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

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

76:                                               ; preds = %12
  ret void
}

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

declare i32 @run_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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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 [93 x i8], align 1

declare ptr @run_container_create() local_unnamed_addr #0

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

declare zeroext i1 @run_container_add(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

declare void @run_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 @run_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
  %.02327 = phi i64 [ 1, %0 ], [ %19, %._crit_edge ]
  %3 = tail call ptr @run_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 126) #5
  %5 = trunc nuw nsw i64 %.02327 to i32
  br label %14

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

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

14:                                               ; preds = %2, %14
  %.02425 = phi i32 [ 0, %2 ], [ %17, %14 ]
  %15 = trunc i32 %.02425 to i16
  %16 = tail call zeroext i1 @run_container_add(ptr noundef %3, i16 noundef zeroext %15) #5
  %17 = add nuw nsw i32 %.02425, %5
  %18 = icmp ult i32 %17, 65536
  br i1 %18, label %14, label %6, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %6
  tail call void @free(ptr noundef %10) #5
  tail call void @run_container_free(ptr noundef %3) #5
  %19 = shl nuw nsw i64 %.02327, 1
  %20 = icmp ult i64 %.02327, 64
  br i1 %20, 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 ]
  %21 = getelementptr inbounds i32, ptr %10, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !8
  %23 = zext i32 %22 to i64
  %24 = getelementptr i8, ptr %21, i64 -4
  %25 = load i32, ptr %24, align 4, !tbaa !8
  %26 = zext i32 %25 to i64
  %27 = add nuw nsw i64 %.02327, %26
  tail call void @_assert_int_equal(i64 noundef %23, i64 noundef %27, ptr noundef nonnull @.str.1, i32 noundef 138) #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 @run_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,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass