; LLVM IR from wgtdkp/apollonia :: src/collision.ll (ZN9apollonia7ContactC2ERKNS_11PolygonBodyEm)

; 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.std::array.6" = type { [2 x i64] }
%"struct.apollonia::Vec2" = type { float, float }
%"struct.apollonia::Contact" = type { %"struct.apollonia::Vec2", %"struct.apollonia::Vec2", %"struct.apollonia::Vec2", %"struct.std::array.5", %"struct.std::array.6", float, float, float, float, float, float }
%"struct.std::array.5" = type { [2 x i8] }

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

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

; 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: mustprogress uwtable
define dso_local void @_ZN9apollonia7ContactC2ERKNS_11PolygonBodyEm(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(112) %1, i64 noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca %"struct.std::array.6", align 8
  %8 = alloca i8, align 1
  %9 = alloca %"struct.apollonia::Vec2", align 4
  %10 = alloca %"struct.apollonia::Vec2", align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8
  %12 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 0
  call void @_ZN9apollonia4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %12)
  %13 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 1
  call void @_ZN9apollonia4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %13)
  %14 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 2
  call void @_ZN9apollonia4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %14)
  %15 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 3
  %16 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 4
  %17 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 6
  store float 0.000000e+00, ptr %17, align 4, !tbaa !11
  %18 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 7
  store float 0.000000e+00, ptr %18, align 8, !tbaa !17
  %19 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 8
  store float 0.000000e+00, ptr %19, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #6
  %20 = getelementptr inbounds %"struct.std::array.6", ptr %7, i32 0, i32 0
  %21 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %21, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds i64, ptr %20, i64 1
  %23 = load i64, ptr %6, align 8, !tbaa !9
  store i64 %23, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %24, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #6
  %25 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 3
  %26 = call noundef ptr @_ZNSt5arrayIbLm2EE5beginEv(ptr noundef nonnull align 1 dereferenceable(2) %25) #7
  %27 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 3
  %28 = call noundef ptr @_ZNSt5arrayIbLm2EE3endEv(ptr noundef nonnull align 1 dereferenceable(2) %27) #7
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #6
  store i8 0, ptr %8, align 1, !tbaa !21
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef %26, ptr noundef %28, ptr noundef nonnull align 1 dereferenceable(1) %8)
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = call <2 x float> @_ZNK9apollonia11PolygonBodyixEm(ptr noundef nonnull align 8 dereferenceable(112) %30, i64 noundef %31)
  store <2 x float> %32, ptr %10, align 4
  %33 = call <2 x float> @_ZNK9apollonia4Body12LocalToWorldERKNS_4Vec2E(ptr noundef nonnull align 8 dereferenceable(88) %29, ptr noundef nonnull align 4 dereferenceable(8) %10)
  store <2 x float> %33, ptr %9, align 4
  %34 = getelementptr inbounds %"struct.apollonia::Contact", ptr %11, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %34, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN9apollonia4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8)) unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #4

; Function Attrs: mustprogress nounwind willreturn memory(none) uwtable
declare dso_local noundef ptr @_ZNSt5arrayIbLm2EE5beginEv(ptr noundef nonnull align 1 dereferenceable(2)) #5 align 2

; Function Attrs: mustprogress nounwind willreturn memory(none) uwtable
declare dso_local noundef ptr @_ZNSt5arrayIbLm2EE3endEv(ptr noundef nonnull align 1 dereferenceable(2)) #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { inlinehint 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 #5 = { mustprogress nounwind willreturn memory(none) 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 52}
!12 = !{!"_ZTSN9apollonia7ContactE", !13, i64 0, !13, i64 8, !13, i64 16, !15, i64 24, !16, i64 32, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68}
!13 = !{!"_ZTSN9apollonia4Vec2E", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"_ZTSSt5arrayIbLm2EE", !7, i64 0}
!16 = !{!"_ZTSSt5arrayImLm2EE", !7, i64 0}
!17 = !{!12, !14, i64 56}
!18 = !{!12, !14, i64 60}
!19 = !{i64 0, i64 16, !20}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !22, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{i64 0, i64 4, !24, i64 4, i64 4, !24}
!24 = !{!14, !14, 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 }

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9apollonia7ContactC2ERKNS_11PolygonBodyEm(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(112) %1, i64 noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca i8, align 1
  %5 = alloca %"struct.apollonia::Vec2", align 8
  tail call void @_ZN9apollonia4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN9apollonia4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZN9apollonia4Vec2C2Ev(ptr noundef nonnull align 4 dereferenceable(8) %7)
  %8 = getelementptr inbounds i8, ptr %0, i64 52
  store <2 x float> zeroinitializer, ptr %8, align 4, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 60
  store float 0.000000e+00, ptr %9, align 4, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %2, ptr %10, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 40
  store i64 %2, ptr %.sroa.4.0..sroa_idx, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = tail call noundef ptr @_ZNSt5arrayIbLm2EE5beginEv(ptr noundef nonnull align 1 dereferenceable(2) %11) #5
  %13 = tail call noundef ptr @_ZNSt5arrayIbLm2EE3endEv(ptr noundef nonnull align 1 dereferenceable(2) %11) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #6
  store i8 0, ptr %4, align 1, !tbaa !15
  call void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef %12, ptr noundef %13, ptr noundef nonnull align 1 dereferenceable(1) %4)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %14 = call <2 x float> @_ZNK9apollonia11PolygonBodyixEm(ptr noundef nonnull align 8 dereferenceable(112) %1, i64 noundef %2)
  store <2 x float> %14, ptr %5, align 8
  %15 = call <2 x float> @_ZNK9apollonia4Body12LocalToWorldERKNS_4Vec2E(ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 4 dereferenceable(8) %5)
  store <2 x float> %15, ptr %0, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPbbEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
declare dso_local noundef ptr @_ZNSt5arrayIbLm2EE5beginEv(ptr noundef nonnull align 1 dereferenceable(2)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none) uwtable
declare dso_local noundef ptr @_ZNSt5arrayIbLm2EE3endEv(ptr noundef nonnull align 1 dereferenceable(2)) local_unnamed_addr #4 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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 = { inlinehint 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 = { mustprogress nofree nosync nounwind willreturn memory(none) 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 #5 = { nounwind 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 60}
!10 = !{!"_ZTSN9apollonia7ContactE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 32, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !6, i64 64, !6, i64 68}
!11 = !{!"_ZTSN9apollonia4Vec2E", !6, i64 0, !6, i64 4}
!12 = !{!"_ZTSSt5arrayIbLm2EE", !7, i64 0}
!13 = !{!"_ZTSSt5arrayImLm2EE", !7, i64 0}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"bool", !7, i64 0}


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