; 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.115 = external hidden unnamed_addr constant [43 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 void @_assert_true(i64 noundef, ptr noundef, ptr noundef, i32 noundef) #1

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

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

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

declare void @roaring_bitmap_to_uint32_array(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @array_equals(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #4

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

10:                                               ; preds = %25, %0
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp ult i32 %11, 50000
  br i1 %12, label %14, label %13

13:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %28

14:                                               ; preds = %10
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 30000
  br i1 %16, label %17, label %24

17:                                               ; preds = %14
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = load ptr, ptr %2, align 8, !tbaa !9
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %1, align 4, !tbaa !5
  %22 = sext i32 %20 to i64
  %23 = getelementptr inbounds i32, ptr %19, i64 %22
  store i32 %18, ptr %23, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %17, %14
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = add i32 %26, 1
  store i32 %27, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !11

28:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 70000, ptr %4, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %40, %28
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = icmp ult i32 %30, 130000
  br i1 %31, label %33, label %32

32:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %43

33:                                               ; preds = %29
  %34 = load i32, ptr %4, align 4, !tbaa !5
  %35 = load ptr, ptr %2, align 8, !tbaa !9
  %36 = load i32, ptr %1, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %1, align 4, !tbaa !5
  %38 = sext i32 %36 to i64
  %39 = getelementptr inbounds i32, ptr %35, i64 %38
  store i32 %34, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %33
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = add i32 %41, 17
  store i32 %42, ptr %4, align 4, !tbaa !5
  br label %29, !llvm.loop !13

43:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 196608, ptr %5, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %60, %43
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = icmp ult i32 %45, 262144
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %63

48:                                               ; preds = %44
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = urem i32 %49, 3
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %59

52:                                               ; preds = %48
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = load ptr, ptr %2, align 8, !tbaa !9
  %55 = load i32, ptr %1, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %1, align 4, !tbaa !5
  %57 = sext i32 %55 to i64
  %58 = getelementptr inbounds i32, ptr %54, i64 %57
  store i32 %53, ptr %58, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %52, %48
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = add i32 %61, 1
  store i32 %62, ptr %5, align 4, !tbaa !5
  br label %44, !llvm.loop !14

63:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %64 = load ptr, ptr %2, align 8, !tbaa !9
  %65 = load i32, ptr %1, align 4, !tbaa !5
  %66 = call ptr @make_roaring_from_array(ptr noundef %64, i32 noundef %65)
  store ptr %66, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  %68 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %67)
  store i64 %68, ptr %7, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %69 = load i64, ptr %7, align 8, !tbaa !15
  %70 = mul i64 %69, 4
  %71 = call noalias ptr @malloc(i64 noundef %70) #8
  store ptr %71, ptr %8, align 8, !tbaa !9
  %72 = load ptr, ptr %6, align 8, !tbaa !9
  %73 = load ptr, ptr %8, align 8, !tbaa !9
  call void @roaring_bitmap_to_uint32_array(ptr noundef %72, ptr noundef %73)
  %74 = load ptr, ptr %8, align 8, !tbaa !9
  %75 = load i64, ptr %7, align 8, !tbaa !15
  %76 = trunc i64 %75 to i32
  %77 = load ptr, ptr %2, align 8, !tbaa !9
  %78 = load i32, ptr %1, align 4, !tbaa !5
  %79 = call i32 @array_equals(ptr noundef %74, i32 noundef %76, ptr noundef %77, i32 noundef %78)
  %80 = sext i32 %79 to i64
  call void @_assert_true(i64 noundef %80, ptr noundef @.str.115, ptr noundef @.str.2, i32 noundef 2311)
  %81 = load ptr, ptr %6, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %81)
  %82 = load ptr, ptr %8, align 8, !tbaa !9
  call void @free(ptr noundef %82) #6
  %83 = load ptr, ptr %2, align 8, !tbaa !9
  call void @free(ptr noundef %83) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #5

; Function Attrs: nounwind uwtable
declare hidden ptr @make_roaring_from_array(ptr noundef, i32 noundef) #4

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 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 #3 = { 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 #4 = { 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 #5 = { nounwind allocsize(0,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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { 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 = !{!"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}
!14 = distinct !{!14, !12}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}


; 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.115 = external hidden unnamed_addr constant [43 x i8], align 1

declare void @roaring_bitmap_free(ptr noundef) local_unnamed_addr #0

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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) local_unnamed_addr #0

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

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

declare void @roaring_bitmap_to_uint32_array(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @array_equals(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @test_conversion_to_int_array() local_unnamed_addr #3 {
  %1 = tail call noalias dereferenceable_or_null(400000) ptr @calloc(i64 noundef 100000, i64 noundef 4) #5
  br label %2

2:                                                ; preds = %7, %0
  %.035 = phi i32 [ 0, %0 ], [ %9, %7 ]
  %.02934 = phi i32 [ 0, %0 ], [ %12, %7 ]
  %.not32 = icmp eq i32 %.02934, 30000
  br i1 %.not32, label %7, label %3

3:                                                ; preds = %2
  %4 = add nsw i32 %.035, 1
  %5 = sext i32 %.035 to i64
  %6 = getelementptr inbounds i32, ptr %1, i64 %5
  store i32 %.02934, ptr %6, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %3, %2
  %.1 = phi i32 [ %4, %3 ], [ %.035, %2 ]
  %8 = or disjoint i32 %.02934, 1
  %9 = add nsw i32 %.1, 1
  %10 = sext i32 %.1 to i64
  %11 = getelementptr inbounds i32, ptr %1, i64 %10
  store i32 %8, ptr %11, align 4, !tbaa !5
  %12 = add nuw nsw i32 %.02934, 2
  %exitcond.not.1 = icmp eq i32 %12, 50000
  br i1 %exitcond.not.1, label %.preheader33.preheader, label %2, !llvm.loop !9

.preheader33.preheader:                           ; preds = %7
  %13 = sext i32 %9 to i64
  %14 = add i32 %9, 3530
  %invariant.gep = getelementptr i32, ptr %1, i64 %13
  %invariant.gep46 = getelementptr i8, ptr %1, i64 32
  %invariant.gep48 = getelementptr i32, ptr %invariant.gep46, i64 %13
  %invariant.gep50 = getelementptr i8, ptr %1, i64 64
  %invariant.gep52 = getelementptr i32, ptr %invariant.gep50, i64 %13
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %.preheader33.preheader
  %index = phi i64 [ 0, %.preheader33.preheader ], [ %index.next.2, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 70000, i32 70017, i32 70034, i32 70051>, %.preheader33.preheader ], [ %vec.ind.next.2, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 68, i32 68, i32 68, i32 68>
  %gep = getelementptr i32, ptr %invariant.gep, i64 %index
  %15 = getelementptr inbounds i8, ptr %gep, i64 16
  store <4 x i32> %vec.ind, ptr %gep, align 4, !tbaa !5
  store <4 x i32> %step.add, ptr %15, align 4, !tbaa !5
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 136, i32 136, i32 136, i32 136>
  %step.add.1 = add <4 x i32> %vec.ind, <i32 204, i32 204, i32 204, i32 204>
  %gep49 = getelementptr i32, ptr %invariant.gep48, i64 %index
  %16 = getelementptr inbounds i8, ptr %gep49, i64 16
  store <4 x i32> %vec.ind.next, ptr %gep49, align 4, !tbaa !5
  store <4 x i32> %step.add.1, ptr %16, align 4, !tbaa !5
  %vec.ind.next.1 = add <4 x i32> %vec.ind, <i32 272, i32 272, i32 272, i32 272>
  %step.add.2 = add <4 x i32> %vec.ind, <i32 340, i32 340, i32 340, i32 340>
  %gep53 = getelementptr i32, ptr %invariant.gep52, i64 %index
  %17 = getelementptr inbounds i8, ptr %gep53, i64 16
  store <4 x i32> %vec.ind.next.1, ptr %gep53, align 4, !tbaa !5
  store <4 x i32> %step.add.2, ptr %17, align 4, !tbaa !5
  %index.next.2 = add nuw nsw i64 %index, 24
  %vec.ind.next.2 = add <4 x i32> %vec.ind, <i32 408, i32 408, i32 408, i32 408>
  %18 = icmp eq i64 %index.next.2, 3528
  br i1 %18, label %.preheader33, label %vector.body, !llvm.loop !11

.preheader33:                                     ; preds = %vector.body
  %19 = getelementptr i32, ptr %1, i64 %13
  %20 = getelementptr i8, ptr %19, i64 14112
  store i32 129976, ptr %20, align 4, !tbaa !5
  %21 = getelementptr i32, ptr %1, i64 %13
  %22 = getelementptr i8, ptr %21, i64 14116
  store i32 129993, ptr %22, align 4, !tbaa !5
  br label %.preheader

23:                                               ; preds = %42
  %24 = tail call ptr @make_roaring_from_array(ptr noundef %1, i32 noundef %.4.1)
  %25 = tail call i64 @roaring_bitmap_get_cardinality(ptr noundef %24) #6
  %26 = shl i64 %25, 2
  %27 = tail call noalias ptr @malloc(i64 noundef %26) #7
  tail call void @roaring_bitmap_to_uint32_array(ptr noundef %24, ptr noundef %27) #6
  %28 = trunc i64 %25 to i32
  %29 = tail call i32 @array_equals(ptr noundef %27, i32 noundef %28, ptr noundef %1, i32 noundef %.4.1)
  %30 = sext i32 %29 to i64
  tail call void @_assert_true(i64 noundef %30, ptr noundef nonnull @.str.115, ptr noundef nonnull @.str.2, i32 noundef 2311) #6
  tail call void @roaring_bitmap_free(ptr noundef %24) #6
  tail call void @free(ptr noundef %27) #6
  tail call void @free(ptr noundef %1) #6
  ret void

.preheader:                                       ; preds = %42, %.preheader33
  %.339 = phi i32 [ %14, %.preheader33 ], [ %.4.1, %42 ]
  %.03138 = phi i32 [ 196608, %.preheader33 ], [ %43, %42 ]
  %31 = urem i32 %.03138, 3
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %.preheader.1, label %32

32:                                               ; preds = %.preheader
  %33 = add nsw i32 %.339, 1
  %34 = sext i32 %.339 to i64
  %35 = getelementptr inbounds i32, ptr %1, i64 %34
  store i32 %.03138, ptr %35, align 4, !tbaa !5
  br label %.preheader.1

.preheader.1:                                     ; preds = %.preheader, %32
  %.4 = phi i32 [ %33, %32 ], [ %.339, %.preheader ]
  %36 = or disjoint i32 %.03138, 1
  %37 = urem i32 %36, 3
  %.not.1 = icmp eq i32 %37, 0
  br i1 %.not.1, label %42, label %38

38:                                               ; preds = %.preheader.1
  %39 = add nsw i32 %.4, 1
  %40 = sext i32 %.4 to i64
  %41 = getelementptr inbounds i32, ptr %1, i64 %40
  store i32 %36, ptr %41, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %38, %.preheader.1
  %.4.1 = phi i32 [ %39, %38 ], [ %.4, %.preheader.1 ]
  %43 = add nuw nsw i32 %.03138, 2
  %exitcond42.not.1 = icmp eq i32 %43, 262144
  br i1 %exitcond42.not.1, label %23, label %.preheader, !llvm.loop !14
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden ptr @make_roaring_from_array(ptr noundef, i32 noundef) local_unnamed_addr #3

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 = { 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 #2 = { 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 #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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #5 = { nounwind allocsize(0,1) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass