; 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.sbs_s = type { ptr, ptr, i32 }
%struct.roaring_bitmap_s = type { %struct.roaring_array_s }
%struct.roaring_array_s = type { i32, i32, ptr, ptr, ptr, i8 }

; 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

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

7:                                                ; preds = %38, %2
  %8 = load i32, ptr %6, align 4, !tbaa !12
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.sbs_s, ptr %9, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = getelementptr inbounds %struct.roaring_bitmap_s, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %struct.roaring_array_s, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !16
  %15 = icmp slt i32 %8, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %7
  %18 = load i8, ptr %5, align 1, !tbaa !10, !range !19, !noundef !20
  %19 = trunc i8 %18 to i1
  br i1 %19, label %20, label %35

20:                                               ; preds = %17
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sbs_s, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds %struct.roaring_bitmap_s, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.roaring_array_s, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !21
  %27 = load i32, ptr %6, align 4, !tbaa !12
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !9
  %31 = zext i8 %30 to i32
  %32 = load i8, ptr %4, align 1, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = icmp eq i32 %31, %33
  br label %35

35:                                               ; preds = %20, %17
  %36 = phi i1 [ false, %17 ], [ %34, %20 ]
  %37 = zext i1 %36 to i8
  store i8 %37, ptr %5, align 1, !tbaa !10
  br label %38

38:                                               ; preds = %35
  %39 = load i32, ptr %6, align 4, !tbaa !12
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %6, align 4, !tbaa !12
  br label %7, !llvm.loop !22

41:                                               ; preds = %16
  %42 = load i8, ptr %5, align 1, !tbaa !10, !range !19, !noundef !20
  %43 = trunc i8 %42 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i1 %43
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"sbs_s", !6, i64 0, !6, i64 8, !13, i64 16}
!16 = !{!17, !13, i64 0}
!17 = !{!"roaring_bitmap_s", !18, i64 0}
!18 = !{!"roaring_array_s", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!17, !6, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local zeroext i1 @sbs_check_type(ptr nocapture noundef readonly %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = load i32, ptr %3, align 8, !tbaa !11
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %6 = getelementptr inbounds i8, ptr %3, i64 24
  %wide.trip.count = zext nneg i32 %4 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %7 = icmp ult i32 %4, 4
  br i1 %7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %15

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.critedge14, %.lr.ph
  %.lcssa.ph = phi i1 [ poison, %.lr.ph ], [ %34, %.critedge14 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.3, %.critedge14 ]
  %.078.unr = phi i1 [ true, %.lr.ph ], [ %34, %.critedge14 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %13
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %13 ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.078.epil = phi i1 [ %14, %13 ], [ %.078.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %13 ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  br i1 %.078.epil, label %8, label %13

8:                                                ; preds = %.epil.preheader
  %9 = load ptr, ptr %6, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %9, i64 %indvars.iv.epil
  %11 = load i8, ptr %10, align 1, !tbaa !15
  %12 = icmp eq i8 %11, %1
  br label %13

13:                                               ; preds = %8, %.epil.preheader
  %14 = phi i1 [ false, %.epil.preheader ], [ %12, %8 ]
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !16

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %13, %2
  %.07.lcssa = phi i1 [ true, %2 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %14, %13 ]
  ret i1 %.07.lcssa

15:                                               ; preds = %.critedge14, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.3, %.critedge14 ]
  %.078 = phi i1 [ true, %.lr.ph.new ], [ %34, %.critedge14 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %.critedge14 ]
  br i1 %.078, label %16, label %.critedge14

16:                                               ; preds = %15
  %17 = load ptr, ptr %6, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %17, i64 %indvars.iv
  %19 = load i8, ptr %18, align 1, !tbaa !15
  %20 = icmp eq i8 %19, %1
  br i1 %20, label %.critedge, label %.critedge14

.critedge:                                        ; preds = %16
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %21 = load ptr, ptr %6, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %21, i64 %indvars.iv.next
  %23 = load i8, ptr %22, align 1, !tbaa !15
  %24 = icmp eq i8 %23, %1
  br i1 %24, label %.critedge13, label %.critedge14

.critedge13:                                      ; preds = %.critedge
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %25 = load ptr, ptr %6, align 8, !tbaa !14
  %26 = getelementptr inbounds i8, ptr %25, i64 %indvars.iv.next.1
  %27 = load i8, ptr %26, align 1, !tbaa !15
  %28 = icmp eq i8 %27, %1
  br i1 %28, label %29, label %.critedge14

29:                                               ; preds = %.critedge13
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %30 = load ptr, ptr %6, align 8, !tbaa !14
  %31 = getelementptr inbounds i8, ptr %30, i64 %indvars.iv.next.2
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = icmp eq i8 %32, %1
  br label %.critedge14

.critedge14:                                      ; preds = %.critedge, %15, %16, %29, %.critedge13
  %34 = phi i1 [ false, %.critedge13 ], [ %33, %29 ], [ false, %16 ], [ false, %15 ], [ false, %.critedge ]
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %15, !llvm.loop !18
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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" }

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


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