; LLVM IR from aap/librw :: src/base.ll (ZN2rw4lerpERKNS_4QuatES2_f)

; 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.rw::Quat" = type { float, 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: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_ZN2rw8makeQuatEffff(float noundef, float noundef, float noundef, float noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN2rw4lerpERKNS_4QuatES2_f(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, float noundef %2) #4 {
  %4 = alloca %"struct.rw::Quat", align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca %"struct.rw::Quat", align 4
  %10 = alloca %"struct.rw::Quat", align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %11, i64 16, i1 false), !tbaa.struct !11
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = call noundef float @_ZN2rw3dotERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16) %9, ptr noundef nonnull align 4 dereferenceable(16) %12)
  store float %13, ptr %8, align 4, !tbaa !9
  %14 = load float, ptr %8, align 4, !tbaa !9
  %15 = fcmp olt float %14, 0.000000e+00
  br i1 %15, label %16, label %24

16:                                               ; preds = %3
  %17 = load float, ptr %8, align 4, !tbaa !9
  %18 = fneg float %17
  store float %18, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  %19 = call { <2 x float>, <2 x float> } @_ZN2rw6negateERKNS_4QuatE(ptr noundef nonnull align 4 dereferenceable(16) %9)
  %20 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 0
  %21 = extractvalue { <2 x float>, <2 x float> } %19, 0
  store <2 x float> %21, ptr %20, align 4
  %22 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 1
  %23 = extractvalue { <2 x float>, <2 x float> } %19, 1
  store <2 x float> %23, ptr %22, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %10, i64 16, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  br label %24

24:                                               ; preds = %16, %3
  %25 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 3
  %26 = load float, ptr %25, align 4, !tbaa !12
  %27 = load float, ptr %7, align 4, !tbaa !9
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.rw::Quat", ptr %28, i32 0, i32 3
  %30 = load float, ptr %29, align 4, !tbaa !12
  %31 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 3
  %32 = load float, ptr %31, align 4, !tbaa !12
  %33 = fsub float %30, %32
  %34 = call float @llvm.fmuladd.f32(float %27, float %33, float %26)
  %35 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 0
  %36 = load float, ptr %35, align 4, !tbaa !14
  %37 = load float, ptr %7, align 4, !tbaa !9
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.rw::Quat", ptr %38, i32 0, i32 0
  %40 = load float, ptr %39, align 4, !tbaa !14
  %41 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 0
  %42 = load float, ptr %41, align 4, !tbaa !14
  %43 = fsub float %40, %42
  %44 = call float @llvm.fmuladd.f32(float %37, float %43, float %36)
  %45 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !15
  %47 = load float, ptr %7, align 4, !tbaa !9
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.rw::Quat", ptr %48, i32 0, i32 1
  %50 = load float, ptr %49, align 4, !tbaa !15
  %51 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 1
  %52 = load float, ptr %51, align 4, !tbaa !15
  %53 = fsub float %50, %52
  %54 = call float @llvm.fmuladd.f32(float %47, float %53, float %46)
  %55 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 2
  %56 = load float, ptr %55, align 4, !tbaa !16
  %57 = load float, ptr %7, align 4, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.rw::Quat", ptr %58, i32 0, i32 2
  %60 = load float, ptr %59, align 4, !tbaa !16
  %61 = getelementptr inbounds %"struct.rw::Quat", ptr %9, i32 0, i32 2
  %62 = load float, ptr %61, align 4, !tbaa !16
  %63 = fsub float %60, %62
  %64 = call float @llvm.fmuladd.f32(float %57, float %63, float %56)
  %65 = call { <2 x float>, <2 x float> } @_ZN2rw8makeQuatEffff(float noundef %34, float noundef %44, float noundef %54, float noundef %64)
  %66 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %67 = extractvalue { <2 x float>, <2 x float> } %65, 0
  store <2 x float> %67, ptr %66, align 4
  %68 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %69 = extractvalue { <2 x float>, <2 x float> } %65, 1
  store <2 x float> %69, ptr %68, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %70 = load { <2 x float>, <2 x float> }, ptr %4, align 4
  ret { <2 x float>, <2 x float> } %70
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN2rw3dotERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_ZN2rw6negateERKNS_4QuatE(ptr noundef nonnull align 4 dereferenceable(16)) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 #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, !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 = !{!"float", !7, i64 0}
!11 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9, i64 12, i64 4, !9}
!12 = !{!13, !10, i64 12}
!13 = !{!"_ZTSN2rw4QuatE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!14 = !{!13, !10, i64 0}
!15 = !{!13, !10, i64 4}
!16 = !{!13, !10, i64 8}


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

%"struct.rw::Quat" = type { float, 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: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_ZN2rw8makeQuatEffff(float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN2rw4lerpERKNS_4QuatES2_f(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, float noundef %2) local_unnamed_addr #4 {
  %4 = alloca %"struct.rw::Quat", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(16) %0, i64 16, i1 false), !tbaa.struct !5
  %5 = call noundef float @_ZN2rw3dotERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(16) %1)
  %6 = fcmp olt float %5, 0.000000e+00
  br i1 %6, label %7, label %._crit_edge

._crit_edge:                                      ; preds = %3
  %.phi.trans.insert = getelementptr inbounds i8, ptr %4, i64 12
  %.pre = load float, ptr %.phi.trans.insert, align 4, !tbaa !10
  %.pre13 = load float, ptr %4, align 8, !tbaa !12
  %.phi.trans.insert14 = getelementptr inbounds i8, ptr %4, i64 4
  %.pre15 = load float, ptr %.phi.trans.insert14, align 4, !tbaa !13
  %.phi.trans.insert16 = getelementptr inbounds i8, ptr %4, i64 8
  %.pre17 = load float, ptr %.phi.trans.insert16, align 8, !tbaa !14
  br label %15

7:                                                ; preds = %3
  %8 = call { <2 x float>, <2 x float> } @_ZN2rw6negateERKNS_4QuatE(ptr noundef nonnull align 4 dereferenceable(16) %4)
  %9 = extractvalue { <2 x float>, <2 x float> } %8, 0
  %10 = extractvalue { <2 x float>, <2 x float> } %8, 1
  store <2 x float> %9, ptr %4, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store <2 x float> %10, ptr %.sroa.4.0..sroa_idx, align 8
  %11 = extractelement <2 x float> %10, i64 1
  %12 = extractelement <2 x float> %9, i64 0
  %13 = extractelement <2 x float> %9, i64 1
  %14 = extractelement <2 x float> %10, i64 0
  br label %15

15:                                               ; preds = %._crit_edge, %7
  %16 = phi float [ %.pre17, %._crit_edge ], [ %14, %7 ]
  %17 = phi float [ %.pre15, %._crit_edge ], [ %13, %7 ]
  %18 = phi float [ %.pre13, %._crit_edge ], [ %12, %7 ]
  %19 = phi float [ %.pre, %._crit_edge ], [ %11, %7 ]
  %20 = getelementptr inbounds i8, ptr %1, i64 12
  %21 = load float, ptr %20, align 4, !tbaa !10
  %22 = fsub float %21, %19
  %23 = call float @llvm.fmuladd.f32(float %2, float %22, float %19)
  %24 = load float, ptr %1, align 4, !tbaa !12
  %25 = fsub float %24, %18
  %26 = call float @llvm.fmuladd.f32(float %2, float %25, float %18)
  %27 = getelementptr inbounds i8, ptr %1, i64 4
  %28 = load float, ptr %27, align 4, !tbaa !13
  %29 = fsub float %28, %17
  %30 = call float @llvm.fmuladd.f32(float %2, float %29, float %17)
  %31 = getelementptr inbounds i8, ptr %1, i64 8
  %32 = load float, ptr %31, align 4, !tbaa !14
  %33 = fsub float %32, %16
  %34 = call float @llvm.fmuladd.f32(float %2, float %33, float %16)
  %35 = call { <2 x float>, <2 x float> } @_ZN2rw8makeQuatEffff(float noundef %23, float noundef %26, float noundef %30, float noundef %34)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  ret { <2 x float>, <2 x float> } %35
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN2rw3dotERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local { <2 x float>, <2 x float> } @_ZN2rw6negateERKNS_4QuatE(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 #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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 12}
!11 = !{!"_ZTSN2rw4QuatE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!12 = !{!11, !7, i64 0}
!13 = !{!11, !7, i64 4}
!14 = !{!11, !7, i64 8}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass