; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseBackground.ll (ZN4Simd4Base26BackgroundShiftRangeMaskedEPKhmmmPhmS3_mS2_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: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd4Base20BackgroundShiftRangeERKhRhS3_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) #1

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

24:                                               ; preds = %68, %10
  %25 = load i64, ptr %21, align 8, !tbaa !9
  %26 = load i64, ptr %14, align 8, !tbaa !9
  %27 = icmp ult i64 %25, %26
  br i1 %27, label %29, label %28

28:                                               ; preds = %24
  store i32 2, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  br label %71

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %30

30:                                               ; preds = %52, %29
  %31 = load i64, ptr %23, align 8, !tbaa !9
  %32 = load i64, ptr %13, align 8, !tbaa !9
  %33 = icmp ult i64 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 5, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  br label %55

35:                                               ; preds = %30
  %36 = load ptr, ptr %19, align 8, !tbaa !5
  %37 = load i64, ptr %23, align 8, !tbaa !9
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !11
  %40 = icmp ne i8 %39, 0
  br i1 %40, label %41, label %51

41:                                               ; preds = %35
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = load i64, ptr %23, align 8, !tbaa !9
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = load i64, ptr %23, align 8, !tbaa !9
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  %48 = load ptr, ptr %17, align 8, !tbaa !5
  %49 = load i64, ptr %23, align 8, !tbaa !9
  %50 = getelementptr inbounds i8, ptr %48, i64 %49
  call void @_ZN4Simd4Base20BackgroundShiftRangeERKhRhS3_(ptr noundef nonnull align 1 dereferenceable(1) %44, ptr noundef nonnull align 1 dereferenceable(1) %47, ptr noundef nonnull align 1 dereferenceable(1) %50)
  br label %51

51:                                               ; preds = %41, %35
  br label %52

52:                                               ; preds = %51
  %53 = load i64, ptr %23, align 8, !tbaa !9
  %54 = add i64 %53, 1
  store i64 %54, ptr %23, align 8, !tbaa !9
  br label %30, !llvm.loop !12

55:                                               ; preds = %34
  %56 = load i64, ptr %12, align 8, !tbaa !9
  %57 = load ptr, ptr %11, align 8, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %57, i64 %56
  store ptr %58, ptr %11, align 8, !tbaa !5
  %59 = load i64, ptr %16, align 8, !tbaa !9
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 %59
  store ptr %61, ptr %15, align 8, !tbaa !5
  %62 = load i64, ptr %18, align 8, !tbaa !9
  %63 = load ptr, ptr %17, align 8, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %63, i64 %62
  store ptr %64, ptr %17, align 8, !tbaa !5
  %65 = load i64, ptr %20, align 8, !tbaa !9
  %66 = load ptr, ptr %19, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 %65
  store ptr %67, ptr %19, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %55
  %69 = load i64, ptr %21, align 8, !tbaa !9
  %70 = add i64 %69, 1
  store i64 %70, ptr %21, align 8, !tbaa !9
  br label %24, !llvm.loop !14

71:                                               ; preds = %28
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline mustprogress 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 = { mustprogress 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 }

!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: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd4Base20BackgroundShiftRangeERKhRhS3_(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base26BackgroundShiftRangeMaskedEPKhmmmPhmS3_mS2_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, ptr nocapture noundef readonly %8, i64 noundef %9) local_unnamed_addr #1 {
  %.not = icmp eq i64 %3, 0
  %.not33 = icmp eq i64 %2, 0
  %or.cond = or i1 %.not, %.not33
  br i1 %or.cond, label %._crit_edge32, label %.preheader.us

.preheader.us:                                    ; preds = %10, %._crit_edge.us
  %.02131.us = phi i64 [ %24, %._crit_edge.us ], [ 0, %10 ]
  %.02230.us = phi ptr [ %20, %._crit_edge.us ], [ %0, %10 ]
  %.02329.us = phi ptr [ %23, %._crit_edge.us ], [ %8, %10 ]
  %.02428.us = phi ptr [ %21, %._crit_edge.us ], [ %4, %10 ]
  %.02527.us = phi ptr [ %22, %._crit_edge.us ], [ %6, %10 ]
  br label %11

11:                                               ; preds = %.preheader.us, %18
  %.026.us = phi i64 [ 0, %.preheader.us ], [ %19, %18 ]
  %12 = getelementptr inbounds i8, ptr %.02329.us, i64 %.026.us
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %.not.us = icmp eq i8 %13, 0
  br i1 %.not.us, label %18, label %14

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %.02230.us, i64 %.026.us
  %16 = getelementptr inbounds i8, ptr %.02428.us, i64 %.026.us
  %17 = getelementptr inbounds i8, ptr %.02527.us, i64 %.026.us
  tail call void @_ZN4Simd4Base20BackgroundShiftRangeERKhRhS3_(ptr noundef nonnull align 1 dereferenceable(1) %15, ptr noundef nonnull align 1 dereferenceable(1) %16, ptr noundef nonnull align 1 dereferenceable(1) %17)
  br label %18

18:                                               ; preds = %14, %11
  %19 = add nuw i64 %.026.us, 1
  %exitcond.not = icmp eq i64 %19, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %11, !llvm.loop !8

._crit_edge.us:                                   ; preds = %18
  %20 = getelementptr inbounds i8, ptr %.02230.us, i64 %1
  %21 = getelementptr inbounds i8, ptr %.02428.us, i64 %5
  %22 = getelementptr inbounds i8, ptr %.02527.us, i64 %7
  %23 = getelementptr inbounds i8, ptr %.02329.us, i64 %9
  %24 = add nuw i64 %.02131.us, 1
  %exitcond35.not = icmp eq i64 %24, %3
  br i1 %exitcond35.not, label %._crit_edge32, label %.preheader.us, !llvm.loop !10

._crit_edge32:                                    ; preds = %._crit_edge.us, %10
  ret void
}

attributes #0 = { alwaysinline mustprogress 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 = { mustprogress 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,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass