; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_fader.ll (ZN6SoLoud5Fader3getEd)

; 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.SoLoud::Fader" = type { float, float, float, double, double, double, float, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN6SoLoud5Fader3getEd(ptr noundef nonnull align 8 dereferenceable(48) %0, double noundef %1) #0 align 2 {
  %3 = alloca float, align 4
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 7
  %10 = load i32, ptr %9, align 4, !tbaa !11
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %12, label %41

12:                                               ; preds = %2
  %13 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 4
  %14 = load double, ptr %13, align 8, !tbaa !15
  %15 = load double, ptr %5, align 8, !tbaa !9
  %16 = fcmp ogt double %14, %15
  br i1 %16, label %17, label %20

17:                                               ; preds = %12
  %18 = load double, ptr %5, align 8, !tbaa !9
  %19 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 4
  store double %18, ptr %19, align 8, !tbaa !15
  br label %20

20:                                               ; preds = %17, %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %21 = load double, ptr %5, align 8, !tbaa !9
  %22 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 4
  %23 = load double, ptr %22, align 8, !tbaa !15
  %24 = fsub double %21, %23
  store double %24, ptr %6, align 8, !tbaa !9
  %25 = load double, ptr %6, align 8, !tbaa !9
  %26 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 5
  %27 = load double, ptr %26, align 8, !tbaa !16
  %28 = fmul double %25, %27
  %29 = call double @sin(double noundef %28) #4
  %30 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 2
  %31 = load float, ptr %30, align 8, !tbaa !17
  %32 = fpext float %31 to double
  %33 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 0
  %34 = load float, ptr %33, align 8, !tbaa !18
  %35 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 2
  %36 = load float, ptr %35, align 8, !tbaa !17
  %37 = fadd float %34, %36
  %38 = fpext float %37 to double
  %39 = call double @llvm.fmuladd.f64(double %29, double %32, double %38)
  %40 = fptrunc double %39 to float
  store float %40, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %107

41:                                               ; preds = %2
  %42 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 4
  %43 = load double, ptr %42, align 8, !tbaa !15
  %44 = load double, ptr %5, align 8, !tbaa !9
  %45 = fcmp ogt double %43, %44
  br i1 %45, label %46, label %79

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %47 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 6
  %48 = load float, ptr %47, align 8, !tbaa !19
  %49 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 0
  %50 = load float, ptr %49, align 8, !tbaa !18
  %51 = fsub float %48, %50
  %52 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 2
  %53 = load float, ptr %52, align 8, !tbaa !17
  %54 = fdiv float %51, %53
  store float %54, ptr %7, align 4, !tbaa !20
  %55 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 6
  %56 = load float, ptr %55, align 8, !tbaa !19
  %57 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 0
  store float %56, ptr %57, align 8, !tbaa !18
  %58 = load double, ptr %5, align 8, !tbaa !9
  %59 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 4
  store double %58, ptr %59, align 8, !tbaa !15
  %60 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 3
  %61 = load double, ptr %60, align 8, !tbaa !21
  %62 = load float, ptr %7, align 4, !tbaa !20
  %63 = fsub float 1.000000e+00, %62
  %64 = fpext float %63 to double
  %65 = fmul double %61, %64
  %66 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 3
  store double %65, ptr %66, align 8, !tbaa !21
  %67 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 1
  %68 = load float, ptr %67, align 4, !tbaa !22
  %69 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 0
  %70 = load float, ptr %69, align 8, !tbaa !18
  %71 = fsub float %68, %70
  %72 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 2
  store float %71, ptr %72, align 8, !tbaa !17
  %73 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 4
  %74 = load double, ptr %73, align 8, !tbaa !15
  %75 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 3
  %76 = load double, ptr %75, align 8, !tbaa !21
  %77 = fadd double %74, %76
  %78 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 5
  store double %77, ptr %78, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %79

79:                                               ; preds = %46, %41
  %80 = load double, ptr %5, align 8, !tbaa !9
  %81 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 5
  %82 = load double, ptr %81, align 8, !tbaa !16
  %83 = fcmp ogt double %80, %82
  br i1 %83, label %84, label %88

84:                                               ; preds = %79
  %85 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 7
  store i32 -1, ptr %85, align 4, !tbaa !11
  %86 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 1
  %87 = load float, ptr %86, align 4, !tbaa !22
  store float %87, ptr %3, align 4
  br label %107

88:                                               ; preds = %79
  %89 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 0
  %90 = load float, ptr %89, align 8, !tbaa !18
  %91 = fpext float %90 to double
  %92 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 2
  %93 = load float, ptr %92, align 8, !tbaa !17
  %94 = fpext float %93 to double
  %95 = load double, ptr %5, align 8, !tbaa !9
  %96 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 4
  %97 = load double, ptr %96, align 8, !tbaa !15
  %98 = fsub double %95, %97
  %99 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 3
  %100 = load double, ptr %99, align 8, !tbaa !21
  %101 = fdiv double %98, %100
  %102 = call double @llvm.fmuladd.f64(double %94, double %101, double %91)
  %103 = fptrunc double %102 to float
  %104 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 6
  store float %103, ptr %104, align 8, !tbaa !19
  %105 = getelementptr inbounds %"class.SoLoud::Fader", ptr %8, i32 0, i32 6
  %106 = load float, ptr %105, align 8, !tbaa !19
  store float %106, ptr %3, align 4
  br label %107

107:                                              ; preds = %88, %84, %20
  %108 = load float, ptr %3, align 4
  ret float %108
}

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

; Function Attrs: nounwind
declare double @sin(double noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !14, i64 44}
!12 = !{!"_ZTSN6SoLoud5FaderE", !13, i64 0, !13, i64 4, !13, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !14, i64 44}
!13 = !{!"float", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !13, i64 8}
!18 = !{!12, !13, i64 0}
!19 = !{!12, !13, i64 40}
!20 = !{!13, !13, i64 0}
!21 = !{!12, !10, i64 16}
!22 = !{!12, !13, i64 4}


; 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 nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local noundef float @_ZN6SoLoud5Fader3getEd(ptr nocapture noundef nonnull align 8 dereferenceable(48) %0, double noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 44
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 2
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load double, ptr %6, align 8, !tbaa !12
  %8 = fcmp ogt double %7, %1
  br i1 %5, label %9, label %26

9:                                                ; preds = %2
  br i1 %8, label %10, label %11

10:                                               ; preds = %9
  store double %1, ptr %6, align 8, !tbaa !12
  br label %11

11:                                               ; preds = %10, %9
  %12 = phi double [ %1, %10 ], [ %7, %9 ]
  %13 = fsub double %1, %12
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = fmul double %13, %15
  %17 = tail call double @sin(double noundef %16) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = load float, ptr %18, align 8, !tbaa !14
  %20 = fpext float %19 to double
  %21 = load float, ptr %0, align 8, !tbaa !15
  %22 = fadd float %19, %21
  %23 = fpext float %22 to double
  %24 = tail call double @llvm.fmuladd.f64(double %17, double %20, double %23)
  %25 = fptrunc double %24 to float
  br label %65

26:                                               ; preds = %2
  br i1 %8, label %27, label %._crit_edge

._crit_edge:                                      ; preds = %26
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 32
  %.pre = load double, ptr %.phi.trans.insert, align 8, !tbaa !13
  br label %45

27:                                               ; preds = %26
  %28 = getelementptr inbounds i8, ptr %0, i64 40
  %29 = load float, ptr %28, align 8, !tbaa !16
  %30 = load float, ptr %0, align 8, !tbaa !15
  %31 = fsub float %29, %30
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load float, ptr %32, align 8, !tbaa !14
  %34 = fdiv float %31, %33
  store float %29, ptr %0, align 8, !tbaa !15
  store double %1, ptr %6, align 8, !tbaa !12
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = load double, ptr %35, align 8, !tbaa !17
  %37 = fsub float 1.000000e+00, %34
  %38 = fpext float %37 to double
  %39 = fmul double %36, %38
  store double %39, ptr %35, align 8, !tbaa !17
  %40 = getelementptr inbounds i8, ptr %0, i64 4
  %41 = load float, ptr %40, align 4, !tbaa !18
  %42 = fsub float %41, %29
  store float %42, ptr %32, align 8, !tbaa !14
  %43 = fadd double %39, %1
  %44 = getelementptr inbounds i8, ptr %0, i64 32
  store double %43, ptr %44, align 8, !tbaa !13
  br label %45

45:                                               ; preds = %._crit_edge, %27
  %46 = phi double [ %7, %._crit_edge ], [ %1, %27 ]
  %47 = phi double [ %.pre, %._crit_edge ], [ %43, %27 ]
  %48 = fcmp olt double %47, %1
  br i1 %48, label %49, label %52

49:                                               ; preds = %45
  store i32 -1, ptr %3, align 4, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %0, i64 4
  %51 = load float, ptr %50, align 4, !tbaa !18
  br label %65

52:                                               ; preds = %45
  %53 = load float, ptr %0, align 8, !tbaa !15
  %54 = fpext float %53 to double
  %55 = getelementptr inbounds i8, ptr %0, i64 8
  %56 = load float, ptr %55, align 8, !tbaa !14
  %57 = fpext float %56 to double
  %58 = fsub double %1, %46
  %59 = getelementptr inbounds i8, ptr %0, i64 16
  %60 = load double, ptr %59, align 8, !tbaa !17
  %61 = fdiv double %58, %60
  %62 = tail call double @llvm.fmuladd.f64(double %57, double %61, double %54)
  %63 = fptrunc double %62 to float
  %64 = getelementptr inbounds i8, ptr %0, i64 40
  store float %63, ptr %64, align 8, !tbaa !16
  br label %65

65:                                               ; preds = %52, %49, %11
  %.0 = phi float [ %25, %11 ], [ %51, %49 ], [ %63, %52 ]
  ret float %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11, i64 44}
!6 = !{!"_ZTSN6SoLoud5FaderE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !11, i64 44}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !10, i64 32}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !7, i64 40}
!17 = !{!6, !10, i64 16}
!18 = !{!6, !7, i64 4}


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