; LLVM IR from wgtdkp/apollonia :: src/body.ll (ZN9apollonia11PolygonBodyC2EfRKSt6vectorINS_4Vec2ESaIS2_EE)

; 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.apollonia::Vec2" = type { float, float }
%"class.apollonia::PolygonBody" = type { %"class.apollonia::Body", %"class.std::vector" }
%"class.apollonia::Body" = type { ptr, float, float, float, float, %"struct.apollonia::Vec2", %"struct.apollonia::Vec2", %"struct.apollonia::Mat22", %"struct.apollonia::Vec2", float, %"struct.apollonia::Vec2", float, float, float }
%"struct.apollonia::Mat22" = type { %"struct.std::array" }
%"struct.std::array" = type { [2 x %"struct.apollonia::Vec2"] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<apollonia::Vec2, std::allocator<apollonia::Vec2>>::_Vector_impl" }
%"struct.std::_Vector_base<apollonia::Vec2, std::allocator<apollonia::Vec2>>::_Vector_impl" = type { %"struct.std::_Vector_base<apollonia::Vec2, std::allocator<apollonia::Vec2>>::_Vector_impl_data" }
%"struct.std::_Vector_base<apollonia::Vec2, std::allocator<apollonia::Vec2>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTVN9apollonia11PolygonBodyE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9apollonia4Body11set_inertiaEf(ptr noundef nonnull align 8 dereferenceable(88), float noundef) #0 align 2

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9apollonia11PolygonBodyC2EfRKSt6vectorINS_4Vec2ESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(112) %0, float noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"struct.apollonia::Vec2", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = load float, ptr %5, align 4, !tbaa !9
  call void @_ZN9apollonia4BodyC2Ef(ptr noundef nonnull align 8 dereferenceable(88) %10, float noundef %11)
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN9apollonia11PolygonBodyE, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.apollonia::PolygonBody", ptr %10, i32 0, i32 1
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 8 dereferenceable(24) %13)
          to label %14 unwind label %23

14:                                               ; preds = %3
  %15 = load float, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = invoke noundef float @_ZN9apolloniaL14PolygonInertiaEfRKSt6vectorINS_4Vec2ESaIS1_EE(float noundef %15, ptr noundef nonnull align 8 dereferenceable(24) %16)
          to label %18 unwind label %27

18:                                               ; preds = %14
  call void @_ZN9apollonia4Body11set_inertiaEf(ptr noundef nonnull align 8 dereferenceable(88) %10, float noundef %17)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = invoke <2 x float> @_ZN9apolloniaL15PolygonCentroidERKSt6vectorINS_4Vec2ESaIS1_EE(ptr noundef nonnull align 8 dereferenceable(24) %19)
          to label %21 unwind label %31

21:                                               ; preds = %18
  store <2 x float> %20, ptr %9, align 4
  invoke void @_ZN9apollonia4Body12set_centroidERKNS_4Vec2E(ptr noundef nonnull align 8 dereferenceable(88) %10, ptr noundef nonnull align 4 dereferenceable(8) %9)
          to label %22 unwind label %31

22:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void

23:                                               ; preds = %3
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %7, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %8, align 4
  br label %36

27:                                               ; preds = %14
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %7, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %8, align 4
  br label %35

31:                                               ; preds = %21, %18
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %7, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %35

35:                                               ; preds = %31, %27
  call void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #4
  br label %36

36:                                               ; preds = %35, %23
  call void @_ZN9apollonia4BodyD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %10) #4
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %7, align 8
  %39 = load i32, ptr %8, align 4
  %40 = insertvalue { ptr, i32 } poison, ptr %38, 0
  %41 = insertvalue { ptr, i32 } %40, i32 %39, 1
  resume { ptr, i32 } %41
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9apollonia4BodyC2Ef(ptr noundef nonnull align 8 dereferenceable(88), float noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare hidden noundef float @_ZN9apolloniaL14PolygonInertiaEfRKSt6vectorINS_4Vec2ESaIS1_EE(float noundef, ptr noundef nonnull align 8 dereferenceable(24)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9apollonia4Body12set_centroidERKNS_4Vec2E(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress uwtable
declare hidden <2 x float> @_ZN9apolloniaL15PolygonCentroidERKSt6vectorINS_4Vec2ESaIS1_EE(ptr noundef nonnull align 8 dereferenceable(24)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9apollonia4BodyD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #0 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !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, !12, i64 0}
!12 = !{!"vtable pointer", !8, 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"

%"struct.apollonia::Vec2" = type { float, float }

@_ZTVN9apollonia11PolygonBodyE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9apollonia4Body11set_inertiaEf(ptr noundef nonnull align 8 dereferenceable(88), float noundef) local_unnamed_addr #0 align 2

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9apollonia11PolygonBodyC2EfRKSt6vectorINS_4Vec2ESaIS2_EE(ptr noundef nonnull align 8 dereferenceable(112) %0, float noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"struct.apollonia::Vec2", align 8
  tail call void @_ZN9apollonia4BodyC2Ef(ptr noundef nonnull align 8 dereferenceable(88) %0, float noundef %1)
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN9apollonia11PolygonBodyE, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  invoke void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %2)
          to label %6 unwind label %11

6:                                                ; preds = %3
  %7 = invoke noundef float @_ZN9apolloniaL14PolygonInertiaEfRKSt6vectorINS_4Vec2ESaIS1_EE(float noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2)
          to label %8 unwind label %13

8:                                                ; preds = %6
  tail call void @_ZN9apollonia4Body11set_inertiaEf(ptr noundef nonnull align 8 dereferenceable(88) %0, float noundef %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %9 = invoke <2 x float> @_ZN9apolloniaL15PolygonCentroidERKSt6vectorINS_4Vec2ESaIS1_EE(ptr noundef nonnull align 8 dereferenceable(24) %2)
          to label %10 unwind label %15

10:                                               ; preds = %8
  store <2 x float> %9, ptr %4, align 8
  call void @_ZN9apollonia4Body12set_centroidERKNS_4Vec2E(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret void

11:                                               ; preds = %3
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %18

13:                                               ; preds = %6
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %17

15:                                               ; preds = %8
  %16 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %17

17:                                               ; preds = %15, %13
  %.pn = phi { ptr, i32 } [ %16, %15 ], [ %14, %13 ]
  tail call void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  br label %18

18:                                               ; preds = %17, %11
  %.pn.pn = phi { ptr, i32 } [ %.pn, %17 ], [ %12, %11 ]
  tail call void @_ZN9apollonia4BodyD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) #4
  resume { ptr, i32 } %.pn.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9apollonia4BodyC2Ef(ptr noundef nonnull align 8 dereferenceable(88), float noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare hidden noundef float @_ZN9apolloniaL14PolygonInertiaEfRKSt6vectorINS_4Vec2ESaIS1_EE(float noundef, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9apollonia4Body12set_centroidERKNS_4Vec2E(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare hidden <2 x float> @_ZN9apolloniaL15PolygonCentroidERKSt6vectorINS_4Vec2ESaIS1_EE(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN9apollonia4Vec2ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9apollonia4BodyD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #0 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !6, i64 0}
!6 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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