; LLVM IR from jermp/2i_bench :: external/CRoaring/src/containers (run)

; 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.run_container_s = type { i32, i32, ptr }
%struct.rle16_s = type { i16, i16 }

; 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 @run_container_iterate(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i16, align 2
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %66, %4
  %16 = load i32, ptr %10, align 4, !tbaa !9
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.run_container_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp slt i32 %16, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %15
  store i32 2, ptr %11, align 4
  br label %69

22:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.run_container_s, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.rle16_s, ptr %26, i64 %28
  %30 = getelementptr inbounds %struct.rle16_s, ptr %29, i32 0, i32 0
  %31 = load i16, ptr %30, align 2, !tbaa !14
  %32 = zext i16 %31 to i32
  %33 = add i32 %23, %32
  store i32 %33, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %13) #2
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.run_container_s, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds %struct.rle16_s, ptr %36, i64 %38
  %40 = getelementptr inbounds %struct.rle16_s, ptr %39, i32 0, i32 1
  %41 = load i16, ptr %40, align 2, !tbaa !17
  store i16 %41, ptr %13, align 2, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %57, %22
  %43 = load i32, ptr %14, align 4, !tbaa !9
  %44 = load i16, ptr %13, align 2, !tbaa !18
  %45 = zext i16 %44 to i32
  %46 = icmp sle i32 %43, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %42
  store i32 5, ptr %11, align 4
  br label %60

48:                                               ; preds = %42
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load i32, ptr %12, align 4, !tbaa !9
  %51 = load i32, ptr %14, align 4, !tbaa !9
  %52 = add i32 %50, %51
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = call zeroext i1 %49(i32 noundef %52, ptr noundef %53)
  br i1 %54, label %56, label %55

55:                                               ; preds = %48
  store i1 false, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %60

56:                                               ; preds = %48
  br label %57

57:                                               ; preds = %56
  %58 = load i32, ptr %14, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %14, align 4, !tbaa !9
  br label %42, !llvm.loop !19

60:                                               ; preds = %55, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  %61 = load i32, ptr %11, align 4
  switch i32 %61, label %63 [
    i32 5, label %62
  ]

62:                                               ; preds = %60
  store i32 0, ptr %11, align 4
  br label %63

63:                                               ; preds = %62, %60
  call void @llvm.lifetime.end.p0(i64 2, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %64 = load i32, ptr %11, align 4
  switch i32 %64, label %69 [
    i32 0, label %65
  ]

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %10, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %10, align 4, !tbaa !9
  br label %15, !llvm.loop !21

69:                                               ; preds = %63, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  %70 = load i32, ptr %11, align 4
  switch i32 %70, label %74 [
    i32 2, label %71
    i32 1, label %72
  ]

71:                                               ; preds = %69
  store i1 true, ptr %5, align 1
  br label %72

72:                                               ; preds = %71, %69
  %73 = load i1, ptr %5, align 1
  ret i1 %73

74:                                               ; preds = %69
  unreachable
}

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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"run_container_s", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !16, i64 0}
!15 = !{!"rle16_s", !16, i64 0, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = !{!15, !16, i64 2}
!18 = !{!16, !16, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; 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.rle16_s = type { i16, i16 }

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @run_container_iterate(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = load i32, ptr %0, align 8, !tbaa !5
  %6 = icmp slt i32 %5, 1
  br i1 %6, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  br label %8

8:                                                ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  %9 = load ptr, ptr %7, align 8, !tbaa !11
  %10 = getelementptr inbounds %struct.rle16_s, ptr %9, i64 %indvars.iv
  %11 = load i16, ptr %10, align 2, !tbaa !12
  %12 = zext i16 %11 to i32
  %13 = add i32 %12, %1
  %14 = getelementptr inbounds i8, ptr %10, i64 2
  %15 = load i16, ptr %14, align 2, !tbaa !15
  %16 = zext i16 %15 to i32
  br label %19

17:                                               ; preds = %19
  %18 = add nuw nsw i32 %.026, 1
  %exitcond.not = icmp eq i32 %.026, %16
  br i1 %exitcond.not, label %22, label %19, !llvm.loop !16

19:                                               ; preds = %8, %17
  %.026 = phi i32 [ 0, %8 ], [ %18, %17 ]
  %20 = add i32 %13, %.026
  %21 = tail call zeroext i1 %2(i32 noundef %20, ptr noundef %3) #1
  br i1 %21, label %17, label %.loopexit

22:                                               ; preds = %17
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %0, align 8, !tbaa !5
  %24 = sext i32 %23 to i64
  %.not = icmp slt i64 %indvars.iv.next, %24
  br i1 %.not, label %8, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %22, %19, %4
  %25 = phi i1 [ true, %4 ], [ false, %19 ], [ true, %22 ]
  ret i1 %25
}

attributes #0 = { 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 #1 = { 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, !7, i64 0}
!6 = !{!"run_container_s", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !14, i64 0}
!13 = !{!"rle16_s", !14, i64 0, !14, i64 2}
!14 = !{!"short", !8, i64 0}
!15 = !{!13, !14, i64 2}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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