; LLVM IR from artvns/SimpleFvm :: simplefvm/src/FVMSolver/CoeffsPartsVelocity/RhsVelocity (RhsU)

; 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.fvmsolver::RhsU" = type { %"class.fvmsolver::AbstractRhsVelocity", %"class.std::unique_ptr", ptr }
%"class.fvmsolver::AbstractRhsVelocity" = type { ptr, double, double }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9fvmsolver4RhsU9calculateEmdd(ptr noundef nonnull align 8 dereferenceable(40) %0, i64 noundef %1, double noundef %2, double noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !11
  store double %3, ptr %8, align 8, !tbaa !11
  %16 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %17 = getelementptr inbounds %"class.fvmsolver::RhsU", ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = call noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUpEm(ptr noundef nonnull align 8 dereferenceable(40) %18, i64 noundef %19)
  %21 = sub i64 %20, 1
  store i64 %21, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %22 = getelementptr inbounds %"class.fvmsolver::RhsU", ptr %16, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = call noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUwEm(ptr noundef nonnull align 8 dereferenceable(40) %23, i64 noundef %24)
  %26 = sub i64 %25, 1
  store i64 %26, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %27 = getelementptr inbounds %"class.fvmsolver::RhsU", ptr %16, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !13
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = call noundef double @_ZNK9fvmsolver8RhsUPort6get_dYEm(ptr noundef nonnull align 8 dereferenceable(40) %28, i64 noundef %29)
  store double %30, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %31 = getelementptr inbounds %"class.fvmsolver::RhsU", ptr %16, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load i64, ptr %9, align 8, !tbaa !9
  %34 = call noundef double @_ZNK9fvmsolver8RhsUPort5get_uEm(ptr noundef nonnull align 8 dereferenceable(40) %32, i64 noundef %33)
  store double %34, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %35 = getelementptr inbounds %"class.fvmsolver::RhsU", ptr %16, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  %37 = load i64, ptr %9, align 8, !tbaa !9
  %38 = call noundef double @_ZNK9fvmsolver8RhsUPort5get_pEm(ptr noundef nonnull align 8 dereferenceable(40) %36, i64 noundef %37)
  store double %38, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %39 = getelementptr inbounds %"class.fvmsolver::RhsU", ptr %16, i32 0, i32 2
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  %41 = load i64, ptr %10, align 8, !tbaa !9
  %42 = call noundef double @_ZNK9fvmsolver8RhsUPort5get_pEm(ptr noundef nonnull align 8 dereferenceable(40) %40, i64 noundef %41)
  store double %42, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %43 = getelementptr inbounds %"class.fvmsolver::RhsU", ptr %16, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  %45 = call noundef double @_ZNK9fvmsolver8RhsUPort10get_alphaUEv(ptr noundef nonnull align 8 dereferenceable(40) %44)
  store double %45, ptr %15, align 8, !tbaa !11
  %46 = load double, ptr %7, align 8, !tbaa !11
  %47 = load double, ptr %15, align 8, !tbaa !11
  %48 = fsub double 1.000000e+00, %47
  %49 = load double, ptr %8, align 8, !tbaa !11
  %50 = fmul double %48, %49
  %51 = load double, ptr %15, align 8, !tbaa !11
  %52 = fdiv double %50, %51
  %53 = load double, ptr %12, align 8, !tbaa !11
  %54 = call double @llvm.fmuladd.f64(double %52, double %53, double %46)
  %55 = getelementptr inbounds %"class.fvmsolver::AbstractRhsVelocity", ptr %16, i32 0, i32 2
  store double %54, ptr %55, align 8, !tbaa !22
  %56 = load double, ptr %14, align 8, !tbaa !11
  %57 = load double, ptr %13, align 8, !tbaa !11
  %58 = fsub double %56, %57
  %59 = load double, ptr %11, align 8, !tbaa !11
  %60 = getelementptr inbounds %"class.fvmsolver::AbstractRhsVelocity", ptr %16, i32 0, i32 2
  %61 = load double, ptr %60, align 8, !tbaa !22
  %62 = call double @llvm.fmuladd.f64(double %58, double %59, double %61)
  %63 = getelementptr inbounds %"class.fvmsolver::AbstractRhsVelocity", ptr %16, i32 0, i32 1
  store double %62, ptr %63, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

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

declare noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUpEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #2

declare noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUwEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #2

declare noundef double @_ZNK9fvmsolver8RhsUPort6get_dYEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #2

declare noundef double @_ZNK9fvmsolver8RhsUPort5get_uEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #2

declare noundef double @_ZNK9fvmsolver8RhsUPort5get_pEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) #2

declare noundef double @_ZNK9fvmsolver8RhsUPort10get_alphaUEv(ptr noundef nonnull align 8 dereferenceable(40)) #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 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 = { "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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !6, i64 32}
!14 = !{!"_ZTSN9fvmsolver4RhsUE", !15, i64 0, !16, i64 24, !6, i64 32}
!15 = !{!"_ZTSN9fvmsolver19AbstractRhsVelocityE", !12, i64 8, !12, i64 16}
!16 = !{!"_ZTSSt10unique_ptrIN9fvmsolver8RhsUPortESt14default_deleteIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_dataIN9fvmsolver8RhsUPortESt14default_deleteIS1_ELb1ELb1EE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_implIN9fvmsolver8RhsUPortESt14default_deleteIS1_EE", !19, i64 0}
!19 = !{!"_ZTSSt5tupleIJPN9fvmsolver8RhsUPortESt14default_deleteIS1_EEE", !20, i64 0}
!20 = !{!"_ZTSSt11_Tuple_implILm0EJPN9fvmsolver8RhsUPortESt14default_deleteIS1_EEE", !21, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm0EPN9fvmsolver8RhsUPortELb0EE", !6, i64 0}
!22 = !{!15, !12, i64 16}
!23 = !{!15, !12, 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 uwtable
define dso_local void @_ZN9fvmsolver4RhsU9calculateEmdd(ptr nocapture noundef nonnull align 8 dereferenceable(40) %0, i64 noundef %1, double noundef %2, double noundef %3) unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUpEm(ptr noundef nonnull align 8 dereferenceable(40) %6, i64 noundef %1)
  %8 = add i64 %7, -1
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = tail call noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUwEm(ptr noundef nonnull align 8 dereferenceable(40) %9, i64 noundef %1)
  %11 = add i64 %10, -1
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = tail call noundef double @_ZNK9fvmsolver8RhsUPort6get_dYEm(ptr noundef nonnull align 8 dereferenceable(40) %12, i64 noundef %1)
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = tail call noundef double @_ZNK9fvmsolver8RhsUPort5get_uEm(ptr noundef nonnull align 8 dereferenceable(40) %14, i64 noundef %8)
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = tail call noundef double @_ZNK9fvmsolver8RhsUPort5get_pEm(ptr noundef nonnull align 8 dereferenceable(40) %16, i64 noundef %8)
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = tail call noundef double @_ZNK9fvmsolver8RhsUPort5get_pEm(ptr noundef nonnull align 8 dereferenceable(40) %18, i64 noundef %11)
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = tail call noundef double @_ZNK9fvmsolver8RhsUPort10get_alphaUEv(ptr noundef nonnull align 8 dereferenceable(40) %20)
  %22 = fsub double 1.000000e+00, %21
  %23 = fmul double %22, %3
  %24 = fdiv double %23, %21
  %25 = tail call double @llvm.fmuladd.f64(double %24, double %15, double %2)
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  store double %25, ptr %26, align 8, !tbaa !18
  %27 = fsub double %19, %17
  %28 = tail call double @llvm.fmuladd.f64(double %27, double %13, double %25)
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  store double %28, ptr %29, align 8, !tbaa !19
  ret void
}

declare noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUpEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #1

declare noundef i64 @_ZNK9fvmsolver8RhsUPort8getNumUwEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #1

declare noundef double @_ZNK9fvmsolver8RhsUPort6get_dYEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #1

declare noundef double @_ZNK9fvmsolver8RhsUPort5get_uEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #1

declare noundef double @_ZNK9fvmsolver8RhsUPort5get_pEm(ptr noundef nonnull align 8 dereferenceable(40), i64 noundef) local_unnamed_addr #1

declare noundef double @_ZNK9fvmsolver8RhsUPort10get_alphaUEv(ptr noundef nonnull align 8 dereferenceable(40)) 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 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 = { "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) }

!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, !17, i64 32}
!6 = !{!"_ZTSN9fvmsolver4RhsUE", !7, i64 0, !11, i64 24, !17, i64 32}
!7 = !{!"_ZTSN9fvmsolver19AbstractRhsVelocityE", !8, i64 8, !8, i64 16}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSSt10unique_ptrIN9fvmsolver8RhsUPortESt14default_deleteIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt15__uniq_ptr_dataIN9fvmsolver8RhsUPortESt14default_deleteIS1_ELb1ELb1EE", !13, i64 0}
!13 = !{!"_ZTSSt15__uniq_ptr_implIN9fvmsolver8RhsUPortESt14default_deleteIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt5tupleIJPN9fvmsolver8RhsUPortESt14default_deleteIS1_EEE", !15, i64 0}
!15 = !{!"_ZTSSt11_Tuple_implILm0EJPN9fvmsolver8RhsUPortESt14default_deleteIS1_EEE", !16, i64 0}
!16 = !{!"_ZTSSt10_Head_baseILm0EPN9fvmsolver8RhsUPortELb0EE", !17, i64 0}
!17 = !{!"any pointer", !9, i64 0}
!18 = !{!7, !8, i64 16}
!19 = !{!7, !8, i64 8}


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