; LLVM IR from flashlight/flashlight :: flashlight/fl/meter/AverageValueMeter.ll (ZN2fl17AverageValueMeter3addEdd)

; 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.fl::AverageValueMeter" = type { double, double, double, double }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2fl17AverageValueMeter3addEdd(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, double noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store double %1, ptr %5, align 8, !tbaa !9
  store double %2, ptr %6, align 8, !tbaa !9
  %7 = load ptr, ptr %4, align 8
  %8 = load double, ptr %6, align 8, !tbaa !9
  %9 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 2
  %10 = load double, ptr %9, align 8, !tbaa !11
  %11 = fadd double %10, %8
  store double %11, ptr %9, align 8, !tbaa !11
  %12 = load double, ptr %6, align 8, !tbaa !9
  %13 = load double, ptr %6, align 8, !tbaa !9
  %14 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 3
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = call double @llvm.fmuladd.f64(double %12, double %13, double %15)
  store double %16, ptr %14, align 8, !tbaa !13
  %17 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 2
  %18 = load double, ptr %17, align 8, !tbaa !11
  %19 = fcmp oeq double %18, 0.000000e+00
  br i1 %19, label %20, label %21

20:                                               ; preds = %3
  br label %50

21:                                               ; preds = %3
  %22 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 0
  %23 = load double, ptr %22, align 8, !tbaa !14
  %24 = load double, ptr %6, align 8, !tbaa !9
  %25 = load double, ptr %5, align 8, !tbaa !9
  %26 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 0
  %27 = load double, ptr %26, align 8, !tbaa !14
  %28 = fsub double %25, %27
  %29 = fmul double %24, %28
  %30 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 2
  %31 = load double, ptr %30, align 8, !tbaa !11
  %32 = fdiv double %29, %31
  %33 = fadd double %23, %32
  %34 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 0
  store double %33, ptr %34, align 8, !tbaa !14
  %35 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 1
  %36 = load double, ptr %35, align 8, !tbaa !15
  %37 = load double, ptr %6, align 8, !tbaa !9
  %38 = load double, ptr %5, align 8, !tbaa !9
  %39 = load double, ptr %5, align 8, !tbaa !9
  %40 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 1
  %41 = load double, ptr %40, align 8, !tbaa !15
  %42 = fneg double %41
  %43 = call double @llvm.fmuladd.f64(double %38, double %39, double %42)
  %44 = fmul double %37, %43
  %45 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 2
  %46 = load double, ptr %45, align 8, !tbaa !11
  %47 = fdiv double %44, %46
  %48 = fadd double %36, %47
  %49 = getelementptr inbounds %"class.fl::AverageValueMeter", ptr %7, i32 0, i32 1
  store double %48, ptr %49, align 8, !tbaa !15
  br label %50

50:                                               ; preds = %21, %20
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 speculatable willreturn memory(none) }

!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 16}
!12 = !{!"_ZTSN2fl17AverageValueMeterE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !10, i64 0}
!15 = !{!12, !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN2fl17AverageValueMeter3addEdd(ptr nocapture noundef nonnull align 8 dereferenceable(32) %0, double noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = fadd double %5, %2
  store double %6, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load double, ptr %7, align 8, !tbaa !10
  %9 = tail call double @llvm.fmuladd.f64(double %2, double %2, double %8)
  store double %9, ptr %7, align 8, !tbaa !10
  %10 = fcmp oeq double %6, 0.000000e+00
  br i1 %10, label %27, label %11

11:                                               ; preds = %3
  %12 = load <2 x double>, ptr %0, align 8, !tbaa !11
  %13 = extractelement <2 x double> %12, i64 0
  %14 = fsub double %1, %13
  %15 = extractelement <2 x double> %12, i64 1
  %16 = fneg double %15
  %17 = tail call double @llvm.fmuladd.f64(double %1, double %1, double %16)
  %18 = insertelement <2 x double> poison, double %14, i64 0
  %19 = insertelement <2 x double> %18, double %17, i64 1
  %20 = insertelement <2 x double> poison, double %2, i64 0
  %21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
  %22 = fmul <2 x double> %19, %21
  %23 = insertelement <2 x double> poison, double %6, i64 0
  %24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
  %25 = fdiv <2 x double> %22, %24
  %26 = fadd <2 x double> %12, %25
  store <2 x double> %26, ptr %0, align 8, !tbaa !11
  br label %27

27:                                               ; preds = %3, %11
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 16}
!6 = !{!"_ZTSN2fl17AverageValueMeterE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 24}
!11 = !{!7, !7, i64 0}


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