; 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.146 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__.test_previous_iterator = external hidden unnamed_addr constant [37 x i8], align 1
@.str.147 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.148 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.149 = external hidden unnamed_addr constant [19 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

; 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 @convert_all_containers(ptr noundef, i8 noundef zeroext) #3

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

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

declare zeroext i1 @roaring_previous_uint32_iterator(ptr noundef) #1

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

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

10:                                               ; preds = %22, %1
  %11 = load i32, ptr %6, align 4, !tbaa !10
  %12 = load i32, ptr %4, align 4, !tbaa !10
  %13 = icmp ult i32 %11, %12
  br i1 %13, label %15, label %14

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

15:                                               ; preds = %10
  %16 = load ptr, ptr %5, align 8, !tbaa !8
  %17 = load ptr, ptr %3, align 8, !tbaa !8
  %18 = load i32, ptr %6, align 4, !tbaa !10
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds i32, ptr %17, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !10
  call void @roaring_bitmap_add(ptr noundef %16, i32 noundef %21)
  br label %22

22:                                               ; preds = %15
  %23 = load i32, ptr %6, align 4, !tbaa !10
  %24 = add i32 %23, 1
  store i32 %24, ptr %6, align 4, !tbaa !10
  br label %10, !llvm.loop !12

25:                                               ; preds = %14
  %26 = load i8, ptr %2, align 1, !tbaa !5
  %27 = zext i8 %26 to i32
  %28 = icmp ne i32 %27, 255
  br i1 %28, label %29, label %32

29:                                               ; preds = %25
  %30 = load ptr, ptr %5, align 8, !tbaa !8
  %31 = load i8, ptr %2, align 1, !tbaa !5
  call void @convert_all_containers(ptr noundef %30, i8 noundef zeroext %31)
  br label %32

32:                                               ; preds = %29, %25
  call void @llvm.lifetime.start.p0(i64 48, ptr %7) #5
  %33 = load ptr, ptr %5, align 8, !tbaa !8
  call void @roaring_init_iterator_last(ptr noundef %33, ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !10
  br label %34

34:                                               ; preds = %65, %32
  %35 = getelementptr inbounds %struct.roaring_uint32_iterator_s, ptr %7, i32 0, i32 5
  %36 = load i8, ptr %35, align 8, !tbaa !14, !range !17, !noundef !18
  %37 = trunc i8 %36 to i1
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  br label %40

39:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.146, ptr noundef @.str.2, i32 noundef 3489, ptr noundef @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

40:                                               ; preds = %38
  %41 = load i32, ptr %8, align 4, !tbaa !10
  %42 = add i32 %41, 1
  store i32 %42, ptr %8, align 4, !tbaa !10
  %43 = load i32, ptr %4, align 4, !tbaa !10
  %44 = zext i32 %43 to i64
  %45 = load i32, ptr %8, align 4, !tbaa !10
  %46 = zext i32 %45 to i64
  %47 = sub nsw i64 %44, %46
  %48 = icmp sge i64 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %40
  br label %51

50:                                               ; preds = %40
  call void @__assert_fail(ptr noundef @.str.147, ptr noundef @.str.2, i32 noundef 3491, ptr noundef @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

51:                                               ; preds = %49
  %52 = load ptr, ptr %3, align 8, !tbaa !8
  %53 = load i32, ptr %4, align 4, !tbaa !10
  %54 = load i32, ptr %8, align 4, !tbaa !10
  %55 = sub i32 %53, %54
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr %52, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !10
  %59 = getelementptr inbounds %struct.roaring_uint32_iterator_s, ptr %7, i32 0, i32 4
  %60 = load i32, ptr %59, align 4, !tbaa !19
  %61 = icmp eq i32 %58, %60
  br i1 %61, label %62, label %63

62:                                               ; preds = %51
  br label %64

63:                                               ; preds = %51
  call void @__assert_fail(ptr noundef @.str.148, ptr noundef @.str.2, i32 noundef 3492, ptr noundef @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

64:                                               ; preds = %62
  br label %65

65:                                               ; preds = %64
  %66 = call zeroext i1 @roaring_previous_uint32_iterator(ptr noundef %7)
  br i1 %66, label %34, label %67, !llvm.loop !20

67:                                               ; preds = %65
  %68 = load i32, ptr %4, align 4, !tbaa !10
  %69 = load i32, ptr %8, align 4, !tbaa !10
  %70 = icmp eq i32 %68, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  br label %73

72:                                               ; preds = %67
  call void @__assert_fail(ptr noundef @.str.149, ptr noundef @.str.2, i32 noundef 3495, ptr noundef @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

73:                                               ; preds = %71
  %74 = load ptr, ptr %5, align 8, !tbaa !8
  call void @roaring_bitmap_free(ptr noundef %74)
  %75 = load ptr, ptr %3, align 8, !tbaa !8
  call void @free(ptr noundef %75) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  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 "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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !16, i64 24}
!15 = !{!"roaring_uint32_iterator_s", !9, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !16, i64 24, !9, i64 32, !6, i64 40, !11, i64 44}
!16 = !{!"_Bool", !6, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!15, !11, i64 20}
!20 = distinct !{!20, !13}


; 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.146 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__.test_previous_iterator = external hidden unnamed_addr constant [37 x i8], align 1
@.str.147 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.148 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.149 = external hidden unnamed_addr constant [19 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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @convert_all_containers(ptr noundef, i8 noundef zeroext) local_unnamed_addr #3

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @test_previous_iterator(i8 noundef zeroext %0) local_unnamed_addr #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca %struct.roaring_uint32_iterator_s, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @test_iterator_generate_data(ptr noundef nonnull %2, ptr noundef nonnull %3)
  %5 = call ptr @roaring_bitmap_create() #5
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %.not17 = icmp eq i32 %6, 0
  br i1 %.not17, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.not = icmp eq i8 %0, -1
  br i1 %.not, label %14, label %13

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %7 = load ptr, ptr %2, align 8, !tbaa !9
  %8 = getelementptr inbounds i32, ptr %7, i64 %indvars.iv
  %9 = load i32, ptr %8, align 4, !tbaa !5
  call void @roaring_bitmap_add(ptr noundef %5, i32 noundef %9) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = zext i32 %10 to i64
  %12 = icmp ult i64 %indvars.iv.next, %11
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !11

13:                                               ; preds = %._crit_edge
  call void @convert_all_containers(ptr noundef %5, i8 noundef zeroext %0)
  br label %14

14:                                               ; preds = %13, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %4) #5
  call void @roaring_init_iterator_last(ptr noundef %5, ptr noundef nonnull %4) #5
  %15 = getelementptr inbounds i8, ptr %4, i64 24
  %16 = getelementptr inbounds i8, ptr %4, i64 20
  br label %17

17:                                               ; preds = %34, %14
  %.0 = phi i32 [ 0, %14 ], [ %22, %34 ]
  %18 = load i8, ptr %15, align 8, !tbaa !13, !range !16, !noundef !17
  %19 = trunc nuw i8 %18 to i1
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  call void @__assert_fail(ptr noundef nonnull @.str.146, ptr noundef nonnull @.str.2, i32 noundef 3489, ptr noundef nonnull @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

21:                                               ; preds = %17
  %22 = add i32 %.0, 1
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %.not13 = icmp ult i32 %23, %22
  br i1 %.not13, label %24, label %25

24:                                               ; preds = %21
  call void @__assert_fail(ptr noundef nonnull @.str.147, ptr noundef nonnull @.str.2, i32 noundef 3491, ptr noundef nonnull @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

25:                                               ; preds = %21
  %26 = load ptr, ptr %2, align 8, !tbaa !9
  %27 = sub i32 %23, %22
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %26, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = load i32, ptr %16, align 4, !tbaa !18
  %32 = icmp eq i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %25
  call void @__assert_fail(ptr noundef nonnull @.str.148, ptr noundef nonnull @.str.2, i32 noundef 3492, ptr noundef nonnull @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

34:                                               ; preds = %25
  %35 = call zeroext i1 @roaring_previous_uint32_iterator(ptr noundef nonnull %4) #5
  br i1 %35, label %17, label %36, !llvm.loop !19

36:                                               ; preds = %34
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = icmp eq i32 %37, %22
  br i1 %38, label %40, label %39

39:                                               ; preds = %36
  call void @__assert_fail(ptr noundef nonnull @.str.149, ptr noundef nonnull @.str.2, i32 noundef 3495, ptr noundef nonnull @__PRETTY_FUNCTION__.test_previous_iterator) #6
  unreachable

40:                                               ; preds = %36
  call void @roaring_bitmap_free(ptr noundef %5) #5
  %41 = load ptr, ptr %2, align 8, !tbaa !9
  call void @free(ptr noundef %41) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret void
}

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


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