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

17:                                               ; preds = %71, %5
  %18 = load i32, ptr %12, align 4, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.run_container_s, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = icmp slt i32 %18, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  store i32 2, ptr %13, align 4
  br label %74

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

44:                                               ; preds = %62, %24
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = load i16, ptr %15, align 2, !tbaa !20
  %47 = zext i16 %46 to i32
  %48 = icmp sle i32 %45, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %44
  store i32 5, ptr %13, align 4
  br label %65

50:                                               ; preds = %44
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = load i64, ptr %10, align 8, !tbaa !11
  %53 = load i32, ptr %14, align 4, !tbaa !9
  %54 = load i32, ptr %16, align 4, !tbaa !9
  %55 = add i32 %53, %54
  %56 = zext i32 %55 to i64
  %57 = or i64 %52, %56
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = call zeroext i1 %51(i64 noundef %57, ptr noundef %58)
  br i1 %59, label %61, label %60

60:                                               ; preds = %50
  store i1 false, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %65

61:                                               ; preds = %50
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %16, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %16, align 4, !tbaa !9
  br label %44, !llvm.loop !21

65:                                               ; preds = %60, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #2
  %66 = load i32, ptr %13, align 4
  switch i32 %66, label %68 [
    i32 5, label %67
  ]

67:                                               ; preds = %65
  store i32 0, ptr %13, align 4
  br label %68

68:                                               ; preds = %67, %65
  call void @llvm.lifetime.end.p0(i64 2, ptr %15) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  %69 = load i32, ptr %13, align 4
  switch i32 %69, label %74 [
    i32 0, label %70
  ]

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70
  %72 = load i32, ptr %12, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %12, align 4, !tbaa !9
  br label %17, !llvm.loop !23

74:                                               ; preds = %68, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  %75 = load i32, ptr %13, align 4
  switch i32 %75, label %79 [
    i32 2, label %76
    i32 1, label %77
  ]

76:                                               ; preds = %74
  store i1 true, ptr %6, align 1
  br label %77

77:                                               ; preds = %76, %74
  %78 = load i1, ptr %6, align 1
  ret i1 %78

79:                                               ; preds = %74
  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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"run_container_s", !10, i64 0, !10, i64 4, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!17, !18, i64 0}
!17 = !{!"rle16_s", !18, i64 0, !18, i64 2}
!18 = !{!"short", !7, i64 0}
!19 = !{!17, !18, i64 2}
!20 = !{!18, !18, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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_iterate64(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef readonly %2, i64 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = icmp slt i32 %6, 1
  br i1 %7, label %.loopexit, label %.lr.ph

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

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

18:                                               ; preds = %19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv, %17
  br i1 %exitcond.not, label %25, label %19, !llvm.loop !16

19:                                               ; preds = %9, %18
  %indvars.iv = phi i64 [ 0, %9 ], [ %indvars.iv.next, %18 ]
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  %21 = add i32 %14, %20
  %22 = zext i32 %21 to i64
  %23 = or i64 %22, %3
  %24 = tail call zeroext i1 %2(i64 noundef %23, ptr noundef %4) #1
  br i1 %24, label %18, label %.loopexit

25:                                               ; preds = %18
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %26 = load i32, ptr %0, align 8, !tbaa !5
  %27 = sext i32 %26 to i64
  %.not = icmp slt i64 %indvars.iv.next34, %27
  br i1 %.not, label %9, label %.loopexit, !llvm.loop !18

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

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,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass