; LLVM IR from St0wy/StowyPhysicsEngine :: StowyPhysicsEngine/src/collision (Simplex)

; 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"

%"class.std::initializer_list" = type { ptr, i64 }
%"struct.stw::Simplex" = type { %"struct.std::array", i64 }
%"struct.std::array" = type { [3 x %"struct.stw::Vector2"] }
%"struct.stw::Vector2" = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN3stw7SimplexaSESt16initializer_listINS_7Vector2EE(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr %1, i64 %2) #0 align 2 {
  %4 = alloca %"class.std::initializer_list", align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = getelementptr inbounds { ptr, i64 }, ptr %4, i32 0, i32 0
  store ptr %1, ptr %7, align 8
  %8 = getelementptr inbounds { ptr, i64 }, ptr %4, i32 0, i32 1
  store i64 %2, ptr %8, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %10 = call noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #5
  store ptr %10, ptr %6, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %23, %3
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = call noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #5
  %14 = icmp ne ptr %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %26

16:                                               ; preds = %11
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.stw::Simplex", ptr %9, i32 0, i32 0
  %19 = call noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call noundef i64 @_ZSt8distanceIPKN3stw7Vector2EENSt15iterator_traitsIT_E15difference_typeES5_S5_(ptr noundef %19, ptr noundef %20)
  %22 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN3stw7Vector2ELm3EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %18, i64 noundef %21) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %17, i64 8, i1 false), !tbaa.struct !9
  br label %23

23:                                               ; preds = %16
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.stw::Vector2", ptr %24, i32 1
  store ptr %25, ptr %6, align 8, !tbaa !5
  br label %11, !llvm.loop !12

26:                                               ; preds = %15
  %27 = call noundef i64 @_ZNKSt16initializer_listIN3stw7Vector2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #5
  %28 = getelementptr inbounds %"struct.stw::Simplex", ptr %9, i32 0, i32 1
  store i64 %27, ptr %28, align 8, !tbaa !14
  ret ptr %9
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE3endEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN3stw7Vector2ELm3EEixEm(ptr noundef nonnull align 4 dereferenceable(24), i64 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIPKN3stw7Vector2EENSt15iterator_traitsIT_E15difference_typeES5_S5_(ptr noundef, ptr noundef) #3

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt16initializer_listIN3stw7Vector2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !17, i64 24}
!15 = !{!"_ZTSN3stw7SimplexE", !16, i64 0, !17, i64 24}
!16 = !{!"_ZTSSt5arrayIN3stw7Vector2ELm3EE", !7, i64 0}
!17 = !{!"long", !7, 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"

%"class.std::initializer_list" = type { ptr, i64 }

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN3stw7SimplexaSESt16initializer_listINS_7Vector2EE(ptr noundef nonnull returned align 8 dereferenceable(32) %0, ptr %1, i64 %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"class.std::initializer_list", align 8
  store ptr %1, ptr %4, align 8
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %2, ptr %5, align 8
  %6 = call noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  %7 = call noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  %.not5 = icmp eq ptr %6, %7
  br i1 %.not5, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  %8 = call noundef i64 @_ZNKSt16initializer_listIN3stw7Vector2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %8, ptr %9, align 8, !tbaa !5
  ret ptr %0

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.06 = phi ptr [ %14, %.lr.ph ], [ %6, %3 ]
  %10 = call noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  %11 = call noundef i64 @_ZSt8distanceIPKN3stw7Vector2EENSt15iterator_traitsIT_E15difference_typeES5_S5_(ptr noundef %10, ptr noundef %.06)
  %12 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN3stw7Vector2ELm3EEixEm(ptr noundef nonnull align 4 dereferenceable(24) %0, i64 noundef %11) #3
  %13 = load i64, ptr %.06, align 4
  store i64 %13, ptr %12, align 4
  %14 = getelementptr inbounds i8, ptr %.06, i64 8
  %15 = call noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE3endEv(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  %.not = icmp eq ptr %14, %15
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt16initializer_listIN3stw7Vector2EE3endEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt5arrayIN3stw7Vector2ELm3EEixEm(ptr noundef nonnull align 4 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZSt8distanceIPKN3stw7Vector2EENSt15iterator_traitsIT_E15difference_typeES5_S5_(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt16initializer_listIN3stw7Vector2EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

attributes #0 = { 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 #1 = { 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 #2 = { 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 #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, !10, i64 24}
!6 = !{!"_ZTSN3stw7SimplexE", !7, i64 0, !10, i64 24}
!7 = !{!"_ZTSSt5arrayIN3stw7Vector2ELm3EE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass