; LLVM IR from SOHNE/Dura2D :: src/kinetics/d2Body.ll (ZN6d2Body15IntegrateForcesEf)

; 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.d2Vec2 = type { float, float }
%class.d2Body = type <{ i16, [2 x i8], i32, %struct.d2Transform, %struct.d2Vec2, %struct.d2Vec2, float, float, float, %struct.d2Vec2, float, float, float, float, float, float, float, ptr, ptr, ptr, ptr, ptr, float, [4 x i8] }>
%struct.d2Transform = type { %struct.d2Vec2, %struct.d2Rot }
%struct.d2Rot = 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6d2Body11ClearForcesEv(ptr noundef nonnull align 8 dereferenceable(132)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6d2Body11ClearTorqueEv(ptr noundef nonnull align 8 dereferenceable(132)) #3 align 2

declare <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8), float noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6d2Body15IntegrateForcesEf(ptr noundef nonnull align 8 dereferenceable(132) %0, float noundef %1) #5 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca %struct.d2Vec2, align 4
  %6 = alloca %struct.d2Vec2, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 2
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  br label %36

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %13 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 9
  %14 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 12
  %15 = load float, ptr %14, align 4, !tbaa !18
  %16 = call <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8) %13, float noundef %15)
  store <2 x float> %16, ptr %5, align 4
  %17 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 5
  %18 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8) %17, ptr noundef nonnull align 4 dereferenceable(8) %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %19 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 5
  %20 = load float, ptr %4, align 4, !tbaa !9
  %21 = call <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8) %19, float noundef %20)
  store <2 x float> %21, ptr %6, align 4
  %22 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 4
  %23 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %22, ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %24 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 10
  %25 = load float, ptr %24, align 4, !tbaa !19
  %26 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 14
  %27 = load float, ptr %26, align 4, !tbaa !20
  %28 = fmul float %25, %27
  %29 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 8
  store float %28, ptr %29, align 8, !tbaa !21
  %30 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 8
  %31 = load float, ptr %30, align 8, !tbaa !21
  %32 = load float, ptr %4, align 4, !tbaa !9
  %33 = getelementptr inbounds %class.d2Body, ptr %7, i32 0, i32 7
  %34 = load float, ptr %33, align 4, !tbaa !22
  %35 = call float @llvm.fmuladd.f32(float %31, float %32, float %34)
  store float %35, ptr %33, align 4, !tbaa !22
  call void @_ZN6d2Body11ClearForcesEv(ptr noundef nonnull align 8 dereferenceable(132) %7)
  call void @_ZN6d2Body11ClearTorqueEv(ptr noundef nonnull align 8 dereferenceable(132) %7)
  br label %36

36:                                               ; preds = %12, %11
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { mustprogress 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 #6 = { 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, !14, i64 4}
!12 = !{!"_ZTS6d2Body", !13, i64 0, !14, i64 4, !15, i64 8, !16, i64 24, !16, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !16, i64 52, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !10, i64 128}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_ZTS10d2BodyType", !7, i64 0}
!15 = !{!"_ZTS11d2Transform", !16, i64 0, !17, i64 8}
!16 = !{!"_ZTS6d2Vec2", !10, i64 0, !10, i64 4}
!17 = !{!"_ZTS5d2Rot", !10, i64 0, !10, i64 4}
!18 = !{!12, !10, i64 68}
!19 = !{!12, !10, i64 60}
!20 = !{!12, !10, i64 76}
!21 = !{!12, !10, i64 48}
!22 = !{!12, !10, i64 44}


; 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.d2Vec2 = 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

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

declare noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6d2Body11ClearForcesEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6d2Body11ClearTorqueEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #3 align 2

declare <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8), float noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6d2Body15IntegrateForcesEf(ptr noundef nonnull align 8 dereferenceable(132) %0, float noundef %1) local_unnamed_addr #5 align 2 {
  %3 = alloca %struct.d2Vec2, align 8
  %4 = alloca %struct.d2Vec2, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %27, label %8

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %9 = getelementptr inbounds i8, ptr %0, i64 52
  %10 = getelementptr inbounds i8, ptr %0, i64 68
  %11 = load float, ptr %10, align 4, !tbaa !16
  %12 = tail call <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8) %9, float noundef %11)
  store <2 x float> %12, ptr %3, align 8
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2aSERKS_(ptr noundef nonnull align 4 dereferenceable(8) %13, ptr noundef nonnull align 4 dereferenceable(8) %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %15 = call <2 x float> @_ZNK6d2Vec2mlEf(ptr noundef nonnull align 4 dereferenceable(8) %13, float noundef %1)
  store <2 x float> %15, ptr %4, align 8
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  %17 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN6d2Vec2pLERKS_(ptr noundef nonnull align 4 dereferenceable(8) %16, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %18 = getelementptr inbounds i8, ptr %0, i64 60
  %19 = load float, ptr %18, align 4, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %0, i64 76
  %21 = load float, ptr %20, align 4, !tbaa !18
  %22 = fmul float %19, %21
  %23 = getelementptr inbounds i8, ptr %0, i64 48
  store float %22, ptr %23, align 8, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %0, i64 44
  %25 = load float, ptr %24, align 4, !tbaa !20
  %26 = call float @llvm.fmuladd.f32(float %22, float %1, float %25)
  store float %26, ptr %24, align 4, !tbaa !20
  call void @_ZN6d2Body11ClearForcesEv(ptr noundef nonnull align 8 dereferenceable(132) %0)
  call void @_ZN6d2Body11ClearTorqueEv(ptr noundef nonnull align 8 dereferenceable(132) %0)
  br label %27

27:                                               ; preds = %2, %8
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { mustprogress 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 #6 = { 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 4}
!6 = !{!"_ZTS6d2Body", !7, i64 0, !10, i64 4, !11, i64 8, !12, i64 24, !12, i64 32, !13, i64 40, !13, i64 44, !13, i64 48, !12, i64 52, !13, i64 60, !13, i64 64, !13, i64 68, !13, i64 72, !13, i64 76, !13, i64 80, !13, i64 84, !15, i64 88, !15, i64 96, !15, i64 104, !15, i64 112, !15, i64 120, !13, i64 128}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS10d2BodyType", !8, i64 0}
!11 = !{!"_ZTS11d2Transform", !12, i64 0, !14, i64 8}
!12 = !{!"_ZTS6d2Vec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTS5d2Rot", !13, i64 0, !13, i64 4}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!6, !13, i64 68}
!17 = !{!6, !13, i64 60}
!18 = !{!6, !13, i64 76}
!19 = !{!6, !13, i64 48}
!20 = !{!6, !13, i64 44}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass