; LLVM IR from ermig1979/Simd :: src/Simd (SimdBaseAddFeatureDifference)

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

28:                                               ; preds = %88, %11
  %29 = load i64, ptr %23, align 8, !tbaa !9
  %30 = load i64, ptr %15, align 8, !tbaa !9
  %31 = icmp ult i64 %29, %30
  br i1 %31, label %33, label %32

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

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  store i64 0, ptr %25, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %72, %33
  %35 = load i64, ptr %25, align 8, !tbaa !9
  %36 = load i64, ptr %14, align 8, !tbaa !9
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 5, ptr %24, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  br label %75

39:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #4
  %40 = load ptr, ptr %12, align 8, !tbaa !5
  %41 = load i64, ptr %25, align 8, !tbaa !9
  %42 = getelementptr inbounds i8, ptr %40, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !13
  %44 = zext i8 %43 to i32
  %45 = load ptr, ptr %16, align 8, !tbaa !5
  %46 = load i64, ptr %25, align 8, !tbaa !9
  %47 = getelementptr inbounds i8, ptr %45, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !13
  %49 = zext i8 %48 to i32
  %50 = load ptr, ptr %18, align 8, !tbaa !5
  %51 = load i64, ptr %25, align 8, !tbaa !9
  %52 = getelementptr inbounds i8, ptr %50, i64 %51
  %53 = load i8, ptr %52, align 1, !tbaa !13
  %54 = zext i8 %53 to i32
  %55 = call noundef i32 @_ZN4Simd4Base17FeatureDifferenceEiii(i32 noundef %44, i32 noundef %49, i32 noundef %54)
  store i32 %55, ptr %26, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #4
  %56 = load ptr, ptr %21, align 8, !tbaa !5
  %57 = load i64, ptr %25, align 8, !tbaa !9
  %58 = getelementptr inbounds i8, ptr %56, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !13
  %60 = zext i8 %59 to i32
  %61 = load i32, ptr %26, align 4, !tbaa !14
  %62 = load i16, ptr %20, align 2, !tbaa !11
  %63 = zext i16 %62 to i32
  %64 = call noundef i32 @_ZN4Simd4Base21ShiftedWeightedSquareEii(i32 noundef %61, i32 noundef %63)
  %65 = add i32 %60, %64
  store i32 %65, ptr %27, align 4, !tbaa !14
  %66 = load i32, ptr %27, align 4, !tbaa !14
  %67 = call noundef i32 @_ZN4Simd4Base3MinEii(i32 noundef %66, i32 noundef 255)
  %68 = trunc i32 %67 to i8
  %69 = load ptr, ptr %21, align 8, !tbaa !5
  %70 = load i64, ptr %25, align 8, !tbaa !9
  %71 = getelementptr inbounds i8, ptr %69, i64 %70
  store i8 %68, ptr %71, align 1, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #4
  br label %72

72:                                               ; preds = %39
  %73 = load i64, ptr %25, align 8, !tbaa !9
  %74 = add i64 %73, 1
  store i64 %74, ptr %25, align 8, !tbaa !9
  br label %34, !llvm.loop !16

75:                                               ; preds = %38
  %76 = load i64, ptr %13, align 8, !tbaa !9
  %77 = load ptr, ptr %12, align 8, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %77, i64 %76
  store ptr %78, ptr %12, align 8, !tbaa !5
  %79 = load i64, ptr %17, align 8, !tbaa !9
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %80, i64 %79
  store ptr %81, ptr %16, align 8, !tbaa !5
  %82 = load i64, ptr %19, align 8, !tbaa !9
  %83 = load ptr, ptr %18, align 8, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %83, i64 %82
  store ptr %84, ptr %18, align 8, !tbaa !5
  %85 = load i64, ptr %22, align 8, !tbaa !9
  %86 = load ptr, ptr %21, align 8, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %86, i64 %85
  store ptr %87, ptr %21, align 8, !tbaa !5
  br label %88

88:                                               ; preds = %75
  %89 = load i64, ptr %23, align 8, !tbaa !9
  %90 = add i64 %89, 1
  store i64 %90, ptr %23, align 8, !tbaa !9
  br label %28, !llvm.loop !18

91:                                               ; preds = %32
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i32 @_ZN4Simd4Base17FeatureDifferenceEiii(i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base21ShiftedWeightedSquareEii(i32 noundef, i32 noundef) #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base3MinEii(i32 noundef, i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { alwaysinline 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 #4 = { 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 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 uwtable
define dso_local void @_ZN4Simd4Base20AddFeatureDifferenceEPKhmmmS2_mS2_mtPhm(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef readonly %4, i64 noundef %5, ptr nocapture noundef readonly %6, i64 noundef %7, i16 noundef zeroext %8, ptr nocapture noundef %9, i64 noundef %10) local_unnamed_addr #0 {
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge37, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %11
  %.not38 = icmp eq i64 %2, 0
  %12 = zext i16 %8 to i32
  br i1 %.not38, label %._crit_edge37, label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.lr.ph, %._crit_edge.us
  %.036.us = phi ptr [ %32, %._crit_edge.us ], [ %0, %.preheader.lr.ph ]
  %.02635.us = phi ptr [ %33, %._crit_edge.us ], [ %4, %.preheader.lr.ph ]
  %.02834.us = phi i64 [ %36, %._crit_edge.us ], [ 0, %.preheader.lr.ph ]
  %.02933.us = phi ptr [ %34, %._crit_edge.us ], [ %6, %.preheader.lr.ph ]
  %.03032.us = phi ptr [ %35, %._crit_edge.us ], [ %9, %.preheader.lr.ph ]
  br label %13

13:                                               ; preds = %.preheader.us, %13
  %.02731.us = phi i64 [ 0, %.preheader.us ], [ %31, %13 ]
  %14 = getelementptr inbounds i8, ptr %.036.us, i64 %.02731.us
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = zext i8 %15 to i32
  %17 = getelementptr inbounds i8, ptr %.02635.us, i64 %.02731.us
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = zext i8 %18 to i32
  %20 = getelementptr inbounds i8, ptr %.02933.us, i64 %.02731.us
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = zext i8 %21 to i32
  %23 = tail call noundef i32 @_ZN4Simd4Base17FeatureDifferenceEiii(i32 noundef %16, i32 noundef %19, i32 noundef %22)
  %24 = getelementptr inbounds i8, ptr %.03032.us, i64 %.02731.us
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = zext i8 %25 to i32
  %27 = tail call noundef i32 @_ZN4Simd4Base21ShiftedWeightedSquareEii(i32 noundef %23, i32 noundef %12)
  %28 = add i32 %27, %26
  %29 = tail call noundef i32 @_ZN4Simd4Base3MinEii(i32 noundef %28, i32 noundef 255)
  %30 = trunc i32 %29 to i8
  store i8 %30, ptr %24, align 1, !tbaa !5
  %31 = add nuw i64 %.02731.us, 1
  %exitcond.not = icmp eq i64 %31, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %13, !llvm.loop !8

._crit_edge.us:                                   ; preds = %13
  %32 = getelementptr inbounds i8, ptr %.036.us, i64 %1
  %33 = getelementptr inbounds i8, ptr %.02635.us, i64 %5
  %34 = getelementptr inbounds i8, ptr %.02933.us, i64 %7
  %35 = getelementptr inbounds i8, ptr %.03032.us, i64 %10
  %36 = add nuw i64 %.02834.us, 1
  %exitcond40.not = icmp eq i64 %36, %3
  br i1 %exitcond40.not, label %._crit_edge37, label %.preheader.us, !llvm.loop !10

._crit_edge37:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %11
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local noundef i32 @_ZN4Simd4Base17FeatureDifferenceEiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base21ShiftedWeightedSquareEii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base3MinEii(i32 noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { 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 = { 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 = { alwaysinline 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" }

!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,TailCallElimPass