; LLVM IR from vectozavr/3dzavr :: engine/animation/Interpolation.ll (ZN13Interpolation6BezierERK5Vec2DS2_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"

%class.anon = type { %class.Vec2D, %class.Vec2D, double }
%class.Vec2D = type { %"struct.std::array.0" }
%"struct.std::array.0" = type { [2 x double] }
%class.anon.3 = type { %class.Vec2D, %class.Vec2D }
%class.anon.4 = type { %class.anon, double }

; 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: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN13Interpolation6LinearEd(double noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN13Interpolation6BezierERK5Vec2DS2_d(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, double noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca %class.anon, align 8
  %10 = alloca %class.anon.3, align 8
  %11 = alloca %class.anon.4, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store double %2, ptr %6, align 8, !tbaa !9
  %15 = load double, ptr %6, align 8, !tbaa !9
  %16 = call noundef double @_ZN13Interpolation6LinearEd(double noundef %15)
  store double %16, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store double 0x3DA5FD7FE1796495, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store double 0x3DA5FD7FE1796495, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 40, ptr %9) #5
  %17 = getelementptr inbounds %class.anon, ptr %9, i32 0, i32 0
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(16) %18)
  %19 = getelementptr inbounds %class.anon, ptr %9, i32 0, i32 1
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 8 dereferenceable(16) %20)
  %21 = getelementptr inbounds %class.anon, ptr %9, i32 0, i32 2
  %22 = load double, ptr %6, align 8, !tbaa !9
  store double %22, ptr %21, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #5
  %23 = getelementptr inbounds %class.anon.3, ptr %10, i32 0, i32 0
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 8 dereferenceable(16) %24)
  %25 = getelementptr inbounds %class.anon.3, ptr %10, i32 0, i32 1
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(16) %26)
  call void @llvm.lifetime.start.p0(i64 48, ptr %11) #5
  %27 = getelementptr inbounds %class.anon.4, ptr %11, i32 0, i32 0
  call void @"_ZZN13Interpolation6BezierERK5Vec2DS2_dEN3$_0C2ERKS3_"(ptr noundef nonnull align 8 dereferenceable(40) %27, ptr noundef nonnull align 8 dereferenceable(40) %9)
  %28 = getelementptr inbounds %class.anon.4, ptr %11, i32 0, i32 1
  %29 = load double, ptr %7, align 8, !tbaa !9
  store double %29, ptr %28, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store double 5.000000e-01, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !17
  br label %30

30:                                               ; preds = %37, %3
  %31 = load double, ptr %12, align 8, !tbaa !9
  %32 = load double, ptr %13, align 8, !tbaa !9
  %33 = fsub double %31, %32
  %34 = call noundef double @_ZSt3absd(double noundef %33)
  %35 = load double, ptr %8, align 8, !tbaa !9
  %36 = fcmp ogt double %34, %35
  br i1 %36, label %37, label %48

37:                                               ; preds = %30
  %38 = load double, ptr %13, align 8, !tbaa !9
  store double %38, ptr %12, align 8, !tbaa !9
  %39 = load double, ptr %12, align 8, !tbaa !9
  %40 = load double, ptr %12, align 8, !tbaa !9
  %41 = call noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_0clEd"(ptr noundef nonnull align 8 dereferenceable(40) %9, double noundef %40)
  %42 = load double, ptr %12, align 8, !tbaa !9
  %43 = call noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_2clEd"(ptr noundef nonnull align 8 dereferenceable(48) %11, double noundef %42)
  %44 = fdiv double %41, %43
  %45 = fsub double %39, %44
  store double %45, ptr %13, align 8, !tbaa !9
  %46 = load i32, ptr %14, align 4, !tbaa !17
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %14, align 4, !tbaa !17
  br label %30, !llvm.loop !19

48:                                               ; preds = %30
  %49 = load double, ptr %12, align 8, !tbaa !9
  %50 = call noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(32) %10, double noundef %49)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 40, 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 %50
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN13Interpolation6BezierERK5Vec2DS2_dEN3$_0C2ERKS3_"(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) #4

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_0clEd"(ptr noundef nonnull align 8 dereferenceable(40), double noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_2clEd"(ptr noundef nonnull align 8 dereferenceable(48), double noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(32), double noundef) #3 align 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 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { inlinehint 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"_ZTSZN13Interpolation6BezierERK5Vec2DS2_dE3$_0", !13, i64 0, !13, i64 16, !10, i64 32}
!13 = !{!"_ZTS5Vec2D", !14, i64 0}
!14 = !{!"_ZTSSt5arrayIdLm2EE", !7, i64 0}
!15 = !{!16, !10, i64 40}
!16 = !{!"_ZTSZN13Interpolation6BezierERK5Vec2DS2_dE3$_2", !12, i64 0, !10, i64 40}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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.anon = type { %class.Vec2D, %class.Vec2D, double }
%class.Vec2D = type { %"struct.std::array.0" }
%"struct.std::array.0" = type { [2 x double] }
%class.anon.3 = type { %class.Vec2D, %class.Vec2D }
%class.anon.4 = type { %class.anon, double }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN13Interpolation6LinearEd(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN13Interpolation6BezierERK5Vec2DS2_d(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, double noundef %2) local_unnamed_addr #2 {
  %4 = alloca %class.anon, align 8
  %5 = alloca %class.anon.3, align 8
  %6 = alloca %class.anon.4, align 8
  %7 = tail call noundef double @_ZN13Interpolation6LinearEd(double noundef %2)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #5
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %8 = getelementptr inbounds i8, ptr %4, i64 16
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %1)
  %9 = getelementptr inbounds i8, ptr %4, i64 32
  store double %7, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #5
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %10 = getelementptr inbounds i8, ptr %5, i64 16
  call void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #5
  call void @"_ZZN13Interpolation6BezierERK5Vec2DS2_dEN3$_0C2ERKS3_"(ptr noundef nonnull align 8 dereferenceable(40) %6, ptr noundef nonnull align 8 dereferenceable(40) %4)
  %11 = getelementptr inbounds i8, ptr %6, i64 40
  store double 0x3DA5FD7FE1796495, ptr %11, align 8, !tbaa !12
  %12 = call noundef double @_ZSt3absd(double noundef -5.000000e-01)
  %13 = fcmp ogt double %12, 0x3DA5FD7FE1796495
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.01517 = phi double [ %17, %.lr.ph ], [ 5.000000e-01, %3 ]
  %14 = call noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_0clEd"(ptr noundef nonnull align 8 dereferenceable(40) %4, double noundef %.01517)
  %15 = call noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_2clEd"(ptr noundef nonnull align 8 dereferenceable(48) %6, double noundef %.01517)
  %16 = fdiv double %14, %15
  %17 = fsub double %.01517, %16
  %18 = fsub double %.01517, %17
  %19 = call noundef double @_ZSt3absd(double noundef %18)
  %20 = fcmp ogt double %19, 0x3DA5FD7FE1796495
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.016.lcssa = phi double [ 0.000000e+00, %3 ], [ %.01517, %.lr.ph ]
  %21 = call noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(32) %5, double noundef %.016.lcssa)
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #5
  ret double %21
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5Vec2DC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @"_ZZN13Interpolation6BezierERK5Vec2DS2_dEN3$_0C2ERKS3_"(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_0clEd"(ptr noundef nonnull align 8 dereferenceable(40), double noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_2clEd"(ptr noundef nonnull align 8 dereferenceable(48), double noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden noundef double @"_ZZN13Interpolation6BezierERK5Vec2DS2_dENK3$_1clEd"(ptr noundef nonnull align 8 dereferenceable(32), double noundef) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress 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 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { inlinehint 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 #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, !11, i64 32}
!6 = !{!"_ZTSZN13Interpolation6BezierERK5Vec2DS2_dE3$_0", !7, i64 0, !7, i64 16, !11, i64 32}
!7 = !{!"_ZTS5Vec2D", !8, i64 0}
!8 = !{!"_ZTSSt5arrayIdLm2EE", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!13, !11, i64 40}
!13 = !{!"_ZTSZN13Interpolation6BezierERK5Vec2DS2_dE3$_2", !6, i64 0, !11, i64 40}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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