; LLVM IR from ImperialCollegeLondon/pnflow :: src/pnm/pnflow/Element.ll (ZN4Elem20setGravityCorrectionERK4var3IdES3_)

; 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.var3 = type { double, double, double }
%class.Elem = type { %class.Apex, [5 x %class.SlvrElm], i8, i32, ptr, double, double, i32, %"class.std::vector", ptr, double, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, %"struct.std::pair", %"struct.std::pair", %"struct.std::pair", i32, i32, i32, i32, %class.var3 }
%class.Apex = type { ptr, i8, double, double, ptr, i32, double, double, double, double, i8, i8, i8, i8, %"struct.std::pair" }
%class.SlvrElm = type { i8, i8, i8, double, double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl" }
%"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, double }

; 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 @_ZNK7GNMData5waterEv(ptr noundef nonnull align 8 dereferenceable(984)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5Fluid7densityEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(80) ptr @_ZNK7GNMData3oilEv(ptr noundef nonnull align 8 dereferenceable(984)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10CommonData9gravConstEv(ptr noundef nonnull align 8 dereferenceable(1972)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK4var3IdEanERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Elem20setGravityCorrectionERK4var3IdES3_(ptr noundef nonnull align 8 dereferenceable(408) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %class.var3, align 8
  %8 = alloca %class.var3, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  %10 = getelementptr inbounds %class.Elem, ptr %9, i32 0, i32 4
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK7GNMData5waterEv(ptr noundef nonnull align 8 dereferenceable(984) %11)
  %13 = call noundef double @_ZNK5Fluid7densityEv(ptr noundef nonnull align 8 dereferenceable(80) %12)
  %14 = getelementptr inbounds %class.Elem, ptr %9, i32 0, i32 4
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK7GNMData3oilEv(ptr noundef nonnull align 8 dereferenceable(984) %15)
  %17 = call noundef double @_ZNK5Fluid7densityEv(ptr noundef nonnull align 8 dereferenceable(80) %16)
  %18 = fsub double %13, %17
  %19 = getelementptr inbounds %class.Elem, ptr %9, i32 0, i32 4
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10CommonData9gravConstEv(ptr noundef nonnull align 8 dereferenceable(1972) %20)
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #3
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNK4var3IdEplERKS0_(ptr dead_on_unwind writable sret(%class.var3) align 8 %8, ptr noundef nonnull align 8 dereferenceable(24) %22, ptr noundef nonnull align 8 dereferenceable(24) %23)
  call void @_ZNK4var3IdEmlEd(ptr dead_on_unwind writable sret(%class.var3) align 8 %7, ptr noundef nonnull align 8 dereferenceable(24) %8, double noundef 5.000000e-01)
  %24 = call noundef double @_ZNK4var3IdEanERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %21, ptr noundef nonnull align 8 dereferenceable(24) %7)
  %25 = fmul double %18, %24
  %26 = getelementptr inbounds %class.Apex, ptr %9, i32 0, i32 9
  store double %25, ptr %26, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  %27 = getelementptr inbounds %class.Apex, ptr %9, i32 0, i32 9
  store double 0.000000e+00, ptr %27, align 8, !tbaa !21
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4var3IdEplERKS0_(ptr dead_on_unwind noalias writable sret(%class.var3) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4var3IdEmlEd(ptr dead_on_unwind noalias writable sret(%class.var3) align 8, ptr noundef nonnull align 8 dereferenceable(24), double noundef) #2 align 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 = { 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 #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, !6, i64 232}
!10 = !{!"_ZTS4Elem", !11, i64 0, !7, i64 104, !12, i64 224, !14, i64 228, !6, i64 232, !13, i64 240, !13, i64 248, !14, i64 256, !16, i64 264, !6, i64 288, !13, i64 296, !12, i64 304, !12, i64 305, !12, i64 306, !12, i64 307, !12, i64 308, !12, i64 309, !12, i64 310, !12, i64 311, !12, i64 312, !12, i64 313, !15, i64 320, !15, i64 336, !15, i64 352, !14, i64 368, !14, i64 372, !14, i64 376, !14, i64 380, !20, i64 384}
!11 = !{!"_ZTS4Apex", !12, i64 8, !13, i64 16, !13, i64 24, !6, i64 32, !14, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !12, i64 80, !12, i64 81, !12, i64 82, !12, i64 83, !15, i64 88}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSSt4pairIidE", !14, i64 0, !13, i64 8}
!16 = !{!"_ZTSSt6vectorIP4ElemSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIP4ElemSaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTS4var3IdE", !13, i64 0, !13, i64 8, !13, i64 16}
!21 = !{!11, !13, i64 72}


; 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"

%class.var3 = type { double, double, double }

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

; Function Attrs: mustprogress 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 @_ZNK7GNMData5waterEv(ptr noundef nonnull align 8 dereferenceable(984)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK5Fluid7densityEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(80) ptr @_ZNK7GNMData3oilEv(ptr noundef nonnull align 8 dereferenceable(984)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10CommonData9gravConstEv(ptr noundef nonnull align 8 dereferenceable(1972)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Elem20setGravityCorrectionERK4var3IdES3_(ptr nocapture noundef nonnull align 8 dereferenceable(408) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %class.var3, align 8
  %5 = alloca %class.var3, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 232
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK7GNMData5waterEv(ptr noundef nonnull align 8 dereferenceable(984) %7)
  %9 = tail call noundef double @_ZNK5Fluid7densityEv(ptr noundef nonnull align 8 dereferenceable(80) %8)
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK7GNMData3oilEv(ptr noundef nonnull align 8 dereferenceable(984) %10)
  %12 = tail call noundef double @_ZNK5Fluid7densityEv(ptr noundef nonnull align 8 dereferenceable(80) %11)
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK10CommonData9gravConstEv(ptr noundef nonnull align 8 dereferenceable(1972) %13)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  call void @_ZNK4var3IdEplERKS0_(ptr dead_on_unwind nonnull writable sret(%class.var3) align 8 %5, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2)
  call void @_ZNK4var3IdEmlEd(ptr dead_on_unwind nonnull writable sret(%class.var3) align 8 %4, ptr noundef nonnull align 8 dereferenceable(24) %5, double noundef 5.000000e-01)
  %15 = call noundef double @_ZNK4var3IdEanERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %14, ptr noundef nonnull align 8 dereferenceable(24) %4)
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  store double 0.000000e+00, ptr %16, align 8, !tbaa !20
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4var3IdEplERKS0_(ptr dead_on_unwind noalias writable sret(%class.var3) align 8, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK4var3IdEmlEd(ptr dead_on_unwind noalias writable sret(%class.var3) align 8, ptr noundef nonnull align 8 dereferenceable(24), double noundef) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress 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 = { 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 #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, !12, i64 232}
!6 = !{!"_ZTS4Elem", !7, i64 0, !9, i64 104, !8, i64 224, !13, i64 228, !12, i64 232, !11, i64 240, !11, i64 248, !13, i64 256, !15, i64 264, !12, i64 288, !11, i64 296, !8, i64 304, !8, i64 305, !8, i64 306, !8, i64 307, !8, i64 308, !8, i64 309, !8, i64 310, !8, i64 311, !8, i64 312, !8, i64 313, !14, i64 320, !14, i64 336, !14, i64 352, !13, i64 368, !13, i64 372, !13, i64 376, !13, i64 380, !19, i64 384}
!7 = !{!"_ZTS4Apex", !8, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !8, i64 80, !8, i64 81, !8, i64 82, !8, i64 83, !14, i64 88}
!8 = !{!"bool", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTSSt4pairIidE", !13, i64 0, !11, i64 8}
!15 = !{!"_ZTSSt6vectorIP4ElemSaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIP4ElemSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIP4ElemSaIS1_EE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!19 = !{!"_ZTS4var3IdE", !11, i64 0, !11, i64 8, !11, i64 16}
!20 = !{!7, !11, i64 72}


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