; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseDescrInt.ll (ZNK4Simd4Base8DescrInt19CosineDistancesMxNaEmmPKPKhS5_Pf)

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

%"class.Simd::Base::DescrInt" = type { %"struct.Simd::Deletable", ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i64, i64, float, ptr, i64, i64, ptr, ptr, ptr, ptr, ptr, i64, i64, i64 }
%"struct.Simd::Deletable" = type { ptr }

; 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 uwtable
define dso_local void @_ZNK4Simd4Base8DescrInt19CosineDistancesMxNaEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184) %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store i64 %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8
  %19 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 12
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %59

22:                                               ; preds = %6
  %23 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 22
  %24 = load i64, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 21
  %26 = load i64, ptr %25, align 8, !tbaa !16
  %27 = mul i64 %24, %26
  %28 = call noundef i64 @_ZN4Simd4Base10AlgCacheL1Ev()
  %29 = icmp ugt i64 %27, %28
  br i1 %29, label %46, label %30

30:                                               ; preds = %22
  %31 = load i64, ptr %9, align 8, !tbaa !9
  %32 = mul i64 %31, 2
  %33 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 21
  %34 = load i64, ptr %33, align 8, !tbaa !16
  %35 = icmp ult i64 %32, %34
  br i1 %35, label %46, label %36

36:                                               ; preds = %30
  %37 = load i64, ptr %8, align 8, !tbaa !9
  %38 = mul i64 %37, 2
  %39 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 20
  %40 = load i64, ptr %39, align 8, !tbaa !17
  %41 = icmp ult i64 %38, %40
  br i1 %41, label %46, label %42

42:                                               ; preds = %36
  %43 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 19
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %52

46:                                               ; preds = %42, %36, %30, %22
  %47 = load i64, ptr %8, align 8, !tbaa !9
  %48 = load i64, ptr %9, align 8, !tbaa !9
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZNK4Simd4Base8DescrInt21CosineDistancesDirectEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184) %18, i64 noundef %47, i64 noundef %48, ptr noundef %49, ptr noundef %50, ptr noundef %51)
  br label %58

52:                                               ; preds = %42
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = load i64, ptr %9, align 8, !tbaa !9
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZNK4Simd4Base8DescrInt21CosineDistancesUnpackEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184) %18, i64 noundef %53, i64 noundef %54, ptr noundef %55, ptr noundef %56, ptr noundef %57)
  br label %58

58:                                               ; preds = %52, %46
  br label %96

59:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %92, %59
  %61 = load i64, ptr %13, align 8, !tbaa !9
  %62 = load i64, ptr %8, align 8, !tbaa !9
  %63 = icmp ult i64 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %95

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load i64, ptr %13, align 8, !tbaa !9
  %68 = getelementptr inbounds ptr, ptr %66, i64 %67
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  store ptr %69, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %70

70:                                               ; preds = %88, %65
  %71 = load i64, ptr %16, align 8, !tbaa !9
  %72 = load i64, ptr %9, align 8, !tbaa !9
  %73 = icmp ult i64 %71, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %70
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  br label %91

75:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = load i64, ptr %16, align 8, !tbaa !9
  %78 = getelementptr inbounds ptr, ptr %76, i64 %77
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  store ptr %79, ptr %17, align 8, !tbaa !5
  %80 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 7
  %81 = load ptr, ptr %80, align 8, !tbaa !19
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  %83 = load ptr, ptr %17, align 8, !tbaa !5
  %84 = getelementptr inbounds %"class.Simd::Base::DescrInt", ptr %18, i32 0, i32 8
  %85 = load i64, ptr %84, align 8, !tbaa !20
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  %87 = getelementptr inbounds float, ptr %86, i32 1
  store ptr %87, ptr %12, align 8, !tbaa !5
  call void %81(ptr noundef %82, ptr noundef %83, i64 noundef %85, ptr noundef %86)
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %88

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

91:                                               ; preds = %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %92

92:                                               ; preds = %91
  %93 = load i64, ptr %13, align 8, !tbaa !9
  %94 = add i64 %93, 1
  store i64 %94, ptr %13, align 8, !tbaa !9
  br label %60, !llvm.loop !23

95:                                               ; preds = %64
  br label %96

96:                                               ; preds = %95, %58
  ret void
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4Simd4Base10AlgCacheL1Ev() #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4Simd4Base8DescrInt21CosineDistancesDirectEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184), i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4Simd4Base8DescrInt21CosineDistancesUnpackEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184), i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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" }
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 = !{!12, !6, i64 96}
!12 = !{!"_ZTSN4Simd4Base8DescrIntE", !13, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !14, i64 88, !6, i64 96, !10, i64 104, !10, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !10, i64 160, !10, i64 168, !10, i64 176}
!13 = !{!"_ZTSN4Simd9DeletableE"}
!14 = !{!"float", !7, i64 0}
!15 = !{!12, !10, i64 176}
!16 = !{!12, !10, i64 168}
!17 = !{!12, !10, i64 160}
!18 = !{!12, !6, i64 152}
!19 = !{!12, !6, i64 56}
!20 = !{!12, !10, i64 64}
!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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK4Simd4Base8DescrInt19CosineDistancesMxNaEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184) %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #0 align 2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %.preheader, label %21

.preheader:                                       ; preds = %6
  %.not34 = icmp eq i64 %1, 0
  br i1 %.not34, label %.loopexit, label %.lr.ph33

.lr.ph33:                                         ; preds = %.preheader
  %.not35 = icmp eq i64 %2, 0
  %9 = getelementptr inbounds i8, ptr %0, i64 56
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  br i1 %.not35, label %.loopexit, label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph33, %._crit_edge.us
  %.032.us = phi ptr [ %18, %._crit_edge.us ], [ %5, %.lr.ph33 ]
  %.02631.us = phi i64 [ %20, %._crit_edge.us ], [ 0, %.lr.ph33 ]
  %11 = getelementptr inbounds ptr, ptr %3, i64 %.02631.us
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  br label %13

13:                                               ; preds = %.lr.ph.us, %13
  %.130.us = phi ptr [ %.032.us, %.lr.ph.us ], [ %18, %13 ]
  %.02529.us = phi i64 [ 0, %.lr.ph.us ], [ %19, %13 ]
  %14 = getelementptr inbounds ptr, ptr %4, i64 %.02529.us
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = load ptr, ptr %9, align 8, !tbaa !14
  %17 = load i64, ptr %10, align 8, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %.130.us, i64 4
  tail call void %16(ptr noundef %12, ptr noundef %15, i64 noundef %17, ptr noundef %.130.us)
  %19 = add nuw i64 %.02529.us, 1
  %exitcond.not = icmp eq i64 %19, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %13, !llvm.loop !16

._crit_edge.us:                                   ; preds = %13
  %20 = add nuw i64 %.02631.us, 1
  %exitcond37.not = icmp eq i64 %20, %1
  br i1 %exitcond37.not, label %.loopexit, label %.lr.ph.us, !llvm.loop !18

21:                                               ; preds = %6
  %22 = getelementptr inbounds i8, ptr %0, i64 176
  %23 = load i64, ptr %22, align 8, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %0, i64 168
  %25 = load i64, ptr %24, align 8, !tbaa !20
  %26 = mul i64 %25, %23
  %27 = tail call noundef i64 @_ZN4Simd4Base10AlgCacheL1Ev()
  %28 = icmp ugt i64 %26, %27
  br i1 %28, label %41, label %29

29:                                               ; preds = %21
  %30 = shl i64 %2, 1
  %31 = load i64, ptr %24, align 8, !tbaa !20
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %41, label %33

33:                                               ; preds = %29
  %34 = shl i64 %1, 1
  %35 = getelementptr inbounds i8, ptr %0, i64 160
  %36 = load i64, ptr %35, align 8, !tbaa !21
  %37 = icmp ult i64 %34, %36
  %38 = getelementptr inbounds i8, ptr %0, i64 152
  %39 = load ptr, ptr %38, align 8
  %40 = icmp eq ptr %39, null
  %or.cond = select i1 %37, i1 true, i1 %40
  br i1 %or.cond, label %41, label %42

41:                                               ; preds = %33, %29, %21
  tail call void @_ZNK4Simd4Base8DescrInt21CosineDistancesDirectEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184) %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  br label %.loopexit

42:                                               ; preds = %33
  tail call void @_ZNK4Simd4Base8DescrInt21CosineDistancesUnpackEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184) %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  br label %.loopexit

.loopexit:                                        ; preds = %._crit_edge.us, %.lr.ph33, %.preheader, %41, %42
  ret void
}

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN4Simd4Base10AlgCacheL1Ev() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4Simd4Base8DescrInt21CosineDistancesDirectEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184), i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4Simd4Base8DescrInt21CosineDistancesUnpackEmmPKPKhS5_Pf(ptr noundef nonnull align 8 dereferenceable(184), i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0 align 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 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, !8, i64 96}
!6 = !{!"_ZTSN4Simd4Base8DescrIntE", !7, i64 0, !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !12, i64 88, !8, i64 96, !11, i64 104, !11, i64 112, !8, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !8, i64 152, !11, i64 160, !11, i64 168, !11, i64 176}
!7 = !{!"_ZTSN4Simd9DeletableE"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"float", !9, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!6, !8, i64 56}
!15 = !{!6, !11, i64 64}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{!6, !11, i64 176}
!20 = !{!6, !11, i64 168}
!21 = !{!6, !11, i64 160}


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