; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qworld.ll (ZN6QWorld21AddCollisionExceptionEP5QBodyS1_)

; 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::pair" = type { ptr, ptr }
%"struct.std::pair.132" = type <{ %"struct.std::__detail::_Node_iterator", i8, [7 x i8] }>
%"struct.std::__detail::_Node_iterator" = type { %"struct.std::__detail::_Node_iterator_base" }
%"struct.std::__detail::_Node_iterator_base" = type { ptr }
%class.QWorld = type { %"class.std::vector", %"class.std::vector.0", %"class.std::vector.5", %"class.std::vector.10", %"class.std::vector.15", %"class.std::unordered_set", %"class.std::vector.25", ptr, i8, %struct.QVector, i8, i8, i32, float, float, float, i32, i32, %"class.std::vector.30" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<QJoint *, std::allocator<QJoint *>>::_Vector_impl" }
%"struct.std::_Vector_base<QJoint *, std::allocator<QJoint *>>::_Vector_impl" = type { %"struct.std::_Vector_base<QJoint *, std::allocator<QJoint *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QJoint *, std::allocator<QJoint *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<QSpring *, std::allocator<QSpring *>>::_Vector_impl" }
%"struct.std::_Vector_base<QSpring *, std::allocator<QSpring *>>::_Vector_impl" = type { %"struct.std::_Vector_base<QSpring *, std::allocator<QSpring *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QSpring *, std::allocator<QSpring *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<QRaycast *, std::allocator<QRaycast *>>::_Vector_impl" }
%"struct.std::_Vector_base<QRaycast *, std::allocator<QRaycast *>>::_Vector_impl" = type { %"struct.std::_Vector_base<QRaycast *, std::allocator<QRaycast *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QRaycast *, std::allocator<QRaycast *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<QGizmo *, std::allocator<QGizmo *>>::_Vector_impl" }
%"struct.std::_Vector_base<QGizmo *, std::allocator<QGizmo *>>::_Vector_impl" = type { %"struct.std::_Vector_base<QGizmo *, std::allocator<QGizmo *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QGizmo *, std::allocator<QGizmo *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.15" = type { %"struct.std::_Vector_base.16" }
%"struct.std::_Vector_base.16" = type { %"struct.std::_Vector_base<std::vector<QBody *>, std::allocator<std::vector<QBody *>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<QBody *>, std::allocator<std::vector<QBody *>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<QBody *>, std::allocator<std::vector<QBody *>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<QBody *>, std::allocator<std::vector<QBody *>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::unordered_set" = type { %"class.std::_Hashtable" }
%"class.std::_Hashtable" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::vector.25" = type { %"struct.std::_Vector_base.26" }
%"struct.std::_Vector_base.26" = type { %"struct.std::_Vector_base<QManifold, std::allocator<QManifold>>::_Vector_impl" }
%"struct.std::_Vector_base<QManifold, std::allocator<QManifold>>::_Vector_impl" = type { %"struct.std::_Vector_base<QManifold, std::allocator<QManifold>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QManifold, std::allocator<QManifold>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.QVector = type { float, float }
%"class.std::vector.30" = type { %"struct.std::_Vector_base.31" }
%"struct.std::_Vector_base.31" = type { %"struct.std::_Vector_base<QBody *, std::allocator<QBody *>>::_Vector_impl" }
%"struct.std::_Vector_base<QBody *, std::allocator<QBody *>>::_Vector_impl" = type { %"struct.std::_Vector_base<QBody *, std::allocator<QBody *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<QBody *, std::allocator<QBody *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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
define dso_local noundef ptr @_ZN6QWorld21AddCollisionExceptionEP5QBodyS1_(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.std::pair", align 8
  %8 = alloca %"struct.std::pair.132", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #3
  call void @_ZNSt4pairIP5QBodyS1_EC2IS1_S1_TnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES5_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp ult ptr %10, %11
  br i1 %12, label %13, label %18

13:                                               ; preds = %3
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  store ptr %14, ptr %15, align 8, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 1
  store ptr %16, ptr %17, align 8, !tbaa !11
  br label %23

18:                                               ; preds = %3
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  store ptr %19, ptr %20, align 8, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 1
  store ptr %21, ptr %22, align 8, !tbaa !11
  br label %23

23:                                               ; preds = %18, %13
  %24 = getelementptr inbounds %class.QWorld, ptr %9, i32 0, i32 5
  %25 = call { ptr, i8 } @_ZNSt13unordered_setISt4pairIP5QBodyS2_ENS1_12BodyPairHashENS1_13BodyPairEqualESaIS3_EE6insertERKS3_(ptr noundef nonnull align 8 dereferenceable(56) %24, ptr noundef nonnull align 8 dereferenceable(16) %7)
  %26 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 0
  %27 = extractvalue { ptr, i8 } %25, 0
  store ptr %27, ptr %26, align 8
  %28 = getelementptr inbounds { ptr, i8 }, ptr %8, i32 0, i32 1
  %29 = extractvalue { ptr, i8 } %25, 1
  store i8 %29, ptr %28, align 8
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #3
  ret ptr %9
}

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt13unordered_setISt4pairIP5QBodyS2_ENS1_12BodyPairHashENS1_13BodyPairEqualESaIS3_EE6insertERKS3_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !6, i64 0}
!10 = !{!"_ZTSSt4pairIP5QBodyS1_E", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}


; 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.std::pair" = type { ptr, ptr }

; 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
define dso_local noundef nonnull ptr @_ZN6QWorld21AddCollisionExceptionEP5QBodyS1_(ptr noundef nonnull returned align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %"struct.std::pair", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #3
  call void @_ZNSt4pairIP5QBodyS1_EC2IS1_S1_TnNSt9enable_ifIXsr6__and_ISt37__is_implicitly_default_constructibleIT_ES5_IT0_EEE5valueEbE4typeELb1EEEv(ptr noundef nonnull align 8 dereferenceable(16) %4)
  %5 = icmp ult ptr %1, %2
  %spec.select = select i1 %5, ptr %1, ptr %2
  %spec.select10 = select i1 %5, ptr %2, ptr %1
  store ptr %spec.select, ptr %4, align 8
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %spec.select10, ptr %6, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 120
  %8 = call { ptr, i8 } @_ZNSt13unordered_setISt4pairIP5QBodyS2_ENS1_12BodyPairHashENS1_13BodyPairEqualESaIS3_EE6insertERKS3_(ptr noundef nonnull align 8 dereferenceable(56) %7, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #3
  ret ptr %0
}

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt13unordered_setISt4pairIP5QBodyS2_ENS1_12BodyPairHashENS1_13BodyPairEqualESaIS3_EE6insertERKS3_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass