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

; 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: 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 float @llvm.fmuladd.f32(float, float, float) #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 <2 x float> @_Z8evaluateRK5Statef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef, ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z9integrateR5Stateff(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef %1, float noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca %struct.Derivative, align 4
  %8 = alloca %struct.Derivative, align 4
  %9 = alloca %struct.Derivative, align 4
  %10 = alloca %struct.Derivative, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load float, ptr %5, align 4, !tbaa !9
  %15 = call <2 x float> @_Z8evaluateRK5Statef(ptr noundef nonnull align 4 dereferenceable(8) %13, float noundef %14)
  store <2 x float> %15, ptr %7, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = load float, ptr %5, align 4, !tbaa !9
  %18 = load float, ptr %6, align 4, !tbaa !9
  %19 = fmul float %18, 5.000000e-01
  %20 = call <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8) %16, float noundef %17, float noundef %19, ptr noundef nonnull align 4 dereferenceable(8) %7)
  store <2 x float> %20, ptr %8, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load float, ptr %5, align 4, !tbaa !9
  %23 = load float, ptr %6, align 4, !tbaa !9
  %24 = fmul float %23, 5.000000e-01
  %25 = call <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8) %21, float noundef %22, float noundef %24, ptr noundef nonnull align 4 dereferenceable(8) %8)
  store <2 x float> %25, ptr %9, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = load float, ptr %5, align 4, !tbaa !9
  %28 = load float, ptr %6, align 4, !tbaa !9
  %29 = call <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8) %26, float noundef %27, float noundef %28, ptr noundef nonnull align 4 dereferenceable(8) %9)
  store <2 x float> %29, ptr %10, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %30 = getelementptr inbounds %struct.Derivative, ptr %7, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !11
  %32 = getelementptr inbounds %struct.Derivative, ptr %8, i32 0, i32 0
  %33 = load float, ptr %32, align 4, !tbaa !11
  %34 = getelementptr inbounds %struct.Derivative, ptr %9, i32 0, i32 0
  %35 = load float, ptr %34, align 4, !tbaa !11
  %36 = fadd float %33, %35
  %37 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %36, float %31)
  %38 = getelementptr inbounds %struct.Derivative, ptr %10, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !11
  %40 = fadd float %37, %39
  %41 = fmul float 0x3FC5555560000000, %40
  store float %41, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %42 = getelementptr inbounds %struct.Derivative, ptr %7, i32 0, i32 1
  %43 = load float, ptr %42, align 4, !tbaa !13
  %44 = getelementptr inbounds %struct.Derivative, ptr %8, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !13
  %46 = getelementptr inbounds %struct.Derivative, ptr %9, i32 0, i32 1
  %47 = load float, ptr %46, align 4, !tbaa !13
  %48 = fadd float %45, %47
  %49 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %48, float %43)
  %50 = getelementptr inbounds %struct.Derivative, ptr %10, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !13
  %52 = fadd float %49, %51
  %53 = fmul float 0x3FC5555560000000, %52
  store float %53, ptr %12, align 4, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.State, ptr %54, i32 0, i32 0
  %56 = load float, ptr %55, align 4, !tbaa !14
  %57 = load float, ptr %11, align 4, !tbaa !9
  %58 = load float, ptr %6, align 4, !tbaa !9
  %59 = call float @llvm.fmuladd.f32(float %57, float %58, float %56)
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.State, ptr %60, i32 0, i32 0
  store float %59, ptr %61, align 4, !tbaa !14
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.State, ptr %62, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !16
  %65 = load float, ptr %12, align 4, !tbaa !9
  %66 = load float, ptr %6, align 4, !tbaa !9
  %67 = call float @llvm.fmuladd.f32(float %65, float %66, float %64)
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.State, ptr %68, i32 0, i32 1
  store float %67, ptr %69, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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

; 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 <2 x float> @_Z8evaluateRK5Statef(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8), float noundef, float noundef, ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z9integrateR5Stateff(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef %1, float noundef %2) local_unnamed_addr #1 {
  %4 = alloca %struct.Derivative, align 8
  %5 = alloca %struct.Derivative, align 8
  %6 = alloca %struct.Derivative, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %7 = tail call <2 x float> @_Z8evaluateRK5Statef(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef %1)
  store <2 x float> %7, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %8 = fmul float %2, 5.000000e-01
  %9 = call <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef %1, float noundef %8, ptr noundef nonnull align 4 dereferenceable(8) %4)
  store <2 x float> %9, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %10 = call <2 x float> @_Z8evaluateRK5StateffRK10Derivative(ptr noundef nonnull align 4 dereferenceable(8) %0, float noundef %1, float noundef %8, ptr noundef nonnull align 4 dereferenceable(8) %5)
  store <2 x float> %10, ptr %6, align 8
  %11 = call <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) %6)
  %12 = load <2 x float>, ptr %4, align 8, !tbaa !5
  %13 = load <2 x float>, ptr %5, align 8, !tbaa !5
  %14 = load <2 x float>, ptr %6, align 8, !tbaa !5
  %15 = fadd <2 x float> %13, %14
  %16 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %15, <2 x float> <float 2.000000e+00, float 2.000000e+00>, <2 x float> %12)
  %17 = fadd <2 x float> %11, %16
  %18 = fmul <2 x float> %17, <float 0x3FC5555560000000, float 0x3FC5555560000000>
  %19 = load <2 x float>, ptr %0, align 4, !tbaa !5
  %20 = insertelement <2 x float> poison, float %2, i64 0
  %21 = shufflevector <2 x float> %20, <2 x float> poison, <2 x i32> zeroinitializer
  %22 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %18, <2 x float> %21, <2 x float> %19)
  store <2 x float> %22, ptr %0, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret void
}

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

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


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