; LLVM IR from Lut1n/ImpGears :: src/ImpGears/Geometry/Geometry.ll (ZN3imp8Geometry4rotXEf)

; 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.imp::Matrix3" = type { %"class.imp::Matrix.base", [4 x i8] }
%"class.imp::Matrix.base" = type <{ %"class.imp::Object", [9 x float] }>
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.imp::Geometry" = type <{ %"class.imp::Object", i32, [4 x i8], %"class.std::vector", %"class.std::vector.0", %"class.std::vector.0", %"class.std::vector.0", %"class.std::vector.5", i8, i8, i8, i8, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_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<imp::Vec3, std::allocator<imp::Vec3>>::_Vector_impl" }
%"struct.std::_Vector_base<imp::Vec3, std::allocator<imp::Vec3>>::_Vector_impl" = type { %"struct.std::_Vector_base<imp::Vec3, std::allocator<imp::Vec3>>::_Vector_impl_data" }
%"struct.std::_Vector_base<imp::Vec3, std::allocator<imp::Vec3>>::_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<imp::Vec<2, float>, std::allocator<imp::Vec<2, float>>>::_Vector_impl" }
%"struct.std::_Vector_base<imp::Vec<2, float>, std::allocator<imp::Vec<2, float>>>::_Vector_impl" = type { %"struct.std::_Vector_base<imp::Vec<2, float>, std::allocator<imp::Vec<2, float>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<imp::Vec<2, float>, std::allocator<imp::Vec<2, float>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

declare i32 @__gxx_personality_v0(...)

; 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 @_ZNKSt6vectorIN3imp4Vec3ESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(36) ptr @_ZNSt6vectorIN3imp4Vec3ESaIS1_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 void @_ZN3imp8Geometry4rotXEf(ptr noundef nonnull align 8 dereferenceable(156) %0, float noundef %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  %6 = alloca %"class.imp::Matrix3", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %10

10:                                               ; preds = %25, %2
  %11 = load i32, ptr %5, align 4, !tbaa !11
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds %"class.imp::Geometry", ptr %9, i32 0, i32 4
  %14 = call noundef i64 @_ZNKSt6vectorIN3imp4Vec3ESaIS1_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 = %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %32

17:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 64, ptr %6) #5
  %18 = load float, ptr %4, align 4, !tbaa !9
  call void @_ZN3imp7Matrix39rotationXEf(ptr dead_on_unwind writable sret(%"class.imp::Matrix3") align 8 %6, float noundef %18)
  %19 = getelementptr inbounds %"class.imp::Geometry", ptr %9, i32 0, i32 4
  %20 = load i32, ptr %5, align 4, !tbaa !11
  %21 = zext i32 %20 to i64
  %22 = call noundef nonnull align 8 dereferenceable(36) ptr @_ZNSt6vectorIN3imp4Vec3ESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %21) #5
  %23 = invoke noundef nonnull align 8 dereferenceable(36) ptr @_ZN3impmLILi3EfEERNS_3VecIXT_ET0_EES4_RKNS_6MatrixIXT_EXT_ES2_EE(ptr noundef nonnull align 8 dereferenceable(36) %22, ptr noundef nonnull align 8 dereferenceable(60) %6)
          to label %24 unwind label %28

24:                                               ; preds = %17
  call void @_ZN3imp7Matrix3D1Ev(ptr noundef nonnull align 8 dereferenceable(60) %6) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %6) #5
  br label %25

25:                                               ; preds = %24
  %26 = load i32, ptr %5, align 4, !tbaa !11
  %27 = add i32 %26, 1
  store i32 %27, ptr %5, align 4, !tbaa !11
  br label %10, !llvm.loop !13

28:                                               ; preds = %17
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %7, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %8, align 4
  call void @_ZN3imp7Matrix3D1Ev(ptr noundef nonnull align 8 dereferenceable(60) %6) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %33

32:                                               ; preds = %16
  ret void

33:                                               ; preds = %28
  %34 = load ptr, ptr %7, align 8
  %35 = load i32, ptr %8, align 4
  %36 = insertvalue { ptr, i32 } poison, ptr %34, 0
  %37 = insertvalue { ptr, i32 } %36, i32 %35, 1
  resume { ptr, i32 } %37
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(36) ptr @_ZN3impmLILi3EfEERNS_3VecIXT_ET0_EES4_RKNS_6MatrixIXT_EXT_ES2_EE(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(60)) #2

declare void @_ZN3imp7Matrix39rotationXEf(ptr dead_on_unwind writable sret(%"class.imp::Matrix3") align 8, float noundef) #3

; Function Attrs: nounwind
declare void @_ZN3imp7Matrix3D1Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #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 = { "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 "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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"class.imp::Matrix3" = type { %"class.imp::Matrix.base", [4 x i8] }
%"class.imp::Matrix.base" = type <{ %"class.imp::Object", [9 x float] }>
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN3imp4Vec3ESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

; 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 void @_ZN3imp8Geometry4rotXEf(ptr noundef nonnull align 8 dereferenceable(156) %0, float noundef %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.imp::Matrix3", align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  %5 = tail call noundef i64 @_ZNKSt6vectorIN3imp4Vec3ESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #5
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %9, %2
  ret void

.lr.ph:                                           ; preds = %2, %9
  %6 = phi i64 [ %11, %9 ], [ 0, %2 ]
  %.07 = phi i32 [ %10, %9 ], [ 0, %2 ]
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #5
  call void @_ZN3imp7Matrix39rotationXEf(ptr dead_on_unwind nonnull writable sret(%"class.imp::Matrix3") align 8 %3, float noundef %1)
  %7 = call noundef nonnull align 8 dereferenceable(36) ptr @_ZNSt6vectorIN3imp4Vec3ESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %6) #5
  %8 = invoke noundef nonnull align 8 dereferenceable(36) ptr @_ZN3impmLILi3EfEERNS_3VecIXT_ET0_EES4_RKNS_6MatrixIXT_EXT_ES2_EE(ptr noundef nonnull align 8 dereferenceable(36) %7, ptr noundef nonnull align 8 dereferenceable(60) %3)
          to label %9 unwind label %14

9:                                                ; preds = %.lr.ph
  call void @_ZN3imp7Matrix3D1Ev(ptr noundef nonnull align 8 dereferenceable(60) %3) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #5
  %10 = add i32 %.07, 1
  %11 = zext i32 %10 to i64
  %12 = call noundef i64 @_ZNKSt6vectorIN3imp4Vec3ESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #5
  %13 = icmp ugt i64 %12, %11
  br i1 %13, label %.lr.ph, label %._crit_edge, !llvm.loop !5

14:                                               ; preds = %.lr.ph
  %15 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3imp7Matrix3D1Ev(ptr noundef nonnull align 8 dereferenceable(60) %3) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #5
  resume { ptr, i32 } %15
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(36) ptr @_ZN3impmLILi3EfEERNS_3VecIXT_ET0_EES4_RKNS_6MatrixIXT_EXT_ES2_EE(ptr noundef nonnull align 8 dereferenceable(36), ptr noundef nonnull align 8 dereferenceable(60)) local_unnamed_addr #2

declare void @_ZN3imp7Matrix39rotationXEf(ptr dead_on_unwind writable sret(%"class.imp::Matrix3") align 8, float noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZN3imp7Matrix3D1Ev(ptr noundef nonnull align 8 dereferenceable(60)) unnamed_addr #4

attributes #0 = { mustprogress 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 = { "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 "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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