; LLVM IR from QiaoLiuHit/LSOTB-TIR :: vlfeat-0.9.19/vl/mathop_sse2.ll (vl_kernel_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_kernel_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 double, align 8
  %17 = 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
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = load i64, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %18, i64 %19
  store ptr %20, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %21 = load ptr, ptr %7, align 8, !tbaa !9
  %22 = getelementptr inbounds double, ptr %21, i64 -2
  %23 = getelementptr inbounds double, ptr %22, i64 1
  store ptr %23, 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
  %24 = call <2 x double> @_mm_setzero_pd()
  store <2 x double> %24, ptr %10, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = ptrtoint ptr %25 to i64
  %27 = and i64 %26, 15
  %28 = icmp ne i64 %27, 0
  %29 = xor i1 %28, true
  %30 = zext i1 %29 to i32
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = ptrtoint ptr %31 to i64
  %33 = and i64 %32, 15
  %34 = icmp ne i64 %33, 0
  %35 = xor i1 %34, true
  %36 = zext i1 %35 to i32
  %37 = and i32 %30, %36
  store i32 %37, ptr %11, align 4, !tbaa !12
  %38 = load i32, ptr %11, align 4, !tbaa !12
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %60

40:                                               ; preds = %3
  br label %41

41:                                               ; preds = %45, %40
  %42 = load ptr, ptr %5, align 8, !tbaa !9
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = icmp ult ptr %42, %43
  br i1 %44, label %45, label %59

45:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  %46 = load ptr, ptr %5, align 8, !tbaa !9
  %47 = load <2 x double>, ptr %46, align 16, !tbaa !11
  store <2 x double> %47, ptr %12, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  %48 = load ptr, ptr %6, align 8, !tbaa !9
  %49 = load <2 x double>, ptr %48, align 16, !tbaa !11
  store <2 x double> %49, ptr %13, align 16, !tbaa !11
  %50 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %51 = load <2 x double>, ptr %12, align 16, !tbaa !11
  %52 = load <2 x double>, ptr %13, align 16, !tbaa !11
  %53 = call <2 x double> @_mm_mul_pd(<2 x double> noundef %51, <2 x double> noundef %52)
  %54 = call <2 x double> @_mm_add_pd(<2 x double> noundef %50, <2 x double> noundef %53)
  store <2 x double> %54, ptr %10, align 16, !tbaa !11
  %55 = load ptr, ptr %5, align 8, !tbaa !9
  %56 = getelementptr inbounds double, ptr %55, i64 2
  store ptr %56, ptr %5, align 8, !tbaa !9
  %57 = load ptr, ptr %6, align 8, !tbaa !9
  %58 = getelementptr inbounds double, ptr %57, i64 2
  store ptr %58, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #5
  br label %41, !llvm.loop !14

59:                                               ; preds = %41
  br label %80

60:                                               ; preds = %3
  br label %61

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

65:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #5
  %66 = load ptr, ptr %5, align 8, !tbaa !9
  %67 = call <2 x double> @_mm_loadu_pd(ptr noundef %66)
  store <2 x double> %67, ptr %14, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  %68 = load ptr, ptr %6, align 8, !tbaa !9
  %69 = call <2 x double> @_mm_loadu_pd(ptr noundef %68)
  store <2 x double> %69, ptr %15, align 16, !tbaa !11
  %70 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %71 = load <2 x double>, ptr %14, align 16, !tbaa !11
  %72 = load <2 x double>, ptr %15, align 16, !tbaa !11
  %73 = call <2 x double> @_mm_mul_pd(<2 x double> noundef %71, <2 x double> noundef %72)
  %74 = call <2 x double> @_mm_add_pd(<2 x double> noundef %70, <2 x double> noundef %73)
  store <2 x double> %74, ptr %10, align 16, !tbaa !11
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = getelementptr inbounds double, ptr %75, i64 2
  store ptr %76, ptr %5, align 8, !tbaa !9
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  %78 = getelementptr inbounds double, ptr %77, i64 2
  store ptr %78, 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
  br label %61, !llvm.loop !16

79:                                               ; preds = %61
  br label %80

80:                                               ; preds = %79, %59
  %81 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %82 = call double @_vl_vhsum_sse2_d(<2 x double> noundef %81)
  store double %82, ptr %9, align 8, !tbaa !17
  br label %83

83:                                               ; preds = %87, %80
  %84 = load ptr, ptr %5, align 8, !tbaa !9
  %85 = load ptr, ptr %7, align 8, !tbaa !9
  %86 = icmp ult ptr %84, %85
  br i1 %86, label %87, label %98

87:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %88 = load ptr, ptr %5, align 8, !tbaa !9
  %89 = getelementptr inbounds double, ptr %88, i32 1
  store ptr %89, ptr %5, align 8, !tbaa !9
  %90 = load double, ptr %88, align 8, !tbaa !17
  store double %90, ptr %16, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %91 = load ptr, ptr %6, align 8, !tbaa !9
  %92 = getelementptr inbounds double, ptr %91, i32 1
  store ptr %92, ptr %6, align 8, !tbaa !9
  %93 = load double, ptr %91, align 8, !tbaa !17
  store double %93, ptr %17, align 8, !tbaa !17
  %94 = load double, ptr %16, align 8, !tbaa !17
  %95 = load double, ptr %17, align 8, !tbaa !17
  %96 = load double, ptr %9, align 8, !tbaa !17
  %97 = call double @llvm.fmuladd.f64(double %94, double %95, double %96)
  store double %97, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %83, !llvm.loop !19

98:                                               ; preds = %83
  %99 = 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 %99
}

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_kernel_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 %.preheader41

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

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

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

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

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph51, %.preheader41, %.preheader
  %.239 = phi <2 x double> [ %6, %.preheader ], [ %6, %.preheader41 ], [ %16, %.lr.ph51 ], [ %23, %.lr.ph ]
  %.234 = phi ptr [ %2, %.preheader ], [ %2, %.preheader41 ], [ %18, %.lr.ph51 ], [ %25, %.lr.ph ]
  %.2 = phi ptr [ %1, %.preheader ], [ %1, %.preheader41 ], [ %17, %.lr.ph51 ], [ %24, %.lr.ph ]
  %27 = tail call double @_vl_vhsum_sse2_d(<2 x double> noundef %.239)
  %28 = icmp ult ptr %.2, %4
  br i1 %28, label %.lr.ph58, label %._crit_edge

.lr.ph58:                                         ; preds = %.loopexit, %.lr.ph58
  %.357 = phi ptr [ %29, %.lr.ph58 ], [ %.2, %.loopexit ]
  %.33556 = phi ptr [ %31, %.lr.ph58 ], [ %.234, %.loopexit ]
  %.03655 = phi double [ %33, %.lr.ph58 ], [ %27, %.loopexit ]
  %29 = getelementptr inbounds i8, ptr %.357, i64 8
  %30 = load double, ptr %.357, align 8, !tbaa !11
  %31 = getelementptr inbounds i8, ptr %.33556, i64 8
  %32 = load double, ptr %.33556, align 8, !tbaa !11
  %33 = tail call double @llvm.fmuladd.f64(double %30, double %32, double %.03655)
  %34 = icmp ult ptr %29, %4
  br i1 %34, label %.lr.ph58, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph58, %.loopexit
  %.036.lcssa = phi double [ %27, %.loopexit ], [ %33, %.lr.ph58 ]
  ret double %.036.lcssa
}

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