; LLVM IR from VTIvanov20/eight-ball-pool :: src (main)

; 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.Vector2 = type { float, float }
%struct.PhysicsVertexData = type { i32, [24 x %struct.Vector2], [24 x %struct.Vector2] }
%struct.Matrix2x2 = type { float, float, float, float }
%struct.PhysicsBodyData = type { i32, i8, %struct.Vector2, %struct.Vector2, %struct.Vector2, float, float, float, float, float, float, float, float, float, float, i8, i8, i8, %struct.PhysicsShape }
%struct.PhysicsShape = type { i32, ptr, %struct.PhysicsVertexData, float, %struct.Matrix2x2 }

@.str.9 = external hidden unnamed_addr constant [59 x i8], align 1

declare i32 @printf(ptr noundef, ...) #0

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden <2 x float> @_ZL14MathVector2Add7Vector2S_(<2 x float>, <2 x float>) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden <2 x float> @_ZL21MathMatVector2Product9Matrix2x27Vector2(<2 x float>, <2 x float>, <2 x float>) #5

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @GetPhysicsShapeVertex(ptr noundef %0, i32 noundef %1) #6 {
  %3 = alloca %struct.Vector2, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.PhysicsVertexData, align 4
  %7 = alloca %struct.Vector2, align 4
  %8 = alloca %struct.Vector2, align 4
  %9 = alloca %struct.Vector2, align 4
  %10 = alloca %struct.Matrix2x2, align 4
  %11 = alloca %struct.Vector2, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 4 %3, i8 0, i64 8, i1 false)
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %74

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.PhysicsBodyData, ptr %15, i32 0, i32 18
  %17 = getelementptr inbounds %struct.PhysicsShape, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !11
  switch i32 %18, label %72 [
    i32 0, label %19
    i32 1, label %50
  ]

19:                                               ; preds = %14
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.PhysicsBodyData, ptr %20, i32 0, i32 2
  %22 = getelementptr inbounds %struct.Vector2, ptr %21, i32 0, i32 0
  %23 = load float, ptr %22, align 8, !tbaa !20
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = sitofp i32 %24 to float
  %26 = fmul float 1.500000e+01, %25
  %27 = fmul float %26, 0x3F91DF46A0000000
  %28 = call float @cosf(float noundef %27) #8
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.PhysicsBodyData, ptr %29, i32 0, i32 18
  %31 = getelementptr inbounds %struct.PhysicsShape, ptr %30, i32 0, i32 3
  %32 = load float, ptr %31, align 4, !tbaa !21
  %33 = call float @llvm.fmuladd.f32(float %28, float %32, float %23)
  %34 = getelementptr inbounds %struct.Vector2, ptr %3, i32 0, i32 0
  store float %33, ptr %34, align 4, !tbaa !22
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.PhysicsBodyData, ptr %35, i32 0, i32 2
  %37 = getelementptr inbounds %struct.Vector2, ptr %36, i32 0, i32 1
  %38 = load float, ptr %37, align 4, !tbaa !23
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = sitofp i32 %39 to float
  %41 = fmul float 1.500000e+01, %40
  %42 = fmul float %41, 0x3F91DF46A0000000
  %43 = call float @sinf(float noundef %42) #8
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.PhysicsBodyData, ptr %44, i32 0, i32 18
  %46 = getelementptr inbounds %struct.PhysicsShape, ptr %45, i32 0, i32 3
  %47 = load float, ptr %46, align 4, !tbaa !21
  %48 = call float @llvm.fmuladd.f32(float %43, float %47, float %38)
  %49 = getelementptr inbounds %struct.Vector2, ptr %3, i32 0, i32 1
  store float %48, ptr %49, align 4, !tbaa !24
  br label %73

50:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 388, ptr %6) #8
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.PhysicsBodyData, ptr %51, i32 0, i32 18
  %53 = getelementptr inbounds %struct.PhysicsShape, ptr %52, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %53, i64 388, i1 false), !tbaa.struct !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.PhysicsBodyData, ptr %54, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %55, i64 8, i1 false), !tbaa.struct !27
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.PhysicsBodyData, ptr %56, i32 0, i32 18
  %58 = getelementptr inbounds %struct.PhysicsShape, ptr %57, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %58, i64 16, i1 false), !tbaa.struct !29
  %59 = getelementptr inbounds %struct.PhysicsVertexData, ptr %6, i32 0, i32 1
  %60 = load i32, ptr %5, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [24 x %struct.Vector2], ptr %59, i64 0, i64 %61
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %62, i64 8, i1 false), !tbaa.struct !27
  %63 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 0
  %64 = load <2 x float>, ptr %63, align 4
  %65 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %10, i32 0, i32 1
  %66 = load <2 x float>, ptr %65, align 4
  %67 = load <2 x float>, ptr %11, align 4
  %68 = call <2 x float> @_ZL21MathMatVector2Product9Matrix2x27Vector2(<2 x float> %64, <2 x float> %66, <2 x float> %67)
  store <2 x float> %68, ptr %9, align 4
  %69 = load <2 x float>, ptr %8, align 4
  %70 = load <2 x float>, ptr %9, align 4
  %71 = call <2 x float> @_ZL14MathVector2Add7Vector2S_(<2 x float> %69, <2 x float> %70)
  store <2 x float> %71, ptr %7, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 388, ptr %6) #8
  br label %73

72:                                               ; preds = %14
  br label %73

73:                                               ; preds = %72, %50, %19
  br label %76

74:                                               ; preds = %2
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %76

76:                                               ; preds = %74, %73
  %77 = load <2 x float>, ptr %3, align 4
  ret <2 x float> %77
}

; Function Attrs: nounwind
declare float @cosf(float noundef) #7

; Function Attrs: nounwind
declare float @sinf(float noundef) #7

attributes #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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { inlinehint 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 #6 = { 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 #7 = { 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 #8 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !17, i64 80}
!12 = !{!"_ZTS15PhysicsBodyData", !10, i64 0, !13, i64 4, !14, i64 8, !14, i64 16, !14, i64 24, !15, i64 32, !15, i64 36, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52, !15, i64 56, !15, i64 60, !15, i64 64, !15, i64 68, !13, i64 72, !13, i64 73, !13, i64 74, !16, i64 80}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS7Vector2", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"_ZTS12PhysicsShape", !17, i64 0, !6, i64 8, !18, i64 16, !15, i64 404, !19, i64 408}
!17 = !{!"_ZTS16PhysicsShapeType", !7, i64 0}
!18 = !{!"_ZTS17PhysicsVertexData", !10, i64 0, !7, i64 4, !7, i64 196}
!19 = !{!"_ZTS9Matrix2x2", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!20 = !{!12, !15, i64 8}
!21 = !{!12, !15, i64 484}
!22 = !{!14, !15, i64 0}
!23 = !{!12, !15, i64 12}
!24 = !{!14, !15, i64 4}
!25 = !{i64 0, i64 4, !9, i64 4, i64 192, !26, i64 196, i64 192, !26}
!26 = !{!7, !7, i64 0}
!27 = !{i64 0, i64 4, !28, i64 4, i64 4, !28}
!28 = !{!15, !15, i64 0}
!29 = !{i64 0, i64 4, !28, i64 4, i64 4, !28, i64 8, i64 4, !28, i64 12, i64 4, !28}


; 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.PhysicsVertexData = type { i32, [24 x %struct.Vector2], [24 x %struct.Vector2] }
%struct.Vector2 = type { float, float }

@.str.9 = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

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

; Function Attrs: mustprogress 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) #2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden <2 x float> @_ZL14MathVector2Add7Vector2S_(<2 x float>, <2 x float>) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden <2 x float> @_ZL21MathMatVector2Product9Matrix2x27Vector2(<2 x float>, <2 x float>, <2 x float>) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local <2 x float> @GetPhysicsShapeVertex(ptr noundef readonly %0, i32 noundef %1) local_unnamed_addr #4 {
  %3 = alloca %struct.PhysicsVertexData, align 4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %36, label %4

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = load i32, ptr %5, align 8, !tbaa !5
  switch i32 %6, label %38 [
    i32 0, label %7
    i32 1, label %27
  ]

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = sitofp i32 %1 to float
  %10 = fmul float %9, 1.500000e+01
  %11 = fmul float %10, 0x3F91DF46A0000000
  %12 = getelementptr inbounds i8, ptr %0, i64 484
  %13 = getelementptr inbounds i8, ptr %0, i64 12
  %14 = load float, ptr %8, align 8, !tbaa !18
  %15 = tail call float @cosf(float noundef %11) #7
  %16 = load float, ptr %12, align 4, !tbaa !19
  %17 = load float, ptr %13, align 4, !tbaa !20
  %18 = tail call float @sinf(float noundef %11) #7
  %19 = load float, ptr %12, align 4, !tbaa !19
  %20 = insertelement <2 x float> poison, float %15, i64 0
  %21 = insertelement <2 x float> %20, float %18, i64 1
  %22 = insertelement <2 x float> poison, float %16, i64 0
  %23 = insertelement <2 x float> %22, float %19, i64 1
  %24 = insertelement <2 x float> poison, float %14, i64 0
  %25 = insertelement <2 x float> %24, float %17, i64 1
  %26 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %21, <2 x float> %23, <2 x float> %25)
  br label %38

27:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 388, ptr nonnull %3) #7
  %28 = getelementptr inbounds i8, ptr %0, i64 96
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(388) %3, ptr noundef nonnull align 8 dereferenceable(388) %28, i64 388, i1 false), !tbaa.struct !21
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.03.0.copyload = load <2 x float>, ptr %29, align 8
  %30 = getelementptr inbounds i8, ptr %0, i64 488
  %.sroa.01.0.copyload = load <2 x float>, ptr %30, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 496
  %.sroa.2.0.copyload = load <2 x float>, ptr %.sroa.2.0..sroa_idx, align 8
  %31 = getelementptr inbounds i8, ptr %3, i64 4
  %32 = sext i32 %1 to i64
  %33 = getelementptr inbounds [24 x %struct.Vector2], ptr %31, i64 0, i64 %32
  %.sroa.0.0.copyload = load <2 x float>, ptr %33, align 4
  %34 = tail call <2 x float> @_ZL21MathMatVector2Product9Matrix2x27Vector2(<2 x float> %.sroa.01.0.copyload, <2 x float> %.sroa.2.0.copyload, <2 x float> %.sroa.0.0.copyload)
  %35 = tail call <2 x float> @_ZL14MathVector2Add7Vector2S_(<2 x float> %.sroa.03.0.copyload, <2 x float> %34)
  call void @llvm.lifetime.end.p0(i64 388, ptr nonnull %3) #7
  br label %38

36:                                               ; preds = %2
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  br label %38

38:                                               ; preds = %7, %27, %4, %36
  %.sroa.015.0 = phi <2 x float> [ zeroinitializer, %4 ], [ %35, %27 ], [ %26, %7 ], [ zeroinitializer, %36 ]
  ret <2 x float> %.sroa.015.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #5

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

attributes #0 = { nofree 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #4 = { 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 #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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, !14, i64 80}
!6 = !{!"_ZTS15PhysicsBodyData", !7, i64 0, !10, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !12, i64 68, !10, i64 72, !10, i64 73, !10, i64 74, !13, i64 80}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTS7Vector2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !8, i64 0}
!13 = !{!"_ZTS12PhysicsShape", !14, i64 0, !15, i64 8, !16, i64 16, !12, i64 404, !17, i64 408}
!14 = !{!"_ZTS16PhysicsShapeType", !8, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"_ZTS17PhysicsVertexData", !7, i64 0, !8, i64 4, !8, i64 196}
!17 = !{!"_ZTS9Matrix2x2", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!18 = !{!6, !12, i64 8}
!19 = !{!6, !12, i64 484}
!20 = !{!6, !12, i64 12}
!21 = !{i64 0, i64 4, !22, i64 4, i64 192, !23, i64 196, i64 192, !23}
!22 = !{!7, !7, i64 0}
!23 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalDCEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass