; 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_uint32_iterator_s = type { ptr, i32, i32, i32, i32, i8, ptr, i8, i32 }

@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__.check_iterate_to_end = external hidden unnamed_addr constant [28 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [40 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 ptr @roaring_bitmap_create() #1

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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) #1

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

declare void @roaring_bitmap_flip_inplace(ptr noundef, i64 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @check_iterate_to_end() #3 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.roaring_uint32_iterator_s, align 8
  %5 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  store i64 4294967296, 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 !5
  br label %6

6:                                                ; preds = %51, %0
  %7 = load i64, ptr %2, align 8, !tbaa !5
  %8 = icmp ult i64 %7, 1024
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %11 = call ptr @roaring_bitmap_create()
  store ptr %11, ptr %3, align 8, !tbaa !9
  %12 = load ptr, ptr %3, align 8, !tbaa !9
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = sub i64 %13, %14
  %16 = load i64, ptr %1, align 8, !tbaa !5
  call void @roaring_bitmap_flip_inplace(ptr noundef %12, i64 noundef %15, i64 noundef %16)
  call void @llvm.lifetime.start.p0(i64 48, ptr %4) #4
  %17 = load ptr, ptr %3, align 8, !tbaa !9
  call void @roaring_init_iterator(ptr noundef %17, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %34, %10
  %19 = getelementptr inbounds %struct.roaring_uint32_iterator_s, ptr %4, i32 0, i32 5
  %20 = load i8, ptr %19, align 8, !tbaa !11, !range !15, !noundef !16
  %21 = trunc i8 %20 to i1
  br i1 %21, label %22, label %38

22:                                               ; preds = %18
  %23 = getelementptr inbounds %struct.roaring_uint32_iterator_s, ptr %4, i32 0, i32 4
  %24 = load i32, ptr %23, align 4, !tbaa !17
  %25 = zext i32 %24 to i64
  %26 = load i64, ptr %2, align 8, !tbaa !5
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = sub i64 %26, %27
  %29 = add i64 %25, %28
  %30 = load i64, ptr %1, align 8, !tbaa !5
  %31 = icmp eq i64 %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %22
  br label %34

33:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.37, ptr noundef @.str.2, i32 noundef 367, ptr noundef @__PRETTY_FUNCTION__.check_iterate_to_end) #5
  unreachable

34:                                               ; preds = %32
  %35 = load i64, ptr %5, align 8, !tbaa !5
  %36 = add i64 %35, 1
  store i64 %36, ptr %5, align 8, !tbaa !5
  %37 = call zeroext i1 @roaring_advance_uint32_iterator(ptr noundef %4)
  br label %18, !llvm.loop !18

38:                                               ; preds = %18
  %39 = load i64, ptr %5, align 8, !tbaa !5
  %40 = load i64, ptr %2, align 8, !tbaa !5
  %41 = icmp eq i64 %39, %40
  %42 = zext i1 %41 to i32
  %43 = sext i32 %42 to i64
  call void @_assert_true(i64 noundef %43, ptr noundef @.str.38, ptr noundef @.str.2, i32 noundef 371)
  %44 = load ptr, ptr %3, align 8, !tbaa !9
  %45 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %44)
  %46 = load i64, ptr %2, align 8, !tbaa !5
  %47 = icmp eq i64 %45, %46
  %48 = zext i1 %47 to i32
  %49 = sext i32 %48 to i64
  call void @_assert_true(i64 noundef %49, ptr noundef @.str.39, ptr noundef @.str.2, i32 noundef 372)
  %50 = load ptr, ptr %3, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %50)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %51

51:                                               ; preds = %38
  %52 = load i64, ptr %2, align 8, !tbaa !5
  %53 = add i64 %52, 1
  store i64 %53, ptr %2, align 8, !tbaa !5
  br label %6, !llvm.loop !20

54:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

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

declare zeroext i1 @roaring_advance_uint32_iterator(ptr noundef) #1

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 = !{!"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, !14, i64 24}
!12 = !{!"roaring_uint32_iterator_s", !10, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !14, i64 24, !10, i64 32, !7, i64 40, !13, i64 44}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !13, i64 20}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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

%struct.roaring_uint32_iterator_s = type { ptr, i32, i32, i32, i32, i8, ptr, i8, i32 }

@.str.2 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [50 x i8], align 1
@__PRETTY_FUNCTION__.check_iterate_to_end = external hidden unnamed_addr constant [28 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: mustprogress 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) local_unnamed_addr #1

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

declare ptr @roaring_bitmap_create() local_unnamed_addr #1

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

declare i64 @roaring_bitmap_get_cardinality(ptr noundef) local_unnamed_addr #1

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

declare void @roaring_bitmap_flip_inplace(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @check_iterate_to_end() local_unnamed_addr #3 {
  %1 = alloca %struct.roaring_uint32_iterator_s, align 8
  %2 = getelementptr inbounds i8, ptr %1, i64 24
  %3 = getelementptr inbounds i8, ptr %1, i64 20
  br label %5

4:                                                ; preds = %._crit_edge
  ret void

5:                                                ; preds = %0, %._crit_edge
  %.01518 = phi i64 [ 0, %0 ], [ %26, %._crit_edge ]
  %6 = call ptr @roaring_bitmap_create() #4
  %7 = sub nuw nsw i64 4294967296, %.01518
  call void @roaring_bitmap_flip_inplace(ptr noundef %6, i64 noundef %7, i64 noundef 4294967296) #4
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %1) #4
  call void @roaring_init_iterator(ptr noundef %6, ptr noundef nonnull %1) #4
  %8 = load i8, ptr %2, align 8, !tbaa !5, !range !12, !noundef !13
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5, %16
  %.017 = phi i64 [ %17, %16 ], [ 0, %5 ]
  %10 = load i32, ptr %3, align 4, !tbaa !14
  %11 = zext i32 %10 to i64
  %12 = sub i64 %.01518, %.017
  %13 = add i64 %12, %11
  %14 = icmp eq i64 %13, 4294967296
  br i1 %14, label %16, label %15

15:                                               ; preds = %.lr.ph
  call void @__assert_fail(ptr noundef nonnull @.str.37, ptr noundef nonnull @.str.2, i32 noundef 367, ptr noundef nonnull @__PRETTY_FUNCTION__.check_iterate_to_end) #5
  unreachable

16:                                               ; preds = %.lr.ph
  %17 = add i64 %.017, 1
  %18 = call zeroext i1 @roaring_advance_uint32_iterator(ptr noundef nonnull %1) #4
  %19 = load i8, ptr %2, align 8, !tbaa !5, !range !12, !noundef !13
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %16, %5
  %.0.lcssa = phi i64 [ 0, %5 ], [ %17, %16 ]
  %21 = icmp eq i64 %.0.lcssa, %.01518
  %22 = zext i1 %21 to i64
  call void @_assert_true(i64 noundef %22, ptr noundef nonnull @.str.38, ptr noundef nonnull @.str.2, i32 noundef 371) #4
  %23 = call i64 @roaring_bitmap_get_cardinality(ptr noundef %6) #4
  %24 = icmp eq i64 %23, %.01518
  %25 = zext i1 %24 to i64
  call void @_assert_true(i64 noundef %25, ptr noundef nonnull @.str.39, ptr noundef nonnull @.str.2, i32 noundef 372) #4
  call void @roaring_bitmap_free(ptr noundef %6) #4
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %1) #4
  %26 = add nuw nsw i64 %.01518, 1
  %exitcond.not = icmp eq i64 %26, 1024
  br i1 %exitcond.not, label %4, label %5, !llvm.loop !17
}

declare void @roaring_init_iterator(ptr noundef, ptr noundef) local_unnamed_addr #1

declare zeroext i1 @roaring_advance_uint32_iterator(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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, !11, i64 24}
!6 = !{!"roaring_uint32_iterator_s", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !11, i64 24, !7, i64 32, !8, i64 40, !10, i64 44}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !10, i64 20}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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