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

%struct.roaring_bitmap_s = type { %struct.roaring_array_s }
%struct.roaring_array_s = type { i32, i32, ptr, ptr, ptr, i8 }

@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.179 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__.test_frozen_serialization_max_containers = external hidden unnamed_addr constant [48 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 @roaring_bitmap_create() #1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare void @roaring_bitmap_add(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @frozen_serialization_compare(ptr noundef) #3

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

4:                                                ; preds = %13, %0
  %5 = load i64, ptr %2, align 8, !tbaa !9
  %6 = icmp slt i64 %5, 65536
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  br label %16

8:                                                ; preds = %4
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  %10 = load i64, ptr %2, align 8, !tbaa !9
  %11 = mul nsw i64 65536, %10
  %12 = trunc i64 %11 to i32
  call void @roaring_bitmap_add(ptr noundef %9, i32 noundef %12)
  br label %13

13:                                               ; preds = %8
  %14 = load i64, ptr %2, align 8, !tbaa !9
  %15 = add nsw i64 %14, 1
  store i64 %15, ptr %2, align 8, !tbaa !9
  br label %4, !llvm.loop !11

16:                                               ; preds = %7
  %17 = load ptr, ptr %1, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.roaring_bitmap_s, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.roaring_array_s, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = icmp eq i32 %20, 65536
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  br label %24

23:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.179, ptr noundef @.str.2, i32 noundef 3971, ptr noundef @__PRETTY_FUNCTION__.test_frozen_serialization_max_containers) #5
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  call void @frozen_serialization_compare(ptr noundef %25)
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  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 = { noreturn 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 #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 }
attributes #5 = { noreturn 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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !16, i64 0}
!14 = !{!"roaring_bitmap_s", !15, i64 0}
!15 = !{!"roaring_array_s", !16, i64 0, !16, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32}
!16 = !{!"int", !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.179 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__.test_frozen_serialization_max_containers = external hidden unnamed_addr constant [48 x i8], align 1

declare ptr @roaring_bitmap_create() local_unnamed_addr #0

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @frozen_serialization_compare(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @test_frozen_serialization_max_containers() local_unnamed_addr #2 {
  %1 = tail call ptr @roaring_bitmap_create() #3
  br label %5

2:                                                ; preds = %5
  %3 = load i32, ptr %1, align 8, !tbaa !5
  %4 = icmp eq i32 %3, 65536
  br i1 %4, label %9, label %8

5:                                                ; preds = %0, %5
  %.05 = phi i64 [ 0, %0 ], [ %7, %5 ]
  %.0.tr = trunc nuw i64 %.05 to i32
  %6 = shl nuw i32 %.0.tr, 16
  tail call void @roaring_bitmap_add(ptr noundef %1, i32 noundef %6) #3
  %7 = add nuw nsw i64 %.05, 1
  %exitcond.not = icmp eq i64 %7, 65536
  br i1 %exitcond.not, label %2, label %5, !llvm.loop !12

8:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.179, ptr noundef nonnull @.str.2, i32 noundef 3971, ptr noundef nonnull @__PRETTY_FUNCTION__.test_frozen_serialization_max_containers) #4
  unreachable

9:                                                ; preds = %2
  tail call void @frozen_serialization_compare(ptr noundef nonnull %1)
  ret void
}

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 = { noreturn 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 #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 }
attributes #4 = { noreturn 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, !8, i64 0}
!6 = !{!"roaring_bitmap_s", !7, i64 0}
!7 = !{!"roaring_array_s", !8, i64 0, !8, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !9, i64 32}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass