; LLVM IR from aap/librw :: src/base.ll (ZN2rw5slerpERKNS_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: 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) #1

; 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)) #2

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

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN2rw5slerpERKNS_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
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca %"struct.rw::Quat", align 4
  %14 = alloca %"struct.rw::Quat", align 4
  %15 = alloca i32, 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
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %16, i64 16, i1 false), !tbaa.struct !11
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call noundef float @_ZN2rw3dotERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16) %9, ptr noundef nonnull align 4 dereferenceable(16) %17)
  store float %18, ptr %8, align 4, !tbaa !9
  %19 = load float, ptr %8, align 4, !tbaa !9
  %20 = fcmp olt float %19, 0.000000e+00
  br i1 %20, label %21, label %29

21:                                               ; preds = %3
  %22 = load float, ptr %8, align 4, !tbaa !9
  %23 = fneg float %22
  store float %23, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  %24 = call { <2 x float>, <2 x float> } @_ZN2rw6negateERKNS_4QuatE(ptr noundef nonnull align 4 dereferenceable(16) %9)
  %25 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 0
  %26 = extractvalue { <2 x float>, <2 x float> } %24, 0
  store <2 x float> %26, ptr %25, align 4
  %27 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 1
  %28 = extractvalue { <2 x float>, <2 x float> } %24, 1
  store <2 x float> %28, ptr %27, 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 %29

29:                                               ; preds = %21, %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %30 = load float, ptr %8, align 4, !tbaa !9
  %31 = call float @acosf(float noundef %30) #6
  store float %31, ptr %11, align 4, !tbaa !9
  %32 = load float, ptr %11, align 4, !tbaa !9
  %33 = fcmp ogt float %32, 0x3EE4F8B580000000
  br i1 %33, label %34, label %66

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %35 = load float, ptr %11, align 4, !tbaa !9
  %36 = call float @sinf(float noundef %35) #6
  store float %36, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #6
  %37 = load float, ptr %7, align 4, !tbaa !9
  %38 = fsub float 1.000000e+00, %37
  %39 = load float, ptr %11, align 4, !tbaa !9
  %40 = fmul float %38, %39
  %41 = call float @sinf(float noundef %40) #6
  %42 = load float, ptr %12, align 4, !tbaa !9
  %43 = fdiv float %41, %42
  %44 = call { <2 x float>, <2 x float> } @_ZN2rw5scaleERKNS_4QuatEf(ptr noundef nonnull align 4 dereferenceable(16) %9, float noundef %43)
  %45 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 0
  %46 = extractvalue { <2 x float>, <2 x float> } %44, 0
  store <2 x float> %46, ptr %45, align 4
  %47 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %13, i32 0, i32 1
  %48 = extractvalue { <2 x float>, <2 x float> } %44, 1
  store <2 x float> %48, ptr %47, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load float, ptr %7, align 4, !tbaa !9
  %51 = load float, ptr %11, align 4, !tbaa !9
  %52 = fmul float %50, %51
  %53 = call float @sinf(float noundef %52) #6
  %54 = load float, ptr %12, align 4, !tbaa !9
  %55 = fdiv float %53, %54
  %56 = call { <2 x float>, <2 x float> } @_ZN2rw5scaleERKNS_4QuatEf(ptr noundef nonnull align 4 dereferenceable(16) %49, float noundef %55)
  %57 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 0
  %58 = extractvalue { <2 x float>, <2 x float> } %56, 0
  store <2 x float> %58, ptr %57, align 4
  %59 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %14, i32 0, i32 1
  %60 = extractvalue { <2 x float>, <2 x float> } %56, 1
  store <2 x float> %60, ptr %59, align 4
  %61 = call { <2 x float>, <2 x float> } @_ZN2rw3addERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(16) %14)
  %62 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 0
  %63 = extractvalue { <2 x float>, <2 x float> } %61, 0
  store <2 x float> %63, ptr %62, align 4
  %64 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %4, i32 0, i32 1
  %65 = extractvalue { <2 x float>, <2 x float> } %61, 1
  store <2 x float> %65, ptr %64, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #6
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %67

66:                                               ; preds = %29
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 %9, i64 16, i1 false), !tbaa.struct !11
  store i32 1, ptr %15, align 4
  br label %67

67:                                               ; preds = %66, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  %68 = load { <2 x float>, <2 x float> }, ptr %4, align 4
  ret { <2 x float>, <2 x float> } %68
}

; Function Attrs: nounwind
declare float @acosf(float noundef) #5

; Function Attrs: nounwind
declare float @sinf(float noundef) #5

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { 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 #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}


; 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: 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) #1

; 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 #2

; 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 #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_ZN2rw5slerpERKNS_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
  %5 = alloca %"struct.rw::Quat", align 8
  %6 = 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
  %7 = call noundef float @_ZN2rw3dotERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(16) %1)
  %8 = fcmp olt float %7, 0.000000e+00
  br i1 %8, label %9, label %14

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

14:                                               ; preds = %9, %3
  %.0 = phi float [ %10, %9 ], [ %7, %3 ]
  %15 = call float @acosf(float noundef %.0) #6
  %16 = fcmp ogt float %15, 0x3EE4F8B580000000
  br i1 %16, label %17, label %37

17:                                               ; preds = %14
  %18 = call float @sinf(float noundef %15) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  %19 = fsub float 1.000000e+00, %2
  %20 = fmul float %19, %15
  %21 = call float @sinf(float noundef %20) #6
  %22 = fdiv float %21, %18
  %23 = call { <2 x float>, <2 x float> } @_ZN2rw5scaleERKNS_4QuatEf(ptr noundef nonnull align 4 dereferenceable(16) %4, float noundef %22)
  %24 = extractvalue { <2 x float>, <2 x float> } %23, 0
  store <2 x float> %24, ptr %5, align 8
  %25 = getelementptr inbounds i8, ptr %5, i64 8
  %26 = extractvalue { <2 x float>, <2 x float> } %23, 1
  store <2 x float> %26, ptr %25, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  %27 = fmul float %15, %2
  %28 = call float @sinf(float noundef %27) #6
  %29 = fdiv float %28, %18
  %30 = call { <2 x float>, <2 x float> } @_ZN2rw5scaleERKNS_4QuatEf(ptr noundef nonnull align 4 dereferenceable(16) %1, float noundef %29)
  %31 = extractvalue { <2 x float>, <2 x float> } %30, 0
  store <2 x float> %31, ptr %6, align 8
  %32 = getelementptr inbounds i8, ptr %6, i64 8
  %33 = extractvalue { <2 x float>, <2 x float> } %30, 1
  store <2 x float> %33, ptr %32, align 8
  %34 = call { <2 x float>, <2 x float> } @_ZN2rw3addERKNS_4QuatES2_(ptr noundef nonnull align 4 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(16) %6)
  %35 = extractvalue { <2 x float>, <2 x float> } %34, 0
  %36 = extractvalue { <2 x float>, <2 x float> } %34, 1
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %38

37:                                               ; preds = %14
  %.sroa.014.0.copyload = load <2 x float>, ptr %4, align 8
  %.sroa.3.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  %.sroa.3.0.copyload = load <2 x float>, ptr %.sroa.3.0..sroa_idx, align 8
  br label %38

38:                                               ; preds = %37, %17
  %.sroa.014.0 = phi <2 x float> [ %35, %17 ], [ %.sroa.014.0.copyload, %37 ]
  %.sroa.3.0 = phi <2 x float> [ %36, %17 ], [ %.sroa.3.0.copyload, %37 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.sroa.014.0, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.sroa.3.0, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = { 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 #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"}


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