; LLVM IR from mtsamis/box2d-optimized :: src/dynamics/b2_joint.ll (Z17b2LinearStiffnessRfS_ffPK6b2BodyS2_)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z17b2LinearStiffnessRfS_ffPK6b2BodyS2_(ptr noundef nonnull align 4 dereferenceable(4) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, float noundef %2, float noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store float %2, ptr %9, align 4, !tbaa !9
  store float %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %17 = load ptr, ptr %11, align 8, !tbaa !5
  %18 = call noundef float @_ZNK6b2Body7GetMassEv(ptr noundef nonnull align 8 dereferenceable(208) %17)
  store float %18, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %19 = load ptr, ptr %12, align 8, !tbaa !5
  %20 = call noundef float @_ZNK6b2Body7GetMassEv(ptr noundef nonnull align 8 dereferenceable(208) %19)
  store float %20, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %21 = load float, ptr %13, align 4, !tbaa !9
  %22 = fcmp ogt float %21, 0.000000e+00
  br i1 %22, label %23, label %34

23:                                               ; preds = %6
  %24 = load float, ptr %14, align 4, !tbaa !9
  %25 = fcmp ogt float %24, 0.000000e+00
  br i1 %25, label %26, label %34

26:                                               ; preds = %23
  %27 = load float, ptr %13, align 4, !tbaa !9
  %28 = load float, ptr %14, align 4, !tbaa !9
  %29 = fmul float %27, %28
  %30 = load float, ptr %13, align 4, !tbaa !9
  %31 = load float, ptr %14, align 4, !tbaa !9
  %32 = fadd float %30, %31
  %33 = fdiv float %29, %32
  store float %33, ptr %15, align 4, !tbaa !9
  br label %42

34:                                               ; preds = %23, %6
  %35 = load float, ptr %13, align 4, !tbaa !9
  %36 = fcmp ogt float %35, 0.000000e+00
  br i1 %36, label %37, label %39

37:                                               ; preds = %34
  %38 = load float, ptr %13, align 4, !tbaa !9
  store float %38, ptr %15, align 4, !tbaa !9
  br label %41

39:                                               ; preds = %34
  %40 = load float, ptr %14, align 4, !tbaa !9
  store float %40, ptr %15, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %39, %37
  br label %42

42:                                               ; preds = %41, %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %43 = load float, ptr %9, align 4, !tbaa !9
  %44 = fmul float 0x401921FB60000000, %43
  store float %44, ptr %16, align 4, !tbaa !9
  %45 = load float, ptr %15, align 4, !tbaa !9
  %46 = load float, ptr %16, align 4, !tbaa !9
  %47 = fmul float %45, %46
  %48 = load float, ptr %16, align 4, !tbaa !9
  %49 = fmul float %47, %48
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  store float %49, ptr %50, align 4, !tbaa !9
  %51 = load float, ptr %15, align 4, !tbaa !9
  %52 = fmul float 2.000000e+00, %51
  %53 = load float, ptr %10, align 4, !tbaa !9
  %54 = fmul float %52, %53
  %55 = load float, ptr %16, align 4, !tbaa !9
  %56 = fmul float %54, %55
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  store float %56, ptr %57, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  ret void
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK6b2Body7GetMassEv(ptr noundef nonnull align 8 dereferenceable(208)) #2 align 2

; 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 = { inlinehint 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 #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}


; 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 nounwind uwtable
define dso_local void @_Z17b2LinearStiffnessRfS_ffPK6b2BodyS2_(ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %0, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %1, float noundef %2, float noundef %3, ptr noundef nonnull %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = tail call noundef float @_ZNK6b2Body7GetMassEv(ptr noundef nonnull align 8 dereferenceable(208) %4)
  %8 = tail call noundef float @_ZNK6b2Body7GetMassEv(ptr noundef nonnull align 8 dereferenceable(208) %5)
  %9 = fcmp ogt float %7, 0.000000e+00
  %10 = fcmp ogt float %8, 0.000000e+00
  %or.cond = and i1 %9, %10
  br i1 %or.cond, label %11, label %15

11:                                               ; preds = %6
  %12 = fmul float %7, %8
  %13 = fadd float %7, %8
  %14 = fdiv float %12, %13
  br label %16

15:                                               ; preds = %6
  %. = select i1 %9, float %7, float %8
  br label %16

16:                                               ; preds = %15, %11
  %.0 = phi float [ %14, %11 ], [ %., %15 ]
  %17 = fmul float %2, 0x401921FB60000000
  %18 = fmul float %17, %.0
  %19 = fmul float %17, %18
  store float %19, ptr %0, align 4, !tbaa !5
  %20 = fmul float %.0, 2.000000e+00
  %21 = fmul float %20, %3
  %22 = fmul float %17, %21
  store float %22, ptr %1, align 4, !tbaa !5
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK6b2Body7GetMassEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #1 align 2

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 = { inlinehint 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" }

!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,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass