; 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.129 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.130 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.131 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [35 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 void @roaring_bitmap_add(ptr noundef, i32 noundef) #1

declare zeroext i1 @roaring_bitmap_run_optimize(ptr noundef) #1

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

4:                                                ; preds = %91, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp ult i32 %5, 1000000
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %94

8:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %9 = call ptr @roaring_bitmap_create()
  store ptr %9, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %10 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %10, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %19, %8
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = add i32 1000, %13
  %15 = icmp ult i32 %12, %14
  br i1 %15, label %16, label %22

16:                                               ; preds = %11
  %17 = load ptr, ptr %2, align 8, !tbaa !9
  %18 = load i32, ptr %3, align 4, !tbaa !5
  call void @roaring_bitmap_add(ptr noundef %17, i32 noundef %18)
  br label %19

19:                                               ; preds = %16
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = add i32 %20, 100
  store i32 %21, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !11

22:                                               ; preds = %11
  %23 = load ptr, ptr %2, align 8, !tbaa !9
  %24 = call i32 @roaring_bitmap_minimum(ptr noundef %23)
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = icmp eq i32 %24, %25
  %27 = zext i1 %26 to i32
  %28 = sext i32 %27 to i64
  call void @_assert_true(i64 noundef %28, ptr noundef @.str.129, ptr noundef @.str.2, i32 noundef 3151)
  %29 = load ptr, ptr %2, align 8, !tbaa !9
  %30 = call i32 @roaring_bitmap_maximum(ptr noundef %29)
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sub i32 %31, 100
  %33 = icmp eq i32 %30, %32
  %34 = zext i1 %33 to i32
  %35 = sext i32 %34 to i64
  call void @_assert_true(i64 noundef %35, ptr noundef @.str.130, ptr noundef @.str.2, i32 noundef 3152)
  %36 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %36, ptr %3, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %45, %22
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = load i32, ptr %1, align 4, !tbaa !5
  %40 = add i32 64000, %39
  %41 = icmp ult i32 %38, %40
  br i1 %41, label %42, label %48

42:                                               ; preds = %37
  %43 = load ptr, ptr %2, align 8, !tbaa !9
  %44 = load i32, ptr %3, align 4, !tbaa !5
  call void @roaring_bitmap_add(ptr noundef %43, i32 noundef %44)
  br label %45

45:                                               ; preds = %42
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = add i32 %46, 2
  store i32 %47, ptr %3, align 4, !tbaa !5
  br label %37, !llvm.loop !13

48:                                               ; preds = %37
  %49 = load ptr, ptr %2, align 8, !tbaa !9
  %50 = call i32 @roaring_bitmap_minimum(ptr noundef %49)
  %51 = load i32, ptr %1, align 4, !tbaa !5
  %52 = icmp eq i32 %50, %51
  %53 = zext i1 %52 to i32
  %54 = sext i32 %53 to i64
  call void @_assert_true(i64 noundef %54, ptr noundef @.str.129, ptr noundef @.str.2, i32 noundef 3158)
  %55 = load ptr, ptr %2, align 8, !tbaa !9
  %56 = call i32 @roaring_bitmap_maximum(ptr noundef %55)
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = sub i32 %57, 2
  %59 = icmp eq i32 %56, %58
  %60 = zext i1 %59 to i32
  %61 = sext i32 %60 to i64
  call void @_assert_true(i64 noundef %61, ptr noundef @.str.131, ptr noundef @.str.2, i32 noundef 3159)
  %62 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %62, ptr %3, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %71, %48
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = load i32, ptr %1, align 4, !tbaa !5
  %66 = add i32 64000, %65
  %67 = icmp ult i32 %64, %66
  br i1 %67, label %68, label %74

68:                                               ; preds = %63
  %69 = load ptr, ptr %2, align 8, !tbaa !9
  %70 = load i32, ptr %3, align 4, !tbaa !5
  call void @roaring_bitmap_add(ptr noundef %69, i32 noundef %70)
  br label %71

71:                                               ; preds = %68
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = add i32 %72, 1
  store i32 %73, ptr %3, align 4, !tbaa !5
  br label %63, !llvm.loop !14

74:                                               ; preds = %63
  %75 = load ptr, ptr %2, align 8, !tbaa !9
  %76 = call zeroext i1 @roaring_bitmap_run_optimize(ptr noundef %75)
  %77 = load ptr, ptr %2, align 8, !tbaa !9
  %78 = call i32 @roaring_bitmap_minimum(ptr noundef %77)
  %79 = load i32, ptr %1, align 4, !tbaa !5
  %80 = icmp eq i32 %78, %79
  %81 = zext i1 %80 to i32
  %82 = sext i32 %81 to i64
  call void @_assert_true(i64 noundef %82, ptr noundef @.str.129, ptr noundef @.str.2, i32 noundef 3166)
  %83 = load ptr, ptr %2, align 8, !tbaa !9
  %84 = call i32 @roaring_bitmap_maximum(ptr noundef %83)
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = sub i32 %85, 1
  %87 = icmp eq i32 %84, %86
  %88 = zext i1 %87 to i32
  %89 = sext i32 %88 to i64
  call void @_assert_true(i64 noundef %89, ptr noundef @.str.132, ptr noundef @.str.2, i32 noundef 3167)
  %90 = load ptr, ptr %2, align 8, !tbaa !9
  call void @roaring_bitmap_free(ptr noundef %90)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  br label %91

91:                                               ; preds = %74
  %92 = load i32, ptr %1, align 4, !tbaa !5
  %93 = mul i32 %92, 2
  store i32 %93, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !15

94:                                               ; preds = %7
  ret void
}

declare i32 @roaring_bitmap_minimum(ptr noundef) #1

declare i32 @roaring_bitmap_maximum(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 = { 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 }

!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 = distinct !{!15, !12}


; 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.129 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.130 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.131 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.132 = external hidden unnamed_addr constant [35 x i8], align 1

declare void @roaring_bitmap_free(ptr noundef) local_unnamed_addr #0

declare ptr @roaring_bitmap_create() local_unnamed_addr #0

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

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

declare zeroext i1 @roaring_bitmap_run_optimize(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @test_maximum_minimum() local_unnamed_addr #1 {
  br label %2

1:                                                ; preds = %._crit_edge
  ret void

2:                                                ; preds = %0, %._crit_edge
  %.03338 = phi i32 [ 123, %0 ], [ %38, %._crit_edge ]
  %3 = tail call ptr @roaring_bitmap_create() #2
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %.03338) #2
  %4 = add nuw nsw i32 %.03338, 100
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %4) #2
  %5 = add nuw nsw i32 %.03338, 200
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %5) #2
  %6 = add nuw nsw i32 %.03338, 300
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %6) #2
  %7 = add nuw nsw i32 %.03338, 400
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %7) #2
  %8 = add nuw nsw i32 %.03338, 500
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %8) #2
  %9 = add nuw nsw i32 %.03338, 600
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %9) #2
  %10 = add nuw nsw i32 %.03338, 700
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %10) #2
  %11 = add nuw nsw i32 %.03338, 800
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %11) #2
  %12 = add nuw nsw i32 %.03338, 900
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %12) #2
  %13 = tail call i32 @roaring_bitmap_minimum(ptr noundef %3) #2
  %14 = icmp eq i32 %13, %.03338
  %15 = zext i1 %14 to i64
  tail call void @_assert_true(i64 noundef %15, ptr noundef nonnull @.str.129, ptr noundef nonnull @.str.2, i32 noundef 3151) #2
  %16 = tail call i32 @roaring_bitmap_maximum(ptr noundef %3) #2
  %17 = icmp eq i32 %16, %12
  %18 = zext i1 %17 to i64
  tail call void @_assert_true(i64 noundef %18, ptr noundef nonnull @.str.130, ptr noundef nonnull @.str.2, i32 noundef 3152) #2
  %19 = add nuw nsw i32 %.03338, 64000
  br label %20

20:                                               ; preds = %2, %20
  %.136 = phi i32 [ %.03338, %2 ], [ %21, %20 ]
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %.136) #2
  %21 = add nuw nsw i32 %.136, 2
  %22 = icmp ult i32 %21, %19
  br i1 %22, label %20, label %.lr.ph, !llvm.loop !5

.lr.ph:                                           ; preds = %20
  %23 = tail call i32 @roaring_bitmap_minimum(ptr noundef %3) #2
  %24 = icmp eq i32 %23, %.03338
  %25 = zext i1 %24 to i64
  tail call void @_assert_true(i64 noundef %25, ptr noundef nonnull @.str.129, ptr noundef nonnull @.str.2, i32 noundef 3158) #2
  %26 = tail call i32 @roaring_bitmap_maximum(ptr noundef %3) #2
  %27 = icmp eq i32 %26, %.136
  %28 = zext i1 %27 to i64
  tail call void @_assert_true(i64 noundef %28, ptr noundef nonnull @.str.131, ptr noundef nonnull @.str.2, i32 noundef 3159) #2
  br label %29

29:                                               ; preds = %.lr.ph, %29
  %.237 = phi i32 [ %.03338, %.lr.ph ], [ %30, %29 ]
  tail call void @roaring_bitmap_add(ptr noundef %3, i32 noundef %.237) #2
  %30 = add nuw nsw i32 %.237, 1
  %exitcond.not = icmp eq i32 %30, %19
  br i1 %exitcond.not, label %._crit_edge, label %29, !llvm.loop !7

._crit_edge:                                      ; preds = %29
  %31 = tail call zeroext i1 @roaring_bitmap_run_optimize(ptr noundef %3) #2
  %32 = tail call i32 @roaring_bitmap_minimum(ptr noundef %3) #2
  %33 = icmp eq i32 %32, %.03338
  %34 = zext i1 %33 to i64
  tail call void @_assert_true(i64 noundef %34, ptr noundef nonnull @.str.129, ptr noundef nonnull @.str.2, i32 noundef 3166) #2
  %35 = tail call i32 @roaring_bitmap_maximum(ptr noundef %3) #2
  %36 = icmp eq i32 %35, %.237
  %37 = zext i1 %36 to i64
  tail call void @_assert_true(i64 noundef %37, ptr noundef nonnull @.str.132, ptr noundef nonnull @.str.2, i32 noundef 3167) #2
  tail call void @roaring_bitmap_free(ptr noundef %3) #2
  %38 = shl nuw nsw i32 %.03338, 1
  %39 = icmp ult i32 %.03338, 500000
  br i1 %39, label %2, label %1, !llvm.loop !8
}

declare i32 @roaring_bitmap_minimum(ptr noundef) local_unnamed_addr #0

declare i32 @roaring_bitmap_maximum(ptr noundef) local_unnamed_addr #0

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 = { 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 }

!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 = distinct !{!8, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass