; LLVM IR from atlantis13579/Riemann :: Src/RigidBodyDynamics (KinematicsTree)

; 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.Riemann::KinematicsTree" = type { %"class.Riemann::KinematicsDriver", float, i8, %"class.std::__cxx11::basic_string", %"class.std::vector" }
%"class.Riemann::KinematicsDriver" = type { ptr, %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Riemann::KeyframeKinematics *, std::allocator<Riemann::KeyframeKinematics *>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::KeyframeKinematics *, std::allocator<Riemann::KeyframeKinematics *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::KeyframeKinematics *, std::allocator<Riemann::KeyframeKinematics *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::KeyframeKinematics *, std::allocator<Riemann::KeyframeKinematics *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Riemann::KeyframeKinematics" = type <{ %"class.Riemann::RigidBodyKinematics.base", [6 x i8], %"class.Riemann::KeyFrameAnimation", %"class.std::__cxx11::basic_string", i32, [4 x i8] }>
%"class.Riemann::RigidBodyKinematics.base" = type { %"class.Riemann::RigidBody.base" }
%"class.Riemann::RigidBody.base" = type <{ ptr, %"class.std::vector.3", i8, [7 x i8], i64, %"class.Maths::TVector3", %"class.Maths::Quaternion", %"class.Maths::TVector3", %"class.Maths::TVector3", %"class.Maths::TVector3", float, %"class.Maths::Matrix3", i16 }>
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::Geometry *, std::allocator<Riemann::Geometry *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.Maths::Quaternion" = type { float, float, float, float }
%"class.Maths::TVector3" = type { float, float, float }
%"class.Maths::Matrix3" = type { [3 x [3 x float]] }
%"class.Riemann::KeyFrameAnimation" = type <{ %"struct.Riemann::Timeline", %"struct.Riemann::Timeline.8", %"class.std::vector.9", %"class.std::vector.14", i8, [7 x i8] }>
%"struct.Riemann::Timeline" = type { float, i32, i8 }
%"struct.Riemann::Timeline.8" = type { float, i32, i8 }
%"class.std::vector.9" = type { %"struct.std::_Vector_base.10" }
%"struct.std::_Vector_base.10" = type { %"struct.std::_Vector_base<Riemann::Keyframe<Maths::TVector3<float>>, std::allocator<Riemann::Keyframe<Maths::TVector3<float>>>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::Keyframe<Maths::TVector3<float>>, std::allocator<Riemann::Keyframe<Maths::TVector3<float>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::Keyframe<Maths::TVector3<float>>, std::allocator<Riemann::Keyframe<Maths::TVector3<float>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::Keyframe<Maths::TVector3<float>>, std::allocator<Riemann::Keyframe<Maths::TVector3<float>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.14" = type { %"struct.std::_Vector_base.15" }
%"struct.std::_Vector_base.15" = type { %"struct.std::_Vector_base<Riemann::Keyframe<Maths::Quaternion>, std::allocator<Riemann::Keyframe<Maths::Quaternion>>>::_Vector_impl" }
%"struct.std::_Vector_base<Riemann::Keyframe<Maths::Quaternion>, std::allocator<Riemann::Keyframe<Maths::Quaternion>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Riemann::Keyframe<Maths::Quaternion>, std::allocator<Riemann::Keyframe<Maths::Quaternion>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Riemann::Keyframe<Maths::Quaternion>, std::allocator<Riemann::Keyframe<Maths::Quaternion>>>::_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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

; 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 zeroext i1 @_ZN7Riemann14KinematicsTree12BindGeometryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_8GeometryE(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2) #2 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %11

11:                                               ; preds = %32, %3
  %12 = load i64, ptr %8, align 8, !tbaa !9
  %13 = getelementptr inbounds %"class.Riemann::KinematicsTree", ptr %10, i32 0, i32 4
  %14 = call noundef i64 @_ZNKSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #5
  %15 = icmp ult i64 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  store i32 2, ptr %9, align 4
  br label %35

17:                                               ; preds = %11
  %18 = getelementptr inbounds %"class.Riemann::KinematicsTree", ptr %10, i32 0, i32 4
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %19) #5
  %21 = load ptr, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.Riemann::KeyframeKinematics", ptr %21, i32 0, i32 3
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = call noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32) %22, ptr noundef nonnull align 8 dereferenceable(32) %23) #5
  br i1 %24, label %25, label %31

25:                                               ; preds = %17
  %26 = getelementptr inbounds %"class.Riemann::KinematicsTree", ptr %10, i32 0, i32 4
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %26, i64 noundef %27) #5
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN7Riemann9RigidBody11AddGeometryEPNS_8GeometryE(ptr noundef nonnull align 8 dereferenceable(154) %29, ptr noundef %30)
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %35

31:                                               ; preds = %17
  br label %32

32:                                               ; preds = %31
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = add i64 %33, 1
  store i64 %34, ptr %8, align 8, !tbaa !9
  br label %11, !llvm.loop !11

35:                                               ; preds = %25, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %36 = load i32, ptr %9, align 4
  switch i32 %36, label %40 [
    i32 2, label %37
    i32 1, label %38
  ]

37:                                               ; preds = %35
  store i1 false, ptr %4, align 1
  br label %38

38:                                               ; preds = %37, %35
  %39 = load i1, ptr %4, align 1
  ret i1 %39

40:                                               ; preds = %35
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #3

declare void @_ZN7Riemann9RigidBody11AddGeometryEPNS_8GeometryE(ptr noundef nonnull align 8 dereferenceable(154), ptr noundef) #4

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

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7Riemann14KinematicsTree12BindGeometryERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPNS_8GeometryE(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2) local_unnamed_addr #1 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 80
  %5 = tail call noundef i64 @_ZNKSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  %.not14.not = icmp eq i64 %5, 0
  br i1 %.not14.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %3, %13
  %.0815 = phi i64 [ %14, %13 ], [ 0, %3 ]
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %.0815) #4
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 240
  %9 = tail call noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull align 8 dereferenceable(32) %1) #4
  br i1 %9, label %10, label %13

10:                                               ; preds = %.lr.ph
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %.0815) #4
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  tail call void @_ZN7Riemann9RigidBody11AddGeometryEPNS_8GeometryE(ptr noundef nonnull align 8 dereferenceable(154) %12, ptr noundef %2)
  br label %.loopexit

13:                                               ; preds = %.lr.ph
  %14 = add nuw i64 %.0815, 1
  %15 = tail call noundef i64 @_ZNKSt6vectorIPN7Riemann18KeyframeKinematicsESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  %.not = icmp ult i64 %14, %15
  br i1 %.not, label %.lr.ph, label %.loopexit, !llvm.loop !9

.loopexit:                                        ; preds = %13, %3, %10
  %.not11 = phi i1 [ true, %10 ], [ false, %3 ], [ false, %13 ]
  ret i1 %.not11
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZSteqIcEN9__gnu_cxx11__enable_ifIXsr9__is_charIT_EE7__valueEbE6__typeERKNSt7__cxx1112basic_stringIS2_St11char_traitsIS2_ESaIS2_EEESC_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

declare void @_ZN7Riemann9RigidBody11AddGeometryEPNS_8GeometryE(ptr noundef nonnull align 8 dereferenceable(154), ptr noundef) local_unnamed_addr #3

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 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 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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass