; LLVM IR from cfd-rg-solver/FVM-RG-Solver :: src/energycalc.ll (ZN13OneTempApprox13avgVibrEnergyER10macroParamm)

; 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.macroParam = type { %struct.Mixture, %"class.std::vector.0", %"class.std::vector.0", double, double, double, double, double, double, double, double, %"class.std::__cxx11::basic_string" }
%struct.Mixture = type <{ %"class.std::vector", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<MixtureComponent, std::allocator<MixtureComponent>>::_Vector_impl" }
%"struct.std::_Vector_base<MixtureComponent, std::allocator<MixtureComponent>>::_Vector_impl" = type { %"struct.std::_Vector_base<MixtureComponent, std::allocator<MixtureComponent>>::_Vector_impl_data" }
%"struct.std::_Vector_base<MixtureComponent, std::allocator<MixtureComponent>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%struct.MixtureComponent = type { double, double, double, double, double, i32, i32, %"class.std::__cxx11::basic_string" }

; 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN13OneTempApprox13avgVibrEnergyER10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(176) %1, i64 noundef %2) #3 align 2 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.macroParam, ptr %12, i32 0, i32 0
  %14 = getelementptr inbounds %struct.Mixture, ptr %13, i32 0, i32 0
  %15 = load i64, ptr %7, align 8, !tbaa !9
  %16 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %15) #5
  %17 = getelementptr inbounds %struct.MixtureComponent, ptr %16, i32 0, i32 6
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = icmp eq i32 %18, 1
  br i1 %19, label %20, label %21

20:                                               ; preds = %3
  store double 0.000000e+00, ptr %4, align 8
  br label %64

21:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store double 0.000000e+00, ptr %8, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i64, ptr %7, align 8, !tbaa !9
  %24 = call noundef double @_ZN13OneTempApprox5ZvibrER10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(176) %22, i64 noundef %23)
  store double %24, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %59, %21
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.macroParam, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.Mixture, ptr %28, i32 0, i32 0
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %30) #5
  %32 = getelementptr inbounds %struct.MixtureComponent, ptr %31, i32 0, i32 5
  %33 = load i32, ptr %32, align 8, !tbaa !18
  %34 = sext i32 %33 to i64
  %35 = icmp ult i64 %26, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %62

37:                                               ; preds = %25
  %38 = load i64, ptr %10, align 8, !tbaa !9
  %39 = trunc i64 %38 to i32
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = call noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %11, i32 noundef %39, ptr noundef nonnull align 8 dereferenceable(176) %40, i64 noundef %41)
  %43 = load double, ptr %9, align 8, !tbaa !17
  %44 = fdiv double %42, %43
  %45 = load i64, ptr %10, align 8, !tbaa !9
  %46 = trunc i64 %45 to i32
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load i64, ptr %7, align 8, !tbaa !9
  %49 = call noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %11, i32 noundef %46, ptr noundef nonnull align 8 dereferenceable(176) %47, i64 noundef %48)
  %50 = fneg double %49
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.macroParam, ptr %51, i32 0, i32 8
  %53 = load double, ptr %52, align 8, !tbaa !19
  %54 = fmul double 0x3B30B0E674035E1A, %53
  %55 = fdiv double %50, %54
  %56 = call double @exp(double noundef %55) #5
  %57 = load double, ptr %8, align 8, !tbaa !17
  %58 = call double @llvm.fmuladd.f64(double %44, double %56, double %57)
  store double %58, ptr %8, align 8, !tbaa !17
  br label %59

59:                                               ; preds = %37
  %60 = load i64, ptr %10, align 8, !tbaa !9
  %61 = add i64 %60, 1
  store i64 %61, ptr %10, align 8, !tbaa !9
  br label %25, !llvm.loop !30

62:                                               ; preds = %36
  %63 = load double, ptr %8, align 8, !tbaa !17
  store double %63, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %64

64:                                               ; preds = %62, %20
  %65 = load double, ptr %4, align 8
  ret double %65
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN13OneTempApprox5ZvibrER10macroParamm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(176), i64 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, ptr noundef nonnull align 8 dereferenceable(176), i64 noundef) #2 align 2

; Function Attrs: nounwind
declare double @exp(double 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 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 = { 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 #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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 44}
!12 = !{!"_ZTS16MixtureComponent", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !14, i64 40, !14, i64 44, !15, i64 48}
!13 = !{!"double", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !10, i64 8, !7, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!12, !14, i64 40}
!19 = !{!20, !13, i64 120}
!20 = !{!"_ZTS10macroParam", !21, i64 0, !26, i64 32, !26, i64 56, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !15, i64 144}
!21 = !{!"_ZTS7Mixture", !22, i64 0, !14, i64 24}
!22 = !{!"_ZTSSt6vectorI16MixtureComponentSaIS0_EE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseI16MixtureComponentSaIS0_EE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseI16MixtureComponentSaIS0_EE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseI16MixtureComponentSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!"_ZTSSt6vectorIdSaIdEE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN13OneTempApprox13avgVibrEnergyER10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(176) %1, i64 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %2) #3
  %5 = getelementptr inbounds i8, ptr %4, i64 44
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %3
  %9 = tail call noundef double @_ZN13OneTempApprox5ZvibrER10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(176) %1, i64 noundef %2)
  %10 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %2) #3
  %11 = getelementptr inbounds i8, ptr %10, i64 40
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %13 = getelementptr inbounds i8, ptr %1, i64 120
  br label %14

14:                                               ; preds = %.lr.ph, %14
  %.022 = phi i64 [ 0, %.lr.ph ], [ %25, %14 ]
  %.02021 = phi double [ 0.000000e+00, %.lr.ph ], [ %24, %14 ]
  %15 = trunc i64 %.022 to i32
  %16 = tail call noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %15, ptr noundef nonnull align 8 dereferenceable(176) %1, i64 noundef %2)
  %17 = fdiv double %16, %9
  %18 = tail call noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %15, ptr noundef nonnull align 8 dereferenceable(176) %1, i64 noundef %2)
  %19 = fneg double %18
  %20 = load double, ptr %13, align 8, !tbaa !16
  %21 = fmul double %20, 0x3B30B0E674035E1A
  %22 = fdiv double %19, %21
  %23 = tail call double @exp(double noundef %22) #3
  %24 = tail call double @llvm.fmuladd.f64(double %17, double %23, double %.02021)
  %25 = add nuw i64 %.022, 1
  %26 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %2) #3
  %27 = getelementptr inbounds i8, ptr %26, i64 40
  %28 = load i32, ptr %27, align 8, !tbaa !15
  %29 = sext i32 %28 to i64
  %30 = icmp ult i64 %25, %29
  br i1 %30, label %14, label %.loopexit, !llvm.loop !27

.loopexit:                                        ; preds = %14, %8, %3
  %.019 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %8 ], [ %24, %14 ]
  ret double %.019
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN13OneTempApprox5ZvibrER10macroParamm(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(176), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, ptr noundef nonnull align 8 dereferenceable(176), i64 noundef) local_unnamed_addr #1 align 2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 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 #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, !10, i64 44}
!6 = !{!"_ZTS16MixtureComponent", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !11, i64 48}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !12, i64 0, !14, i64 8, !8, i64 16}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!6, !10, i64 40}
!16 = !{!17, !7, i64 120}
!17 = !{!"_ZTS10macroParam", !18, i64 0, !23, i64 32, !23, i64 56, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !11, i64 144}
!18 = !{!"_ZTS7Mixture", !19, i64 0, !10, i64 24}
!19 = !{!"_ZTSSt6vectorI16MixtureComponentSaIS0_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseI16MixtureComponentSaIS0_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseI16MixtureComponentSaIS0_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseI16MixtureComponentSaIS0_EE17_Vector_impl_dataE", !13, i64 0, !13, i64 8, !13, i64 16}
!23 = !{!"_ZTSSt6vectorIdSaIdEE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !13, i64 0, !13, i64 8, !13, i64 16}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass