; LLVM IR from Mithreindeir/VelocityRaptor :: VelocityRaptor/src (vrJoint)

; 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.vrVec2 = type { float, float }
%struct.vrLocalPoint = type { float, %struct.vrVec2, ptr }
%struct.vrRigidBody = type { %struct.vrVec2, %struct.vrVec2, %struct.vrVec2, %struct.vrVec2, float, float, float, float, %struct.vrCollisionGroup, %struct.vrMaterial, ptr, %struct.vrColor, %struct.vrVec2, %struct.vrOrientedBoundingBox, ptr, i32 }
%struct.vrCollisionGroup = type { i32, i32 }
%struct.vrMaterial = type { float, float, float, float, float, float, float, float }
%struct.vrColor = type { float, float, float }
%struct.vrOrientedBoundingBox = type { %struct.vrVec2, %struct.vrVec2 }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
define dso_local <2 x float> @vrGetLocalPoint(ptr noundef %0) #2 {
  %2 = alloca %struct.vrVec2, align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca %struct.vrVec2, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.vrLocalPoint, ptr %10, i32 0, i32 2
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.vrRigidBody, ptr %12, i32 0, i32 4
  %14 = load float, ptr %13, align 8, !tbaa !13
  store float %14, ptr %4, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %15 = load float, ptr %4, align 4, !tbaa !20
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.vrLocalPoint, ptr %16, i32 0, i32 0
  %18 = load float, ptr %17, align 8, !tbaa !21
  %19 = fsub float %15, %18
  store float %19, ptr %5, align 4, !tbaa !20
  %20 = load float, ptr %5, align 4, !tbaa !20
  %21 = fcmp oeq float %20, 0.000000e+00
  br i1 %21, label %22, label %25

22:                                               ; preds = %1
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.vrLocalPoint, ptr %23, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %24, i64 8, i1 false), !tbaa.struct !22
  store i32 1, ptr %6, align 4
  br label %59

25:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %26 = load float, ptr %5, align 4, !tbaa !20
  %27 = fpext float %26 to double
  %28 = call double @cos(double noundef %27) #6
  %29 = fptrunc double %28 to float
  store float %29, ptr %7, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %30 = load float, ptr %5, align 4, !tbaa !20
  %31 = fpext float %30 to double
  %32 = call double @sin(double noundef %31) #6
  %33 = fptrunc double %32 to float
  store float %33, ptr %8, align 4, !tbaa !20
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.vrLocalPoint, ptr %34, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %35, i64 8, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %36 = getelementptr inbounds %struct.vrVec2, ptr %2, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !23
  %38 = load float, ptr %7, align 4, !tbaa !20
  %39 = getelementptr inbounds %struct.vrVec2, ptr %2, i32 0, i32 1
  %40 = load float, ptr %39, align 4, !tbaa !24
  %41 = load float, ptr %8, align 4, !tbaa !20
  %42 = fmul float %40, %41
  %43 = fneg float %42
  %44 = call float @llvm.fmuladd.f32(float %37, float %38, float %43)
  %45 = getelementptr inbounds %struct.vrVec2, ptr %2, i32 0, i32 0
  %46 = load float, ptr %45, align 4, !tbaa !23
  %47 = load float, ptr %8, align 4, !tbaa !20
  %48 = getelementptr inbounds %struct.vrVec2, ptr %2, i32 0, i32 1
  %49 = load float, ptr %48, align 4, !tbaa !24
  %50 = load float, ptr %7, align 4, !tbaa !20
  %51 = fmul float %49, %50
  %52 = call float @llvm.fmuladd.f32(float %46, float %47, float %51)
  %53 = call <2 x float> @vrVect(float noundef %44, float noundef %52)
  store <2 x float> %53, ptr %9, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.vrLocalPoint, ptr %54, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %55, ptr align 4 %2, i64 8, i1 false), !tbaa.struct !22
  %56 = load float, ptr %4, align 4, !tbaa !20
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.vrLocalPoint, ptr %57, i32 0, i32 0
  store float %56, ptr %58, align 8, !tbaa !21
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %59

59:                                               ; preds = %25, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %60 = load <2 x float>, ptr %2, align 4
  ret <2 x float> %60
}

; Function Attrs: nounwind
declare double @cos(double noundef) #3

; Function Attrs: nounwind
declare double @sin(double noundef) #3

declare <2 x float> @vrVect(float noundef, float noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 "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 = { "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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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/C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"vrLocalPoint", !11, i64 0, !12, i64 4, !6, i64 16}
!11 = !{!"float", !7, i64 0}
!12 = !{!"vrVec2", !11, i64 0, !11, i64 4}
!13 = !{!14, !11, i64 32}
!14 = !{!"vrRigidBody", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !15, i64 48, !17, i64 56, !6, i64 88, !18, i64 96, !12, i64 108, !19, i64 116, !6, i64 136, !16, i64 144}
!15 = !{!"vrCollisionGroup", !16, i64 0, !16, i64 4}
!16 = !{!"int", !7, i64 0}
!17 = !{!"vrMaterial", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}
!18 = !{!"vrColor", !11, i64 0, !11, i64 4, !11, i64 8}
!19 = !{!"vrOrientedBoundingBox", !12, i64 0, !12, i64 8}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 0}
!22 = !{i64 0, i64 4, !20, i64 4, i64 4, !20}
!23 = !{!12, !11, i64 0}
!24 = !{!12, !11, 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"

; Function Attrs: nounwind uwtable
define dso_local <2 x float> @vrGetLocalPoint(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 32
  %5 = load float, ptr %4, align 8, !tbaa !12
  %6 = load float, ptr %0, align 8, !tbaa !19
  %7 = fsub float %5, %6
  %8 = fcmp oeq float %7, 0.000000e+00
  br i1 %8, label %9, label %11

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  %.sroa.015.0.copyload = load <2 x float>, ptr %10, align 4
  br label %24

11:                                               ; preds = %1
  %12 = fpext float %7 to double
  %13 = tail call double @cos(double noundef %12) #4
  %14 = fptrunc double %13 to float
  %15 = tail call double @sin(double noundef %12) #4
  %16 = fptrunc double %15 to float
  %17 = getelementptr inbounds i8, ptr %0, i64 4
  %.sroa.015.0.copyload19 = load <2 x float>, ptr %17, align 4
  %.sroa.015.0.vec.extract = extractelement <2 x float> %.sroa.015.0.copyload19, i64 0
  %.sroa.015.4.vec.extract = extractelement <2 x float> %.sroa.015.0.copyload19, i64 1
  %18 = fneg float %.sroa.015.4.vec.extract
  %19 = fmul float %16, %18
  %20 = tail call float @llvm.fmuladd.f32(float %.sroa.015.0.vec.extract, float %14, float %19)
  %21 = fmul float %.sroa.015.4.vec.extract, %14
  %22 = tail call float @llvm.fmuladd.f32(float %.sroa.015.0.vec.extract, float %16, float %21)
  %23 = tail call <2 x float> @vrVect(float noundef %20, float noundef %22) #4
  store <2 x float> %23, ptr %17, align 4
  store float %5, ptr %0, align 8, !tbaa !19
  br label %24

24:                                               ; preds = %11, %9
  %.sroa.015.0 = phi <2 x float> [ %.sroa.015.0.copyload, %9 ], [ %23, %11 ]
  ret <2 x float> %.sroa.015.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

declare <2 x float> @vrVect(float noundef, float noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { "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 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, !11, i64 16}
!6 = !{!"vrLocalPoint", !7, i64 0, !10, i64 4, !11, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"vrVec2", !7, i64 0, !7, i64 4}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !7, i64 32}
!13 = !{!"vrRigidBody", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !14, i64 48, !16, i64 56, !11, i64 88, !17, i64 96, !10, i64 108, !18, i64 116, !11, i64 136, !15, i64 144}
!14 = !{!"vrCollisionGroup", !15, i64 0, !15, i64 4}
!15 = !{!"int", !8, i64 0}
!16 = !{!"vrMaterial", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!17 = !{!"vrColor", !7, i64 0, !7, i64 4, !7, i64 8}
!18 = !{!"vrOrientedBoundingBox", !10, i64 0, !10, i64 8}
!19 = !{!6, !7, i64 0}


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