; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libLocalDesc/surf/lib_match_surf.ll (Z17euclideanDistanceP10descriptorS0_)

; 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.descriptor = type { ptr, ptr }
%class.vectorDescriptor = type { double, double, double, double }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_Z17euclideanDistanceP10descriptorS0_(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %7

7:                                                ; preds = %156, %2
  %8 = load i32, ptr %6, align 4, !tbaa !11
  %9 = icmp slt i32 %8, 16
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %159

11:                                               ; preds = %7
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %class.descriptor, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = load i32, ptr %6, align 4, !tbaa !11
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds %class.vectorDescriptor, ptr %14, i64 %16
  %18 = getelementptr inbounds %class.vectorDescriptor, ptr %17, i32 0, i32 0
  %19 = load double, ptr %18, align 8, !tbaa !15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.descriptor, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load i32, ptr %6, align 4, !tbaa !11
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds %class.vectorDescriptor, ptr %22, i64 %24
  %26 = getelementptr inbounds %class.vectorDescriptor, ptr %25, i32 0, i32 0
  %27 = load double, ptr %26, align 8, !tbaa !15
  %28 = fsub double %19, %27
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.descriptor, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = load i32, ptr %6, align 4, !tbaa !11
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %class.vectorDescriptor, ptr %31, i64 %33
  %35 = getelementptr inbounds %class.vectorDescriptor, ptr %34, i32 0, i32 0
  %36 = load double, ptr %35, align 8, !tbaa !15
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.descriptor, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !13
  %40 = load i32, ptr %6, align 4, !tbaa !11
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %class.vectorDescriptor, ptr %39, i64 %41
  %43 = getelementptr inbounds %class.vectorDescriptor, ptr %42, i32 0, i32 0
  %44 = load double, ptr %43, align 8, !tbaa !15
  %45 = fsub double %36, %44
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %class.descriptor, ptr %46, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = load i32, ptr %6, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %class.vectorDescriptor, ptr %48, i64 %50
  %52 = getelementptr inbounds %class.vectorDescriptor, ptr %51, i32 0, i32 1
  %53 = load double, ptr %52, align 8, !tbaa !18
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %class.descriptor, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = load i32, ptr %6, align 4, !tbaa !11
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %class.vectorDescriptor, ptr %56, i64 %58
  %60 = getelementptr inbounds %class.vectorDescriptor, ptr %59, i32 0, i32 1
  %61 = load double, ptr %60, align 8, !tbaa !18
  %62 = fsub double %53, %61
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %class.descriptor, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = load i32, ptr %6, align 4, !tbaa !11
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds %class.vectorDescriptor, ptr %65, i64 %67
  %69 = getelementptr inbounds %class.vectorDescriptor, ptr %68, i32 0, i32 1
  %70 = load double, ptr %69, align 8, !tbaa !18
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %class.descriptor, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !13
  %74 = load i32, ptr %6, align 4, !tbaa !11
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds %class.vectorDescriptor, ptr %73, i64 %75
  %77 = getelementptr inbounds %class.vectorDescriptor, ptr %76, i32 0, i32 1
  %78 = load double, ptr %77, align 8, !tbaa !18
  %79 = fsub double %70, %78
  %80 = fmul double %62, %79
  %81 = call double @llvm.fmuladd.f64(double %28, double %45, double %80)
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  %83 = getelementptr inbounds %class.descriptor, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = load i32, ptr %6, align 4, !tbaa !11
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds %class.vectorDescriptor, ptr %84, i64 %86
  %88 = getelementptr inbounds %class.vectorDescriptor, ptr %87, i32 0, i32 3
  %89 = load double, ptr %88, align 8, !tbaa !19
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %class.descriptor, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !13
  %93 = load i32, ptr %6, align 4, !tbaa !11
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds %class.vectorDescriptor, ptr %92, i64 %94
  %96 = getelementptr inbounds %class.vectorDescriptor, ptr %95, i32 0, i32 3
  %97 = load double, ptr %96, align 8, !tbaa !19
  %98 = fsub double %89, %97
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %class.descriptor, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !13
  %102 = load i32, ptr %6, align 4, !tbaa !11
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds %class.vectorDescriptor, ptr %101, i64 %103
  %105 = getelementptr inbounds %class.vectorDescriptor, ptr %104, i32 0, i32 3
  %106 = load double, ptr %105, align 8, !tbaa !19
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = getelementptr inbounds %class.descriptor, ptr %107, i32 0, i32 0
  %109 = load ptr, ptr %108, align 8, !tbaa !13
  %110 = load i32, ptr %6, align 4, !tbaa !11
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %class.vectorDescriptor, ptr %109, i64 %111
  %113 = getelementptr inbounds %class.vectorDescriptor, ptr %112, i32 0, i32 3
  %114 = load double, ptr %113, align 8, !tbaa !19
  %115 = fsub double %106, %114
  %116 = call double @llvm.fmuladd.f64(double %98, double %115, double %81)
  %117 = load ptr, ptr %3, align 8, !tbaa !5
  %118 = getelementptr inbounds %class.descriptor, ptr %117, i32 0, i32 0
  %119 = load ptr, ptr %118, align 8, !tbaa !13
  %120 = load i32, ptr %6, align 4, !tbaa !11
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds %class.vectorDescriptor, ptr %119, i64 %121
  %123 = getelementptr inbounds %class.vectorDescriptor, ptr %122, i32 0, i32 2
  %124 = load double, ptr %123, align 8, !tbaa !20
  %125 = load ptr, ptr %4, align 8, !tbaa !5
  %126 = getelementptr inbounds %class.descriptor, ptr %125, i32 0, i32 0
  %127 = load ptr, ptr %126, align 8, !tbaa !13
  %128 = load i32, ptr %6, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds %class.vectorDescriptor, ptr %127, i64 %129
  %131 = getelementptr inbounds %class.vectorDescriptor, ptr %130, i32 0, i32 2
  %132 = load double, ptr %131, align 8, !tbaa !20
  %133 = fsub double %124, %132
  %134 = load ptr, ptr %3, align 8, !tbaa !5
  %135 = getelementptr inbounds %class.descriptor, ptr %134, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !13
  %137 = load i32, ptr %6, align 4, !tbaa !11
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds %class.vectorDescriptor, ptr %136, i64 %138
  %140 = getelementptr inbounds %class.vectorDescriptor, ptr %139, i32 0, i32 2
  %141 = load double, ptr %140, align 8, !tbaa !20
  %142 = load ptr, ptr %4, align 8, !tbaa !5
  %143 = getelementptr inbounds %class.descriptor, ptr %142, i32 0, i32 0
  %144 = load ptr, ptr %143, align 8, !tbaa !13
  %145 = load i32, ptr %6, align 4, !tbaa !11
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds %class.vectorDescriptor, ptr %144, i64 %146
  %148 = getelementptr inbounds %class.vectorDescriptor, ptr %147, i32 0, i32 2
  %149 = load double, ptr %148, align 8, !tbaa !20
  %150 = fsub double %141, %149
  %151 = call double @llvm.fmuladd.f64(double %133, double %150, double %116)
  %152 = load float, ptr %5, align 4, !tbaa !9
  %153 = fpext float %152 to double
  %154 = fadd double %153, %151
  %155 = fptrunc double %154 to float
  store float %155, ptr %5, align 4, !tbaa !9
  br label %156

156:                                              ; preds = %11
  %157 = load i32, ptr %6, align 4, !tbaa !11
  %158 = add nsw i32 %157, 1
  store i32 %158, ptr %6, align 4, !tbaa !11
  br label %7, !llvm.loop !21

159:                                              ; preds = %10
  %160 = load float, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float %160
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS10descriptor", !6, i64 0, !6, i64 8}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTS16vectorDescriptor", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24}
!17 = !{!"double", !7, i64 0}
!18 = !{!16, !17, i64 8}
!19 = !{!16, !17, i64 24}
!20 = !{!16, !17, i64 16}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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

%class.vectorDescriptor = type { double, double, double, double }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef float @_Z17euclideanDistanceP10descriptorS0_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  br label %6

5:                                                ; preds = %6
  ret float %33

6:                                                ; preds = %2, %6
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next, %6 ]
  %.03536 = phi float [ 0.000000e+00, %2 ], [ %33, %6 ]
  %7 = getelementptr inbounds %class.vectorDescriptor, ptr %3, i64 %indvars.iv
  %8 = load double, ptr %7, align 8, !tbaa !10
  %9 = getelementptr inbounds %class.vectorDescriptor, ptr %4, i64 %indvars.iv
  %10 = load double, ptr %9, align 8, !tbaa !10
  %11 = fsub double %8, %10
  %12 = getelementptr inbounds i8, ptr %7, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %9, i64 8
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = fsub double %13, %15
  %17 = fmul double %16, %16
  %18 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %17)
  %19 = getelementptr inbounds i8, ptr %7, i64 24
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %9, i64 24
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = fsub double %20, %22
  %24 = tail call double @llvm.fmuladd.f64(double %23, double %23, double %18)
  %25 = getelementptr inbounds i8, ptr %7, i64 16
  %26 = load double, ptr %25, align 8, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %9, i64 16
  %28 = load double, ptr %27, align 8, !tbaa !15
  %29 = fsub double %26, %28
  %30 = tail call double @llvm.fmuladd.f64(double %29, double %29, double %24)
  %31 = fpext float %.03536 to double
  %32 = fadd double %30, %31
  %33 = fptrunc double %32 to float
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 16
  br i1 %exitcond.not, label %5, label %6, !llvm.loop !16
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, 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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"_ZTS10descriptor", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !12, i64 0}
!11 = !{!"_ZTS16vectorDescriptor", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"double", !8, i64 0}
!13 = !{!11, !12, i64 8}
!14 = !{!11, !12, i64 24}
!15 = !{!11, !12, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass