; LLVM IR from atlantis13579/Riemann :: Src/Geometry/Spline.ll (ZN7Riemann6Bezier15CalculateLengthERKN5Maths8TVector3IfEES5_S5_)

; 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.Maths::TVector3" = type { float, float, float }

; 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 float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN7Riemann6Bezier15CalculateLengthERKN5Maths8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.Maths::TVector3", align 4
  %8 = alloca %"class.Maths::TVector3", align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %7) #5
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #5
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %8)
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.Maths::TVector3", ptr %17, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"class.Maths::TVector3", ptr %20, i32 0, i32 0
  %22 = load float, ptr %21, align 4, !tbaa !9
  %23 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %22, float %19)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"class.Maths::TVector3", ptr %24, i32 0, i32 0
  %26 = load float, ptr %25, align 4, !tbaa !9
  %27 = fadd float %23, %26
  %28 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 0
  store float %27, ptr %28, align 4, !tbaa !9
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.Maths::TVector3", ptr %29, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !12
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"class.Maths::TVector3", ptr %32, i32 0, i32 1
  %34 = load float, ptr %33, align 4, !tbaa !12
  %35 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %34, float %31)
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.Maths::TVector3", ptr %36, i32 0, i32 1
  %38 = load float, ptr %37, align 4, !tbaa !12
  %39 = fadd float %35, %38
  %40 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 1
  store float %39, ptr %40, align 4, !tbaa !12
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %"class.Maths::TVector3", ptr %41, i32 0, i32 0
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.Maths::TVector3", ptr %44, i32 0, i32 0
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = fmul float 2.000000e+00, %46
  %48 = fneg float %47
  %49 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %43, float %48)
  %50 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 0
  store float %49, ptr %50, align 4, !tbaa !9
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %"class.Maths::TVector3", ptr %51, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !12
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"class.Maths::TVector3", ptr %54, i32 0, i32 1
  %56 = load float, ptr %55, align 4, !tbaa !12
  %57 = fmul float 2.000000e+00, %56
  %58 = fneg float %57
  %59 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %53, float %58)
  %60 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 1
  store float %59, ptr %60, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %61 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 0
  %62 = load float, ptr %61, align 4, !tbaa !9
  %63 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 0
  %64 = load float, ptr %63, align 4, !tbaa !9
  %65 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 1
  %66 = load float, ptr %65, align 4, !tbaa !12
  %67 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 1
  %68 = load float, ptr %67, align 4, !tbaa !12
  %69 = fmul float %66, %68
  %70 = call float @llvm.fmuladd.f32(float %62, float %64, float %69)
  %71 = fmul float 4.000000e+00, %70
  store float %71, ptr %9, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %72 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 0
  %73 = load float, ptr %72, align 4, !tbaa !9
  %74 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !9
  %76 = getelementptr inbounds %"class.Maths::TVector3", ptr %7, i32 0, i32 1
  %77 = load float, ptr %76, align 4, !tbaa !12
  %78 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 1
  %79 = load float, ptr %78, align 4, !tbaa !12
  %80 = fmul float %77, %79
  %81 = call float @llvm.fmuladd.f32(float %73, float %75, float %80)
  %82 = fmul float 4.000000e+00, %81
  store float %82, ptr %10, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %83 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 0
  %84 = load float, ptr %83, align 4, !tbaa !9
  %85 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 0
  %86 = load float, ptr %85, align 4, !tbaa !9
  %87 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 1
  %88 = load float, ptr %87, align 4, !tbaa !12
  %89 = getelementptr inbounds %"class.Maths::TVector3", ptr %8, i32 0, i32 1
  %90 = load float, ptr %89, align 4, !tbaa !12
  %91 = fmul float %88, %90
  %92 = call float @llvm.fmuladd.f32(float %84, float %86, float %91)
  store float %92, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %93 = load float, ptr %9, align 4, !tbaa !13
  %94 = load float, ptr %10, align 4, !tbaa !13
  %95 = fadd float %93, %94
  %96 = load float, ptr %11, align 4, !tbaa !13
  %97 = fadd float %95, %96
  %98 = call float @sqrtf(float noundef %97) #5
  %99 = fmul float 2.000000e+00, %98
  store float %99, ptr %12, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %100 = load float, ptr %9, align 4, !tbaa !13
  %101 = call float @sqrtf(float noundef %100) #5
  store float %101, ptr %13, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %102 = load float, ptr %9, align 4, !tbaa !13
  %103 = fmul float 2.000000e+00, %102
  %104 = load float, ptr %13, align 4, !tbaa !13
  %105 = fmul float %103, %104
  store float %105, ptr %14, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %106 = load float, ptr %11, align 4, !tbaa !13
  %107 = call float @sqrtf(float noundef %106) #5
  %108 = fmul float 2.000000e+00, %107
  store float %108, ptr %15, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %109 = load float, ptr %10, align 4, !tbaa !13
  %110 = load float, ptr %13, align 4, !tbaa !13
  %111 = fdiv float %109, %110
  store float %111, ptr %16, align 4, !tbaa !13
  %112 = load float, ptr %14, align 4, !tbaa !13
  %113 = load float, ptr %12, align 4, !tbaa !13
  %114 = load float, ptr %13, align 4, !tbaa !13
  %115 = load float, ptr %10, align 4, !tbaa !13
  %116 = fmul float %114, %115
  %117 = load float, ptr %12, align 4, !tbaa !13
  %118 = load float, ptr %15, align 4, !tbaa !13
  %119 = fsub float %117, %118
  %120 = fmul float %116, %119
  %121 = call float @llvm.fmuladd.f32(float %112, float %113, float %120)
  %122 = load float, ptr %11, align 4, !tbaa !13
  %123 = fmul float 4.000000e+00, %122
  %124 = load float, ptr %9, align 4, !tbaa !13
  %125 = load float, ptr %10, align 4, !tbaa !13
  %126 = load float, ptr %10, align 4, !tbaa !13
  %127 = fmul float %125, %126
  %128 = fneg float %127
  %129 = call float @llvm.fmuladd.f32(float %123, float %124, float %128)
  %130 = load float, ptr %13, align 4, !tbaa !13
  %131 = load float, ptr %16, align 4, !tbaa !13
  %132 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %130, float %131)
  %133 = load float, ptr %12, align 4, !tbaa !13
  %134 = fadd float %132, %133
  %135 = load float, ptr %16, align 4, !tbaa !13
  %136 = load float, ptr %15, align 4, !tbaa !13
  %137 = fadd float %135, %136
  %138 = fdiv float %134, %137
  %139 = call float @logf(float noundef %138) #5
  %140 = call float @llvm.fmuladd.f32(float %129, float %139, float %121)
  %141 = load float, ptr %14, align 4, !tbaa !13
  %142 = fmul float 4.000000e+00, %141
  %143 = fdiv float %140, %142
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %7) #5
  ret float %143
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #4

; Function Attrs: nounwind
declare float @logf(float noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 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 #4 = { nounwind "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, !11, i64 0}
!10 = !{!"_ZTSN5Maths8TVector3IfEE", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, 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"

%"class.Maths::TVector3" = type { float, float, float }

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN7Riemann6Bezier15CalculateLengthERKN5Maths8TVector3IfEES5_S5_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %"class.Maths::TVector3", align 4
  %5 = alloca %"class.Maths::TVector3", align 4
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #6
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %4)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #6
  call void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12) %5)
  %6 = load float, ptr %0, align 4, !tbaa !5
  %7 = load float, ptr %1, align 4, !tbaa !5
  %8 = call float @llvm.fmuladd.f32(float %7, float -2.000000e+00, float %6)
  %9 = load float, ptr %2, align 4, !tbaa !5
  %10 = fadd float %8, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = load float, ptr %11, align 4, !tbaa !10
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load float, ptr %13, align 4, !tbaa !10
  %15 = call float @llvm.fmuladd.f32(float %14, float -2.000000e+00, float %12)
  %16 = getelementptr inbounds i8, ptr %2, i64 4
  %17 = load float, ptr %16, align 4, !tbaa !10
  %18 = fadd float %15, %17
  %19 = fmul float %6, -2.000000e+00
  %20 = call float @llvm.fmuladd.f32(float %7, float 2.000000e+00, float %19)
  %21 = fmul float %12, -2.000000e+00
  %22 = call float @llvm.fmuladd.f32(float %14, float 2.000000e+00, float %21)
  %23 = insertelement <2 x float> poison, float %18, i64 0
  %24 = insertelement <2 x float> %23, float %22, i64 1
  %25 = shufflevector <2 x float> %23, <2 x float> poison, <2 x i32> zeroinitializer
  %26 = fmul <2 x float> %24, %25
  %27 = insertelement <2 x float> poison, float %10, i64 0
  %28 = shufflevector <2 x float> %27, <2 x float> poison, <2 x i32> zeroinitializer
  %29 = insertelement <2 x float> %28, float %20, i64 1
  %30 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %28, <2 x float> %29, <2 x float> %26)
  %31 = fmul <2 x float> %30, <float 4.000000e+00, float 4.000000e+00>
  %32 = fmul float %22, %22
  %33 = call float @llvm.fmuladd.f32(float %20, float %20, float %32)
  %34 = extractelement <2 x float> %31, i64 0
  %35 = extractelement <2 x float> %31, i64 1
  %36 = fadd float %34, %35
  %37 = fadd float %33, %36
  %38 = call float @sqrtf(float noundef %37) #6
  %39 = fmul float %38, 2.000000e+00
  %40 = call float @sqrtf(float noundef %34) #6
  %41 = fmul float %34, 2.000000e+00
  %42 = fmul float %41, %40
  %sqrt = call float @llvm.sqrt.f32(float %33)
  %43 = fmul float %sqrt, 2.000000e+00
  %44 = fdiv float %35, %40
  %45 = fmul float %35, %40
  %46 = fsub float %39, %43
  %47 = fmul float %45, %46
  %48 = call float @llvm.fmuladd.f32(float %42, float %39, float %47)
  %49 = fmul float %33, 4.000000e+00
  %50 = fneg float %35
  %51 = fmul float %35, %50
  %52 = call float @llvm.fmuladd.f32(float %49, float %34, float %51)
  %53 = call float @llvm.fmuladd.f32(float %40, float 2.000000e+00, float %44)
  %54 = fadd float %39, %53
  %55 = fadd float %43, %44
  %56 = fdiv float %54, %55
  %57 = call float @logf(float noundef %56) #6
  %58 = call float @llvm.fmuladd.f32(float %52, float %57, float %48)
  %59 = fmul float %42, 4.000000e+00
  %60 = fdiv float %58, %59
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #6
  ret float %60
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Maths8TVector3IfEC2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #3 align 2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @logf(float noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #5

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


; Effective O3 passes: AggressiveInstCombinePass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass