; LLVM IR from sp-nitech/SPTK :: third_party/SWIPE/vector.ll (ZN4sptk5swipe6splinvENS0_6vectorES1_S1_di)

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

%"struct.sptk::swipe::vector" = type { i32, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN4sptk5swipe6splinvENS0_6vectorES1_S1_di(i32 %0, ptr %1, i32 %2, ptr %3, i32 %4, ptr %5, double noundef %6, i32 noundef %7) #2 {
  %9 = alloca %"struct.sptk::swipe::vector", align 8
  %10 = alloca %"struct.sptk::swipe::vector", align 8
  %11 = alloca %"struct.sptk::swipe::vector", align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = getelementptr inbounds { i32, ptr }, ptr %9, i32 0, i32 0
  store i32 %0, ptr %18, align 8
  %19 = getelementptr inbounds { i32, ptr }, ptr %9, i32 0, i32 1
  store ptr %1, ptr %19, align 8
  %20 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 0
  store i32 %2, ptr %20, align 8
  %21 = getelementptr inbounds { i32, ptr }, ptr %10, i32 0, i32 1
  store ptr %3, ptr %21, align 8
  %22 = getelementptr inbounds { i32, ptr }, ptr %11, i32 0, i32 0
  store i32 %4, ptr %22, align 8
  %23 = getelementptr inbounds { i32, ptr }, ptr %11, i32 0, i32 1
  store ptr %5, ptr %23, align 8
  store double %6, ptr %12, align 8, !tbaa !5
  store i32 %7, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %24 = load i32, ptr %13, align 4, !tbaa !9
  %25 = sub nsw i32 %24, 1
  store i32 %25, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %26 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %9, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %9, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = load i32, ptr %14, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %33, i64 %35
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = fsub double %31, %37
  store double %38, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %39 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %9, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = load i32, ptr %13, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds double, ptr %40, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = load double, ptr %12, align 8, !tbaa !5
  %46 = fsub double %44, %45
  %47 = load double, ptr %15, align 8, !tbaa !5
  %48 = fdiv double %46, %47
  store double %48, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %49 = load double, ptr %12, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %9, i32 0, i32 1
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = load i32, ptr %14, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds double, ptr %51, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !5
  %56 = fsub double %49, %55
  %57 = load double, ptr %15, align 8, !tbaa !5
  %58 = fdiv double %56, %57
  store double %58, ptr %17, align 8, !tbaa !5
  %59 = load double, ptr %16, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %10, i32 0, i32 1
  %61 = load ptr, ptr %60, align 8, !tbaa !11
  %62 = load i32, ptr %14, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %61, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !5
  %66 = load double, ptr %17, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %10, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !11
  %69 = load i32, ptr %13, align 4, !tbaa !9
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %68, i64 %70
  %72 = load double, ptr %71, align 8, !tbaa !5
  %73 = fmul double %66, %72
  %74 = call double @llvm.fmuladd.f64(double %59, double %65, double %73)
  %75 = load double, ptr %16, align 8, !tbaa !5
  %76 = load double, ptr %16, align 8, !tbaa !5
  %77 = fmul double %75, %76
  %78 = load double, ptr %16, align 8, !tbaa !5
  %79 = load double, ptr %16, align 8, !tbaa !5
  %80 = fneg double %79
  %81 = call double @llvm.fmuladd.f64(double %77, double %78, double %80)
  %82 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %11, i32 0, i32 1
  %83 = load ptr, ptr %82, align 8, !tbaa !11
  %84 = load i32, ptr %14, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds double, ptr %83, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !5
  %88 = fmul double %81, %87
  %89 = load double, ptr %17, align 8, !tbaa !5
  %90 = load double, ptr %17, align 8, !tbaa !5
  %91 = fmul double %89, %90
  %92 = load double, ptr %17, align 8, !tbaa !5
  %93 = load double, ptr %17, align 8, !tbaa !5
  %94 = fneg double %93
  %95 = call double @llvm.fmuladd.f64(double %91, double %92, double %94)
  %96 = fmul double %88, %95
  %97 = getelementptr inbounds %"struct.sptk::swipe::vector", ptr %11, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8, !tbaa !11
  %99 = load i32, ptr %13, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds double, ptr %98, i64 %100
  %102 = load double, ptr %101, align 8, !tbaa !5
  %103 = fmul double %96, %102
  %104 = load double, ptr %15, align 8, !tbaa !5
  %105 = load double, ptr %15, align 8, !tbaa !5
  %106 = fmul double %104, %105
  %107 = fmul double %103, %106
  %108 = fdiv double %107, 6.000000e+00
  %109 = fadd double %74, %108
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  ret double %109
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTSN4sptk5swipe6vectorE", !10, i64 0, !13, i64 8}
!13 = !{!"any pointer", !7, i64 0}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef double @_ZN4sptk5swipe6splinvENS0_6vectorES1_S1_di(i32 %0, ptr nocapture readonly %1, i32 %2, ptr nocapture readonly %3, i32 %4, ptr nocapture readonly %5, double noundef %6, i32 noundef %7) local_unnamed_addr #1 {
  %9 = add nsw i32 %7, -1
  %10 = sext i32 %7 to i64
  %11 = getelementptr inbounds double, ptr %1, i64 %10
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = sext i32 %9 to i64
  %14 = getelementptr inbounds double, ptr %1, i64 %13
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = fsub double %12, %15
  %17 = fsub double %12, %6
  %18 = fdiv double %17, %16
  %19 = fsub double %6, %15
  %20 = fdiv double %19, %16
  %21 = getelementptr inbounds double, ptr %3, i64 %13
  %22 = load double, ptr %21, align 8, !tbaa !5
  %23 = getelementptr inbounds double, ptr %3, i64 %10
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fmul double %20, %24
  %26 = tail call double @llvm.fmuladd.f64(double %18, double %22, double %25)
  %27 = fmul double %18, %18
  %28 = fneg double %18
  %29 = tail call double @llvm.fmuladd.f64(double %27, double %18, double %28)
  %30 = getelementptr inbounds double, ptr %5, i64 %13
  %31 = load double, ptr %30, align 8, !tbaa !5
  %32 = fmul double %31, %29
  %33 = fmul double %20, %20
  %34 = fneg double %20
  %35 = tail call double @llvm.fmuladd.f64(double %33, double %20, double %34)
  %36 = fmul double %35, %32
  %37 = getelementptr inbounds double, ptr %5, i64 %10
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = fmul double %38, %36
  %40 = fmul double %16, %16
  %41 = fmul double %40, %39
  %42 = fdiv double %41, 6.000000e+00
  %43 = fadd double %26, %42
  ret double %43
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass