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

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

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

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

22:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store double 0.000000e+00, ptr %8, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store double 1.000000e+00, ptr %9, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %23

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

34:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %64

35:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %36 = load i64, ptr %10, align 8, !tbaa !9
  %37 = trunc i64 %36 to i32
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i64, ptr %7, align 8, !tbaa !9
  %40 = call noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %12, i32 noundef %37, ptr noundef nonnull align 8 dereferenceable(176) %38, i64 noundef %39)
  store double %40, ptr %11, align 8, !tbaa !17
  %41 = load double, ptr %9, align 8, !tbaa !17
  %42 = load double, ptr %11, align 8, !tbaa !17
  %43 = fmul double %41, %42
  %44 = load double, ptr %11, align 8, !tbaa !17
  %45 = fneg double %44
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.macroParam, ptr %46, i32 0, i32 8
  %48 = load double, ptr %47, align 8, !tbaa !19
  %49 = fmul double 0x3B30B0E674035E1A, %48
  %50 = fdiv double %45, %49
  %51 = call double @exp(double noundef %50) #3
  %52 = fmul double %43, %51
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.macroParam, ptr %53, i32 0, i32 8
  %55 = load double, ptr %54, align 8, !tbaa !19
  %56 = call double @pow(double noundef %55, double noundef 2.000000e+00) #3
  %57 = fmul double 0x3B30B0E674035E1A, %56
  %58 = fdiv double %52, %57
  %59 = load double, ptr %8, align 8, !tbaa !17
  %60 = fadd double %59, %58
  store double %60, ptr %8, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %61

61:                                               ; preds = %35
  %62 = load i64, ptr %10, align 8, !tbaa !9
  %63 = add i64 %62, 1
  store i64 %63, ptr %10, align 8, !tbaa !9
  br label %23, !llvm.loop !30

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

66:                                               ; preds = %64, %21
  %67 = load double, ptr %4, align 8
  ret double %67
}

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN13OneTempApprox9ZvibrDiffER10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(176) %1, i64 noundef %2) local_unnamed_addr #0 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) #2
  %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 %.preheader

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

.lr.ph:                                           ; preds = %.preheader
  %11 = getelementptr inbounds i8, ptr %1, i64 120
  br label %12

12:                                               ; preds = %.lr.ph, %12
  %.01720 = phi i64 [ 0, %.lr.ph ], [ %25, %12 ]
  %.01819 = phi double [ 0.000000e+00, %.lr.ph ], [ %24, %12 ]
  %13 = trunc i64 %.01720 to i32
  %14 = tail call noundef double @_ZN13OneTempApprox13vibrEnergyLvlEiR10macroParamm(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %13, ptr noundef nonnull align 8 dereferenceable(176) %1, i64 noundef %2)
  %15 = fneg double %14
  %16 = load double, ptr %11, align 8, !tbaa !16
  %17 = fmul double %16, 0x3B30B0E674035E1A
  %18 = fdiv double %15, %17
  %19 = tail call double @exp(double noundef %18) #2
  %20 = fmul double %14, %19
  %21 = load double, ptr %11, align 8, !tbaa !16
  %square = fmul double %21, %21
  %22 = fmul double %square, 0x3B30B0E674035E1A
  %23 = fdiv double %20, %22
  %24 = fadd double %.01819, %23
  %25 = add nuw i64 %.01720, 1
  %26 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNSt6vectorI16MixtureComponentSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %2) #2
  %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 %12, label %.loopexit, !llvm.loop !27

.loopexit:                                        ; preds = %12, %.preheader, %3
  %.0 = phi double [ 0.000000e+00, %3 ], [ 0.000000e+00, %.preheader ], [ %24, %12 ]
  ret double %.0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @exp(double noundef) local_unnamed_addr #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 = { 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 = { 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,SROAPass,SimplifyCFGPass,TailCallElimPass