; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl/mathop_sse2.ll (vl_distance_l2_sse2_d)

; 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: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_setzero_pd() #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_mul_pd(<2 x double> noundef, <2 x double> noundef) #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_add_pd(<2 x double> noundef, <2 x double> noundef) #1

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_loadu_pd(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @_vl_vhsum_sse2_d(<2 x double> noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local double @_vl_distance_l2_sse2_d(i64 noundef %0, ptr noundef %1, ptr noundef %2) #4 {
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca <2 x double>, align 16
  %11 = alloca i32, align 4
  %12 = alloca <2 x double>, align 16
  %13 = alloca <2 x double>, align 16
  %14 = alloca <2 x double>, align 16
  %15 = alloca <2 x double>, align 16
  %16 = alloca <2 x double>, align 16
  %17 = alloca <2 x double>, align 16
  %18 = alloca <2 x double>, align 16
  %19 = alloca <2 x double>, align 16
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds double, ptr %23, i64 %24
  store ptr %25, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = getelementptr inbounds double, ptr %26, i64 -2
  %28 = getelementptr inbounds double, ptr %27, i64 1
  store ptr %28, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  %29 = call <2 x double> @_mm_setzero_pd()
  store <2 x double> %29, ptr %10, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = ptrtoint ptr %30 to i64
  %32 = and i64 %31, 15
  %33 = icmp ne i64 %32, 0
  %34 = xor i1 %33, true
  %35 = zext i1 %34 to i32
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = ptrtoint ptr %36 to i64
  %38 = and i64 %37, 15
  %39 = icmp ne i64 %38, 0
  %40 = xor i1 %39, true
  %41 = zext i1 %40 to i32
  %42 = and i32 %35, %41
  store i32 %42, ptr %11, align 4, !tbaa !12
  %43 = load i32, ptr %11, align 4, !tbaa !12
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %69

45:                                               ; preds = %3
  br label %46

46:                                               ; preds = %50, %45
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !9
  %49 = icmp ult ptr %47, %48
  br i1 %49, label %50, label %68

50:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  %51 = load ptr, ptr %5, align 8, !tbaa !9
  %52 = load <2 x double>, ptr %51, align 16, !tbaa !11
  store <2 x double> %52, ptr %12, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  %53 = load ptr, ptr %6, align 8, !tbaa !9
  %54 = load <2 x double>, ptr %53, align 16, !tbaa !11
  store <2 x double> %54, ptr %13, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #5
  %55 = load <2 x double>, ptr %12, align 16, !tbaa !11
  %56 = load <2 x double>, ptr %13, align 16, !tbaa !11
  %57 = call <2 x double> @_mm_sub_pd(<2 x double> noundef %55, <2 x double> noundef %56)
  store <2 x double> %57, ptr %14, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  %58 = load <2 x double>, ptr %14, align 16, !tbaa !11
  %59 = load <2 x double>, ptr %14, align 16, !tbaa !11
  %60 = call <2 x double> @_mm_mul_pd(<2 x double> noundef %58, <2 x double> noundef %59)
  store <2 x double> %60, ptr %15, align 16, !tbaa !11
  %61 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %62 = load <2 x double>, ptr %15, align 16, !tbaa !11
  %63 = call <2 x double> @_mm_add_pd(<2 x double> noundef %61, <2 x double> noundef %62)
  store <2 x double> %63, ptr %10, align 16, !tbaa !11
  %64 = load ptr, ptr %5, align 8, !tbaa !9
  %65 = getelementptr inbounds double, ptr %64, i64 2
  store ptr %65, ptr %5, align 8, !tbaa !9
  %66 = load ptr, ptr %6, align 8, !tbaa !9
  %67 = getelementptr inbounds double, ptr %66, i64 2
  store ptr %67, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  br label %46, !llvm.loop !14

68:                                               ; preds = %46
  br label %93

69:                                               ; preds = %3
  br label %70

70:                                               ; preds = %74, %69
  %71 = load ptr, ptr %5, align 8, !tbaa !9
  %72 = load ptr, ptr %8, align 8, !tbaa !9
  %73 = icmp ult ptr %71, %72
  br i1 %73, label %74, label %92

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #5
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = call <2 x double> @_mm_loadu_pd(ptr noundef %75)
  store <2 x double> %76, ptr %16, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #5
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  %78 = call <2 x double> @_mm_loadu_pd(ptr noundef %77)
  store <2 x double> %78, ptr %17, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %18) #5
  %79 = load <2 x double>, ptr %16, align 16, !tbaa !11
  %80 = load <2 x double>, ptr %17, align 16, !tbaa !11
  %81 = call <2 x double> @_mm_sub_pd(<2 x double> noundef %79, <2 x double> noundef %80)
  store <2 x double> %81, ptr %18, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #5
  %82 = load <2 x double>, ptr %18, align 16, !tbaa !11
  %83 = load <2 x double>, ptr %18, align 16, !tbaa !11
  %84 = call <2 x double> @_mm_mul_pd(<2 x double> noundef %82, <2 x double> noundef %83)
  store <2 x double> %84, ptr %19, align 16, !tbaa !11
  %85 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %86 = load <2 x double>, ptr %19, align 16, !tbaa !11
  %87 = call <2 x double> @_mm_add_pd(<2 x double> noundef %85, <2 x double> noundef %86)
  store <2 x double> %87, ptr %10, align 16, !tbaa !11
  %88 = load ptr, ptr %5, align 8, !tbaa !9
  %89 = getelementptr inbounds double, ptr %88, i64 2
  store ptr %89, ptr %5, align 8, !tbaa !9
  %90 = load ptr, ptr %6, align 8, !tbaa !9
  %91 = getelementptr inbounds double, ptr %90, i64 2
  store ptr %91, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #5
  br label %70, !llvm.loop !16

92:                                               ; preds = %70
  br label %93

93:                                               ; preds = %92, %68
  %94 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %95 = call double @_vl_vhsum_sse2_d(<2 x double> noundef %94)
  store double %95, ptr %9, align 8, !tbaa !17
  br label %96

96:                                               ; preds = %100, %93
  %97 = load ptr, ptr %5, align 8, !tbaa !9
  %98 = load ptr, ptr %7, align 8, !tbaa !9
  %99 = icmp ult ptr %97, %98
  br i1 %99, label %100, label %114

100:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %101 = load ptr, ptr %5, align 8, !tbaa !9
  %102 = getelementptr inbounds double, ptr %101, i32 1
  store ptr %102, ptr %5, align 8, !tbaa !9
  %103 = load double, ptr %101, align 8, !tbaa !17
  store double %103, ptr %20, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %104 = load ptr, ptr %6, align 8, !tbaa !9
  %105 = getelementptr inbounds double, ptr %104, i32 1
  store ptr %105, ptr %6, align 8, !tbaa !9
  %106 = load double, ptr %104, align 8, !tbaa !17
  store double %106, ptr %21, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  %107 = load double, ptr %20, align 8, !tbaa !17
  %108 = load double, ptr %21, align 8, !tbaa !17
  %109 = fsub double %107, %108
  store double %109, ptr %22, align 8, !tbaa !17
  %110 = load double, ptr %22, align 8, !tbaa !17
  %111 = load double, ptr %22, align 8, !tbaa !17
  %112 = load double, ptr %9, align 8, !tbaa !17
  %113 = call double @llvm.fmuladd.f64(double %110, double %111, double %112)
  store double %113, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  br label %96, !llvm.loop !19

114:                                              ; preds = %96
  %115 = load double, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret double %115
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_sub_pd(<2 x double> noundef, <2 x double> noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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 = { inlinehint nounwind uwtable "min-legal-vector-width"="128" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="128" "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 #5 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = distinct !{!19, !15}


; 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 nounwind uwtable
declare hidden <2 x double> @_mm_setzero_pd() local_unnamed_addr #0

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_mul_pd(<2 x double> noundef, <2 x double> noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_add_pd(<2 x double> noundef, <2 x double> noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_loadu_pd(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden double @_vl_vhsum_sse2_d(<2 x double> noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local double @_vl_distance_l2_sse2_d(i64 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = getelementptr inbounds double, ptr %1, i64 %0
  %5 = getelementptr inbounds i8, ptr %4, i64 -8
  %6 = tail call <2 x double> @_mm_setzero_pd()
  %7 = ptrtoint ptr %1 to i64
  %8 = ptrtoint ptr %2 to i64
  %9 = or i64 %8, %7
  %10 = and i64 %9, 15
  %11 = icmp eq i64 %10, 0
  %12 = icmp ugt ptr %5, %1
  br i1 %11, label %.preheader, label %.preheader49

.preheader49:                                     ; preds = %3
  br i1 %12, label %.lr.ph, label %.loopexit

.preheader:                                       ; preds = %3
  br i1 %12, label %.lr.ph59, label %.loopexit

.lr.ph59:                                         ; preds = %.preheader, %.lr.ph59
  %.058 = phi ptr [ %18, %.lr.ph59 ], [ %1, %.preheader ]
  %.04057 = phi ptr [ %19, %.lr.ph59 ], [ %2, %.preheader ]
  %.04556 = phi <2 x double> [ %17, %.lr.ph59 ], [ %6, %.preheader ]
  %13 = load <2 x double>, ptr %.058, align 16, !tbaa !5
  %14 = load <2 x double>, ptr %.04057, align 16, !tbaa !5
  %15 = tail call <2 x double> @_mm_sub_pd(<2 x double> noundef %13, <2 x double> noundef %14)
  %16 = tail call <2 x double> @_mm_mul_pd(<2 x double> noundef %15, <2 x double> noundef %15)
  %17 = tail call <2 x double> @_mm_add_pd(<2 x double> noundef %.04556, <2 x double> noundef %16)
  %18 = getelementptr inbounds i8, ptr %.058, i64 16
  %19 = getelementptr inbounds i8, ptr %.04057, i64 16
  %20 = icmp ult ptr %18, %5
  br i1 %20, label %.lr.ph59, label %.loopexit, !llvm.loop !8

.lr.ph:                                           ; preds = %.preheader49, %.lr.ph
  %.153 = phi ptr [ %26, %.lr.ph ], [ %1, %.preheader49 ]
  %.14152 = phi ptr [ %27, %.lr.ph ], [ %2, %.preheader49 ]
  %.14651 = phi <2 x double> [ %25, %.lr.ph ], [ %6, %.preheader49 ]
  %21 = tail call <2 x double> @_mm_loadu_pd(ptr noundef %.153)
  %22 = tail call <2 x double> @_mm_loadu_pd(ptr noundef %.14152)
  %23 = tail call <2 x double> @_mm_sub_pd(<2 x double> noundef %21, <2 x double> noundef %22)
  %24 = tail call <2 x double> @_mm_mul_pd(<2 x double> noundef %23, <2 x double> noundef %23)
  %25 = tail call <2 x double> @_mm_add_pd(<2 x double> noundef %.14651, <2 x double> noundef %24)
  %26 = getelementptr inbounds i8, ptr %.153, i64 16
  %27 = getelementptr inbounds i8, ptr %.14152, i64 16
  %28 = icmp ult ptr %26, %5
  br i1 %28, label %.lr.ph, label %.loopexit, !llvm.loop !10

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph59, %.preheader49, %.preheader
  %.247 = phi <2 x double> [ %6, %.preheader ], [ %6, %.preheader49 ], [ %17, %.lr.ph59 ], [ %25, %.lr.ph ]
  %.242 = phi ptr [ %2, %.preheader ], [ %2, %.preheader49 ], [ %19, %.lr.ph59 ], [ %27, %.lr.ph ]
  %.2 = phi ptr [ %1, %.preheader ], [ %1, %.preheader49 ], [ %18, %.lr.ph59 ], [ %26, %.lr.ph ]
  %29 = tail call double @_vl_vhsum_sse2_d(<2 x double> noundef %.247)
  %30 = icmp ult ptr %.2, %4
  br i1 %30, label %.lr.ph66, label %._crit_edge

.lr.ph66:                                         ; preds = %.loopexit, %.lr.ph66
  %.365 = phi ptr [ %31, %.lr.ph66 ], [ %.2, %.loopexit ]
  %.34364 = phi ptr [ %33, %.lr.ph66 ], [ %.242, %.loopexit ]
  %.04463 = phi double [ %36, %.lr.ph66 ], [ %29, %.loopexit ]
  %31 = getelementptr inbounds i8, ptr %.365, i64 8
  %32 = load double, ptr %.365, align 8, !tbaa !11
  %33 = getelementptr inbounds i8, ptr %.34364, i64 8
  %34 = load double, ptr %.34364, align 8, !tbaa !11
  %35 = fsub double %32, %34
  %36 = tail call double @llvm.fmuladd.f64(double %35, double %35, double %.04463)
  %37 = icmp ult ptr %31, %4
  br i1 %37, label %.lr.ph66, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph66, %.loopexit
  %.044.lcssa = phi double [ %29, %.loopexit ], [ %36, %.lr.ph66 ]
  ret double %.044.lcssa
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_sub_pd(<2 x double> noundef, <2 x double> noundef) local_unnamed_addr #0

attributes #0 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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 = { inlinehint nounwind uwtable "min-legal-vector-width"="128" "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="128" "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/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !6, i64 0}
!13 = distinct !{!13, !9}


; Effective O3 passes: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass