; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseBackground.ll (ZN4Simd4Base23BackgroundGrowRangeFastEPKhmmmPhmS3_m)

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

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

20:                                               ; preds = %85, %8
  %21 = load i64, ptr %17, align 8, !tbaa !9
  %22 = load i64, ptr %12, align 8, !tbaa !9
  %23 = icmp ult i64 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  store i32 2, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  br label %88

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #2
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %72, %25
  %27 = load i64, ptr %19, align 8, !tbaa !9
  %28 = load i64, ptr %11, align 8, !tbaa !9
  %29 = icmp ult i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  store i32 5, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  br label %75

31:                                               ; preds = %26
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load i64, ptr %19, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %32, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !11
  %36 = zext i8 %35 to i32
  %37 = load ptr, ptr %13, align 8, !tbaa !5
  %38 = load i64, ptr %19, align 8, !tbaa !9
  %39 = getelementptr inbounds i8, ptr %37, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = zext i8 %40 to i32
  %42 = icmp slt i32 %36, %41
  br i1 %42, label %43, label %51

43:                                               ; preds = %31
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load i64, ptr %19, align 8, !tbaa !9
  %46 = getelementptr inbounds i8, ptr %44, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = load i64, ptr %19, align 8, !tbaa !9
  %50 = getelementptr inbounds i8, ptr %48, i64 %49
  store i8 %47, ptr %50, align 1, !tbaa !11
  br label %51

51:                                               ; preds = %43, %31
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load i64, ptr %19, align 8, !tbaa !9
  %54 = getelementptr inbounds i8, ptr %52, i64 %53
  %55 = load i8, ptr %54, align 1, !tbaa !11
  %56 = zext i8 %55 to i32
  %57 = load ptr, ptr %15, align 8, !tbaa !5
  %58 = load i64, ptr %19, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %57, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = zext i8 %60 to i32
  %62 = icmp sgt i32 %56, %61
  br i1 %62, label %63, label %71

63:                                               ; preds = %51
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load i64, ptr %19, align 8, !tbaa !9
  %66 = getelementptr inbounds i8, ptr %64, i64 %65
  %67 = load i8, ptr %66, align 1, !tbaa !11
  %68 = load ptr, ptr %15, align 8, !tbaa !5
  %69 = load i64, ptr %19, align 8, !tbaa !9
  %70 = getelementptr inbounds i8, ptr %68, i64 %69
  store i8 %67, ptr %70, align 1, !tbaa !11
  br label %71

71:                                               ; preds = %63, %51
  br label %72

72:                                               ; preds = %71
  %73 = load i64, ptr %19, align 8, !tbaa !9
  %74 = add i64 %73, 1
  store i64 %74, ptr %19, align 8, !tbaa !9
  br label %26, !llvm.loop !12

75:                                               ; preds = %30
  %76 = load i64, ptr %10, align 8, !tbaa !9
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 %76
  store ptr %78, ptr %9, align 8, !tbaa !5
  %79 = load i64, ptr %14, align 8, !tbaa !9
  %80 = load ptr, ptr %13, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 %79
  store ptr %81, ptr %13, align 8, !tbaa !5
  %82 = load i64, ptr %16, align 8, !tbaa !9
  %83 = load ptr, ptr %15, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 %82
  store ptr %84, ptr %15, align 8, !tbaa !5
  br label %85

85:                                               ; preds = %75
  %86 = load i64, ptr %17, align 8, !tbaa !9
  %87 = add i64 %86, 1
  store i64 %87, ptr %17, align 8, !tbaa !9
  br label %20, !llvm.loop !14

88:                                               ; preds = %24
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN4Simd4Base23BackgroundGrowRangeFastEPKhmmmPhmS3_m(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef %4, i64 noundef %5, ptr nocapture noundef %6, i64 noundef %7) local_unnamed_addr #0 {
  %.not = icmp eq i64 %3, 0
  %.not37 = icmp eq i64 %2, 0
  %or.cond = or i1 %.not, %.not37
  br i1 %or.cond, label %._crit_edge36, label %.preheader.us

.preheader.us:                                    ; preds = %8, %._crit_edge.us
  %.02735.us = phi i64 [ %27, %._crit_edge.us ], [ 0, %8 ]
  %.02834.us = phi ptr [ %24, %._crit_edge.us ], [ %0, %8 ]
  %.02933.us = phi ptr [ %26, %._crit_edge.us ], [ %6, %8 ]
  %.03032.us = phi ptr [ %25, %._crit_edge.us ], [ %4, %8 ]
  br label %9

9:                                                ; preds = %.preheader.us, %22
  %.031.us = phi i64 [ 0, %.preheader.us ], [ %23, %22 ]
  %10 = getelementptr inbounds i8, ptr %.02834.us, i64 %.031.us
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %.03032.us, i64 %.031.us
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = icmp ult i8 %11, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %9
  store i8 %11, ptr %12, align 1, !tbaa !5
  %.pre = load i8, ptr %10, align 1, !tbaa !5
  br label %16

16:                                               ; preds = %15, %9
  %17 = phi i8 [ %.pre, %15 ], [ %11, %9 ]
  %18 = getelementptr inbounds i8, ptr %.02933.us, i64 %.031.us
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = icmp ugt i8 %17, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i8 %17, ptr %18, align 1, !tbaa !5
  br label %22

22:                                               ; preds = %21, %16
  %23 = add nuw i64 %.031.us, 1
  %exitcond.not = icmp eq i64 %23, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %9, !llvm.loop !8

._crit_edge.us:                                   ; preds = %22
  %24 = getelementptr inbounds i8, ptr %.02834.us, i64 %1
  %25 = getelementptr inbounds i8, ptr %.03032.us, i64 %5
  %26 = getelementptr inbounds i8, ptr %.02933.us, i64 %7
  %27 = add nuw i64 %.02735.us, 1
  %exitcond39.not = icmp eq i64 %27, %3
  br i1 %exitcond39.not, label %._crit_edge36, label %.preheader.us, !llvm.loop !10

._crit_edge36:                                    ; preds = %._crit_edge.us, %8
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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