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

; 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.b2Vec2 = type { float, float }
%class.b2PrismaticJoint = type <{ %class.b2Joint, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, %struct.b2Vec2, float, %struct.b2Vec2, float, float, float, float, float, float, float, i8, i8, [2 x i8], i32, i32, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, %struct.b2Vec2, %struct.b2Vec2, float, float, float, float, %struct.b2Mat22, float, float, [4 x i8] }>
%class.b2Joint = type { ptr, i32, ptr, ptr, %struct.b2JointEdge, %struct.b2JointEdge, ptr, ptr, i32, i8, i8, %struct.b2JointUserData }
%struct.b2JointEdge = type { ptr, ptr, ptr, ptr }
%struct.b2JointUserData = type { i64 }
%struct.b2Mat22 = type { %struct.b2Vec2, %struct.b2Vec2 }

; 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: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #1

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

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK16b2PrismaticJoint16GetReactionForceEf(ptr noundef nonnull align 8 dereferenceable(300) %0, float noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca %struct.b2Vec2, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca %struct.b2Vec2, align 4
  %7 = alloca %struct.b2Vec2, align 4
  %8 = alloca %struct.b2Vec2, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = load float, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %11 = getelementptr inbounds %class.b2PrismaticJoint, ptr %9, i32 0, i32 6
  %12 = getelementptr inbounds %struct.b2Vec2, ptr %11, i32 0, i32 0
  %13 = load float, ptr %12, align 4, !tbaa !11
  %14 = getelementptr inbounds %class.b2PrismaticJoint, ptr %9, i32 0, i32 26
  %15 = call <2 x float> @_ZmlfRK6b2Vec2(float noundef %13, ptr noundef nonnull align 4 dereferenceable(8) %14)
  store <2 x float> %15, ptr %7, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %16 = getelementptr inbounds %class.b2PrismaticJoint, ptr %9, i32 0, i32 7
  %17 = load float, ptr %16, align 4, !tbaa !22
  %18 = getelementptr inbounds %class.b2PrismaticJoint, ptr %9, i32 0, i32 8
  %19 = load float, ptr %18, align 8, !tbaa !23
  %20 = fadd float %17, %19
  %21 = getelementptr inbounds %class.b2PrismaticJoint, ptr %9, i32 0, i32 9
  %22 = load float, ptr %21, align 4, !tbaa !24
  %23 = fsub float %20, %22
  %24 = getelementptr inbounds %class.b2PrismaticJoint, ptr %9, i32 0, i32 25
  %25 = call <2 x float> @_ZmlfRK6b2Vec2(float noundef %23, ptr noundef nonnull align 4 dereferenceable(8) %24)
  store <2 x float> %25, ptr %8, align 4
  %26 = call <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %7, ptr noundef nonnull align 4 dereferenceable(8) %8)
  store <2 x float> %26, ptr %6, align 4
  %27 = call <2 x float> @_ZmlfRK6b2Vec2(float noundef %10, ptr noundef nonnull align 4 dereferenceable(8) %6)
  store <2 x float> %27, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %28 = load <2 x float>, ptr %3, align 4
  ret <2 x float> %28
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { 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 #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 164}
!12 = !{!"_ZTS16b2PrismaticJoint", !13, i64 0, !20, i64 128, !20, i64 136, !20, i64 144, !20, i64 152, !10, i64 160, !20, i64 164, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !10, i64 196, !17, i64 200, !17, i64 201, !16, i64 204, !16, i64 208, !20, i64 212, !20, i64 220, !10, i64 228, !10, i64 232, !10, i64 236, !10, i64 240, !20, i64 244, !20, i64 252, !10, i64 260, !10, i64 264, !10, i64 268, !10, i64 272, !21, i64 276, !10, i64 292, !10, i64 296}
!13 = !{!"_ZTS7b2Joint", !14, i64 8, !6, i64 16, !6, i64 24, !15, i64 32, !15, i64 64, !6, i64 96, !6, i64 104, !16, i64 112, !17, i64 116, !17, i64 117, !18, i64 120}
!14 = !{!"_ZTS11b2JointType", !7, i64 0}
!15 = !{!"_ZTS11b2JointEdge", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"int", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTS15b2JointUserData", !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"_ZTS6b2Vec2", !10, i64 0, !10, i64 4}
!21 = !{!"_ZTS7b2Mat22", !20, i64 0, !20, i64 8}
!22 = !{!12, !10, i64 172}
!23 = !{!12, !10, i64 176}
!24 = !{!12, !10, i64 180}


; 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.b2Vec2 = 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: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZNK16b2PrismaticJoint16GetReactionForceEf(ptr noundef nonnull align 8 dereferenceable(300) %0, float noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca %struct.b2Vec2, align 8
  %4 = alloca %struct.b2Vec2, align 8
  %5 = alloca %struct.b2Vec2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 164
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 252
  %9 = tail call <2 x float> @_ZmlfRK6b2Vec2(float noundef %7, ptr noundef nonnull align 4 dereferenceable(8) %8)
  store <2 x float> %9, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %10 = getelementptr inbounds i8, ptr %0, i64 172
  %11 = load float, ptr %10, align 4, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %0, i64 176
  %13 = load float, ptr %12, align 8, !tbaa !21
  %14 = fadd float %11, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 180
  %16 = load float, ptr %15, align 4, !tbaa !22
  %17 = fsub float %14, %16
  %18 = getelementptr inbounds i8, ptr %0, i64 244
  %19 = tail call <2 x float> @_ZmlfRK6b2Vec2(float noundef %17, ptr noundef nonnull align 4 dereferenceable(8) %18)
  store <2 x float> %19, ptr %5, align 8
  %20 = call <2 x float> @_ZplRK6b2Vec2S1_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(8) %5)
  store <2 x float> %20, ptr %3, align 8
  %21 = call <2 x float> @_ZmlfRK6b2Vec2(float noundef %1, ptr noundef nonnull align 4 dereferenceable(8) %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
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret <2 x float> %21
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { 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 #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, !18, i64 164}
!6 = !{!"_ZTS16b2PrismaticJoint", !7, i64 0, !17, i64 128, !17, i64 136, !17, i64 144, !17, i64 152, !18, i64 160, !17, i64 164, !18, i64 172, !18, i64 176, !18, i64 180, !18, i64 184, !18, i64 188, !18, i64 192, !18, i64 196, !14, i64 200, !14, i64 201, !13, i64 204, !13, i64 208, !17, i64 212, !17, i64 220, !18, i64 228, !18, i64 232, !18, i64 236, !18, i64 240, !17, i64 244, !17, i64 252, !18, i64 260, !18, i64 264, !18, i64 268, !18, i64 272, !19, i64 276, !18, i64 292, !18, i64 296}
!7 = !{!"_ZTS7b2Joint", !8, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !12, i64 64, !11, i64 96, !11, i64 104, !13, i64 112, !14, i64 116, !14, i64 117, !15, i64 120}
!8 = !{!"_ZTS11b2JointType", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!"_ZTS11b2JointEdge", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24}
!13 = !{!"int", !9, i64 0}
!14 = !{!"bool", !9, i64 0}
!15 = !{!"_ZTS15b2JointUserData", !16, i64 0}
!16 = !{!"long", !9, i64 0}
!17 = !{!"_ZTS6b2Vec2", !18, i64 0, !18, i64 4}
!18 = !{!"float", !9, i64 0}
!19 = !{!"_ZTS7b2Mat22", !17, i64 0, !17, i64 8}
!20 = !{!6, !18, i64 172}
!21 = !{!6, !18, i64 176}
!22 = !{!6, !18, i64 180}


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