; LLVM IR from sytelus/GamePhysics :: IntegrationBasics/Integration.ll (Z8evaluateRK5StateffRK10Derivative)

; 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.Derivative = type { float, float }
%struct.State = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z12accelerationRK5Statef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #0

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef %1, float noundef %2, ptr noundef nonnull align 4 dereferenceable(8) %3) #3 {
  %5 = alloca %struct.Derivative, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.State, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.State, ptr %11, i32 0, i32 0
  %13 = load float, ptr %12, align 4, !tbaa !11
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Derivative, ptr %14, i32 0, i32 0
  %16 = load float, ptr %15, align 4, !tbaa !13
  %17 = load float, ptr %8, align 4, !tbaa !9
  %18 = call float @llvm.fmuladd.f32(float %16, float %17, float %13)
  %19 = getelementptr inbounds %struct.State, ptr %10, i32 0, i32 0
  store float %18, ptr %19, align 4, !tbaa !11
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.State, ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !15
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Derivative, ptr %23, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !16
  %26 = load float, ptr %8, align 4, !tbaa !9
  %27 = call float @llvm.fmuladd.f32(float %25, float %26, float %22)
  %28 = getelementptr inbounds %struct.State, ptr %10, i32 0, i32 1
  store float %27, ptr %28, align 4, !tbaa !15
  %29 = getelementptr inbounds %struct.State, ptr %10, i32 0, i32 1
  %30 = load float, ptr %29, align 4, !tbaa !15
  %31 = getelementptr inbounds %struct.Derivative, ptr %5, i32 0, i32 0
  store float %30, ptr %31, align 4, !tbaa !13
  %32 = load float, ptr %7, align 4, !tbaa !9
  %33 = load float, ptr %8, align 4, !tbaa !9
  %34 = fadd float %32, %33
  %35 = call noundef float @_Z12accelerationRK5Statef(ptr noundef nonnull align 4 dereferenceable(8) %10, float noundef %34)
  %36 = getelementptr inbounds %struct.Derivative, ptr %5, i32 0, i32 1
  store float %35, ptr %36, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %37 = load <2 x float>, ptr %5, align 4
  ret <2 x float> %37
}

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 willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 }

!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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS5State", !10, i64 0, !10, i64 4}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS10Derivative", !10, i64 0, !10, i64 4}
!15 = !{!12, !10, i64 4}
!16 = !{!14, !10, i64 4}


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

%struct.State = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z12accelerationRK5Statef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %0, float noundef %1, float noundef %2, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %3) local_unnamed_addr #2 {
  %5 = alloca %struct.State, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %6 = load <2 x float>, ptr %0, align 4, !tbaa !5
  %7 = load <2 x float>, ptr %3, align 4, !tbaa !5
  %8 = insertelement <2 x float> poison, float %2, i64 0
  %9 = shufflevector <2 x float> %8, <2 x float> poison, <2 x i32> zeroinitializer
  %10 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %7, <2 x float> %9, <2 x float> %6)
  store <2 x float> %10, ptr %5, align 8, !tbaa !5
  %11 = shufflevector <2 x float> %10, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %12 = fadd float %1, %2
  %13 = call noundef float @_Z12accelerationRK5Statef(ptr noundef nonnull align 4 dereferenceable(8) %5, float noundef %12)
  %.sroa.0.4.vec.insert = insertelement <2 x float> %11, float %13, i64 1
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret <2 x float> %.sroa.0.4.vec.insert
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass