; 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.69 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [9 x i8], align 1
@stderr = external global ptr, align 8
@.str.71 = external hidden unnamed_addr constant [45 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 ptr @roaring_bitmap_from_range(i64 noundef, i64 noundef, i32 noundef) #1

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_equals(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @check_bitmap_from_range(i32 noundef %0, i64 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = load i64, ptr %5, align 8, !tbaa !9
  %14 = load i32, ptr %6, align 4, !tbaa !5
  %15 = call ptr @roaring_bitmap_from_range(i64 noundef %12, i64 noundef %13, i32 noundef %14)
  store ptr %15, ptr %7, align 8, !tbaa !11
  %16 = load ptr, ptr %7, align 8, !tbaa !11
  %17 = ptrtoint ptr %16 to i64
  call void @_assert_true(i64 noundef %17, ptr noundef @.str.69, ptr noundef @.str.2, i32 noundef 826)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %18 = call ptr @roaring_bitmap_create()
  store ptr %18, ptr %8, align 8, !tbaa !11
  %19 = load ptr, ptr %8, align 8, !tbaa !11
  %20 = ptrtoint ptr %19 to i64
  call void @_assert_true(i64 noundef %20, ptr noundef @.str.70, ptr noundef @.str.2, i32 noundef 828)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %21 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %21, ptr %9, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %31, %3
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = icmp ult i64 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %35

28:                                               ; preds = %22
  %29 = load ptr, ptr %8, align 8, !tbaa !11
  %30 = load i32, ptr %9, align 4, !tbaa !5
  call void @roaring_bitmap_add(ptr noundef %29, i32 noundef %30)
  br label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = add i32 %33, %32
  store i32 %34, ptr %9, align 4, !tbaa !5
  br label %22, !llvm.loop !13

35:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %36 = load ptr, ptr %8, align 8, !tbaa !11
  %37 = load ptr, ptr %7, align 8, !tbaa !11
  %38 = call zeroext i1 @roaring_bitmap_equals(ptr noundef %36, ptr noundef %37)
  %39 = zext i1 %38 to i8
  store i8 %39, ptr %10, align 1, !tbaa !15
  %40 = load i8, ptr %10, align 1, !tbaa !15, !range !17, !noundef !18
  %41 = trunc i8 %40 to i1
  br i1 %41, label %49, label %42

42:                                               ; preds = %35
  %43 = load ptr, ptr @stderr, align 8, !tbaa !11
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = load i64, ptr %5, align 8, !tbaa !9
  %46 = trunc i64 %45 to i32
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.71, i32 noundef %44, i32 noundef %46, i32 noundef %47) #4
  br label %49

49:                                               ; preds = %42, %35
  %50 = load ptr, ptr %8, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %50)
  %51 = load ptr, ptr %7, align 8, !tbaa !11
  call void @roaring_bitmap_free(ptr noundef %51)
  %52 = load i8, ptr %10, align 1, !tbaa !15, !range !17, !noundef !18
  %53 = trunc i8 %52 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret i1 %53
}

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}


; 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.69 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.70 = external hidden unnamed_addr constant [9 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.71 = external hidden unnamed_addr constant [45 x i8], align 1

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

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_equals(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @check_bitmap_from_range(i32 noundef %0, i64 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = zext i32 %0 to i64
  %5 = tail call ptr @roaring_bitmap_from_range(i64 noundef %4, i64 noundef %1, i32 noundef %2) #3
  %6 = ptrtoint ptr %5 to i64
  tail call void @_assert_true(i64 noundef %6, ptr noundef nonnull @.str.69, ptr noundef nonnull @.str.2, i32 noundef 826) #3
  %7 = tail call ptr @roaring_bitmap_create() #3
  %8 = ptrtoint ptr %7 to i64
  tail call void @_assert_true(i64 noundef %8, ptr noundef nonnull @.str.70, ptr noundef nonnull @.str.2, i32 noundef 828) #3
  %9 = icmp ult i64 %4, %1
  br i1 %9, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %3
  %10 = tail call zeroext i1 @roaring_bitmap_equals(ptr noundef %7, ptr noundef %5) #3
  br i1 %10, label %18, label %14

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.021 = phi i32 [ %11, %.lr.ph ], [ %0, %3 ]
  tail call void @roaring_bitmap_add(ptr noundef %7, i32 noundef %.021) #3
  %11 = add i32 %.021, %2
  %12 = zext i32 %11 to i64
  %13 = icmp ult i64 %12, %1
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !5

14:                                               ; preds = %._crit_edge
  %15 = load ptr, ptr @stderr, align 8, !tbaa !7
  %16 = trunc nuw i64 %1 to i32
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.71, i32 noundef %0, i32 noundef %16, i32 noundef %2) #4
  br label %18

18:                                               ; preds = %14, %._crit_edge
  tail call void @roaring_bitmap_free(ptr noundef %7) #3
  tail call void @roaring_bitmap_free(ptr noundef %5) #3
  ret i1 %10
}

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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 = { nofree 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 }
attributes #4 = { cold 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 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass