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

42:                                               ; preds = %3
  br label %43

43:                                               ; preds = %47, %42
  %44 = load ptr, ptr %5, align 8, !tbaa !9
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = icmp ult ptr %44, %45
  br i1 %46, label %47, label %62

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #5
  %48 = load ptr, ptr %5, align 8, !tbaa !9
  %49 = load <2 x double>, ptr %48, align 16, !tbaa !11
  store <2 x double> %49, ptr %12, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  %50 = load ptr, ptr %6, align 8, !tbaa !9
  %51 = load <2 x double>, ptr %50, align 16, !tbaa !11
  store <2 x double> %51, ptr %13, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #5
  %52 = load <2 x double>, ptr %12, align 16, !tbaa !11
  %53 = load <2 x double>, ptr %13, align 16, !tbaa !11
  %54 = call <2 x double> @_mm_mul_pd(<2 x double> noundef %52, <2 x double> noundef %53)
  store <2 x double> %54, ptr %14, align 16, !tbaa !11
  %55 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %56 = load <2 x double>, ptr %14, align 16, !tbaa !11
  %57 = call <2 x double> @_mm_add_pd(<2 x double> noundef %55, <2 x double> noundef %56)
  store <2 x double> %57, ptr %10, align 16, !tbaa !11
  %58 = load ptr, ptr %5, align 8, !tbaa !9
  %59 = getelementptr inbounds double, ptr %58, i64 2
  store ptr %59, ptr %5, align 8, !tbaa !9
  %60 = load ptr, ptr %6, align 8, !tbaa !9
  %61 = getelementptr inbounds double, ptr %60, i64 2
  store ptr %61, ptr %6, align 8, !tbaa !9
  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 %43, !llvm.loop !14

62:                                               ; preds = %43
  br label %84

63:                                               ; preds = %3
  br label %64

64:                                               ; preds = %68, %63
  %65 = load ptr, ptr %5, align 8, !tbaa !9
  %66 = load ptr, ptr %8, align 8, !tbaa !9
  %67 = icmp ult ptr %65, %66
  br i1 %67, label %68, label %83

68:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #5
  %69 = load ptr, ptr %5, align 8, !tbaa !9
  %70 = call <2 x double> @_mm_loadu_pd(ptr noundef %69)
  store <2 x double> %70, ptr %15, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #5
  %71 = load ptr, ptr %6, align 8, !tbaa !9
  %72 = call <2 x double> @_mm_loadu_pd(ptr noundef %71)
  store <2 x double> %72, ptr %16, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #5
  %73 = load <2 x double>, ptr %15, align 16, !tbaa !11
  %74 = load <2 x double>, ptr %16, align 16, !tbaa !11
  %75 = call <2 x double> @_mm_mul_pd(<2 x double> noundef %73, <2 x double> noundef %74)
  store <2 x double> %75, ptr %17, align 16, !tbaa !11
  %76 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %77 = load <2 x double>, ptr %17, align 16, !tbaa !11
  %78 = call <2 x double> @_mm_add_pd(<2 x double> noundef %76, <2 x double> noundef %77)
  store <2 x double> %78, ptr %10, align 16, !tbaa !11
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  %80 = getelementptr inbounds double, ptr %79, i64 2
  store ptr %80, ptr %5, align 8, !tbaa !9
  %81 = load ptr, ptr %6, align 8, !tbaa !9
  %82 = getelementptr inbounds double, ptr %81, i64 2
  store ptr %82, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #5
  br label %64, !llvm.loop !16

83:                                               ; preds = %64
  br label %84

84:                                               ; preds = %83, %62
  %85 = load <2 x double>, ptr %10, align 16, !tbaa !11
  %86 = call double @_vl_vhsum_sse2_d(<2 x double> noundef %85)
  store double %86, ptr %9, align 8, !tbaa !17
  br label %87

87:                                               ; preds = %91, %84
  %88 = load ptr, ptr %5, align 8, !tbaa !9
  %89 = load ptr, ptr %7, align 8, !tbaa !9
  %90 = icmp ult ptr %88, %89
  br i1 %90, label %91, label %102

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

102:                                              ; preds = %87
  %103 = 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 %103
}

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_setzero_pd() #2

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

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

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

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

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

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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: nounwind uwtable
define dso_local double @_vl_dot_sse2_d(i64 noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %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 %.preheader43

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

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

.lr.ph53:                                         ; preds = %.preheader, %.lr.ph53
  %.052 = phi ptr [ %17, %.lr.ph53 ], [ %1, %.preheader ]
  %.03451 = phi ptr [ %18, %.lr.ph53 ], [ %2, %.preheader ]
  %.03950 = phi <2 x double> [ %16, %.lr.ph53 ], [ %6, %.preheader ]
  %13 = load <2 x double>, ptr %.052, align 16, !tbaa !5
  %14 = load <2 x double>, ptr %.03451, 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 %.03950, <2 x double> noundef %15)
  %17 = getelementptr inbounds i8, ptr %.052, i64 16
  %18 = getelementptr inbounds i8, ptr %.03451, i64 16
  %19 = icmp ult ptr %17, %5
  br i1 %19, label %.lr.ph53, label %.loopexit, !llvm.loop !8

.lr.ph:                                           ; preds = %.preheader43, %.lr.ph
  %.147 = phi ptr [ %24, %.lr.ph ], [ %1, %.preheader43 ]
  %.13546 = phi ptr [ %25, %.lr.ph ], [ %2, %.preheader43 ]
  %.14045 = phi <2 x double> [ %23, %.lr.ph ], [ %6, %.preheader43 ]
  %20 = tail call <2 x double> @_mm_loadu_pd(ptr noundef %.147)
  %21 = tail call <2 x double> @_mm_loadu_pd(ptr noundef %.13546)
  %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 %.14045, <2 x double> noundef %22)
  %24 = getelementptr inbounds i8, ptr %.147, i64 16
  %25 = getelementptr inbounds i8, ptr %.13546, i64 16
  %26 = icmp ult ptr %24, %5
  br i1 %26, label %.lr.ph, label %.loopexit, !llvm.loop !10

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

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

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <2 x double> @_mm_setzero_pd() local_unnamed_addr #1

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

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

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

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

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

attributes #0 = { 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 = { 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 = { 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, !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