; LLVM IR from goldest-star/seawave-animation :: src/vcl/shape/hierarchy_mesh/hierarchy_mesh_drawable (hierarchy_mesh_drawable)

; 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.vcl::hierarchy_mesh_drawable" = type { %"class.std::map", %"class.std::vector" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, int>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<vcl::hierarchy_mesh_drawable_node, std::allocator<vcl::hierarchy_mesh_drawable_node>>::_Vector_impl" }
%"struct.std::_Vector_base<vcl::hierarchy_mesh_drawable_node, std::allocator<vcl::hierarchy_mesh_drawable_node>>::_Vector_impl" = type { %"struct.std::_Vector_base<vcl::hierarchy_mesh_drawable_node, std::allocator<vcl::hierarchy_mesh_drawable_node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vcl::hierarchy_mesh_drawable_node, std::allocator<vcl::hierarchy_mesh_drawable_node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.vcl::hierarchy_mesh_drawable_node" = type { %"struct.vcl::mesh_drawable", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"struct.vcl::affine_transform", %"struct.vcl::affine_transform" }
%"struct.vcl::mesh_drawable" = type { %"struct.vcl::mesh_drawable_gpu_data", %"struct.vcl::mesh_drawable_uniform", i32, i32 }
%"struct.vcl::mesh_drawable_gpu_data" = type { i32, i32, i32, i32, i32, i32, i32 }
%"struct.vcl::mesh_drawable_uniform" = type { %"struct.vcl::affine_transform", %"struct.vcl::buffer_stack", %"struct.vcl::shading_mesh", float }
%"struct.vcl::buffer_stack" = type { float, float, float }
%"struct.vcl::shading_mesh" = type { float, float, float, i32 }
%"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] }
%"struct.vcl::affine_transform" = type { %"struct.vcl::buffer_stack", %"struct.vcl::mat", float, %"struct.vcl::buffer_stack" }
%"struct.vcl::mat" = type { float, float, float, float, float, float, float, float, float }

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

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

; 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
define dso_local void @_ZN3vcl23hierarchy_mesh_drawable27set_shader_for_all_elementsEj(ptr noundef nonnull align 8 dereferenceable(72) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %8 = getelementptr inbounds %"struct.vcl::hierarchy_mesh_drawable", ptr %7, i32 0, i32 1
  %9 = call noundef i64 @_ZNKSt6vectorIN3vcl28hierarchy_mesh_drawable_nodeESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #2
  store i64 %9, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %22, %2
  %11 = load i64, ptr %6, align 8, !tbaa !11
  %12 = load i64, ptr %5, align 8, !tbaa !11
  %13 = icmp ult i64 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %25

15:                                               ; preds = %10
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = getelementptr inbounds %"struct.vcl::hierarchy_mesh_drawable", ptr %7, i32 0, i32 1
  %18 = load i64, ptr %6, align 8, !tbaa !11
  %19 = call noundef nonnull align 8 dereferenceable(328) ptr @_ZNSt6vectorIN3vcl28hierarchy_mesh_drawable_nodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %18) #2
  %20 = getelementptr inbounds %"struct.vcl::hierarchy_mesh_drawable_node", ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %"struct.vcl::mesh_drawable", ptr %20, i32 0, i32 2
  store i32 %16, ptr %21, align 4, !tbaa !13
  br label %22

22:                                               ; preds = %15
  %23 = load i64, ptr %6, align 8, !tbaa !11
  %24 = add i64 %23, 1
  store i64 %24, ptr %6, align 8, !tbaa !11
  br label %10, !llvm.loop !25

25:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 124}
!14 = !{!"_ZTSN3vcl28hierarchy_mesh_drawable_nodeE", !15, i64 0, !23, i64 136, !23, i64 168, !18, i64 200, !18, i64 264}
!15 = !{!"_ZTSN3vcl13mesh_drawableE", !16, i64 0, !17, i64 28, !10, i64 124, !10, i64 128}
!16 = !{!"_ZTSN3vcl22mesh_drawable_gpu_dataE", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!17 = !{!"_ZTSN3vcl21mesh_drawable_uniformE", !18, i64 0, !19, i64 64, !22, i64 76, !20, i64 92}
!18 = !{!"_ZTSN3vcl16affine_transformE", !19, i64 0, !21, i64 12, !20, i64 48, !19, i64 52}
!19 = !{!"_ZTSN3vcl12buffer_stackIfLm3EEE", !20, i64 0, !20, i64 4, !20, i64 8}
!20 = !{!"float", !7, i64 0}
!21 = !{!"_ZTSN3vcl3matILm3ELm3EEE", !20, i64 0, !20, i64 4, !20, i64 8, !20, i64 12, !20, i64 16, !20, i64 20, !20, i64 24, !20, i64 28, !20, i64 32}
!22 = !{!"_ZTSN3vcl12shading_meshE", !20, i64 0, !20, i64 4, !20, i64 8, !10, i64 12}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !24, i64 0, !12, i64 8, !7, i64 16}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"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 @_ZNKSt6vectorIN3vcl28hierarchy_mesh_drawable_nodeESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3vcl23hierarchy_mesh_drawable27set_shader_for_all_elementsEj(ptr noundef nonnull align 8 dereferenceable(72) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = tail call noundef i64 @_ZNKSt6vectorIN3vcl28hierarchy_mesh_drawable_nodeESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %3) #1
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.05 = phi i64 [ %7, %.lr.ph ], [ 0, %2 ]
  %5 = tail call noundef nonnull align 8 dereferenceable(328) ptr @_ZNSt6vectorIN3vcl28hierarchy_mesh_drawable_nodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef %.05) #1
  %6 = getelementptr inbounds i8, ptr %5, i64 124
  store i32 %1, ptr %6, align 4, !tbaa !5
  %7 = add nuw i64 %.05, 1
  %exitcond.not = icmp eq i64 %7, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !22
}

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

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 = { 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, !9, i64 124}
!6 = !{!"_ZTSN3vcl28hierarchy_mesh_drawable_nodeE", !7, i64 0, !18, i64 136, !18, i64 168, !13, i64 200, !13, i64 264}
!7 = !{!"_ZTSN3vcl13mesh_drawableE", !8, i64 0, !12, i64 28, !9, i64 124, !9, i64 128}
!8 = !{!"_ZTSN3vcl22mesh_drawable_gpu_dataE", !9, i64 0, !9, i64 4, !9, i64 8, !9, i64 12, !9, i64 16, !9, i64 20, !9, i64 24}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN3vcl21mesh_drawable_uniformE", !13, i64 0, !14, i64 64, !17, i64 76, !15, i64 92}
!13 = !{!"_ZTSN3vcl16affine_transformE", !14, i64 0, !16, i64 12, !15, i64 48, !14, i64 52}
!14 = !{!"_ZTSN3vcl12buffer_stackIfLm3EEE", !15, i64 0, !15, i64 4, !15, i64 8}
!15 = !{!"float", !10, i64 0}
!16 = !{!"_ZTSN3vcl3matILm3ELm3EEE", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !15, i64 20, !15, i64 24, !15, i64 28, !15, i64 32}
!17 = !{!"_ZTSN3vcl12shading_meshE", !15, i64 0, !15, i64 4, !15, i64 8, !9, i64 12}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !19, i64 0, !21, i64 8, !10, i64 16}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !20, i64 0}
!20 = !{!"any pointer", !10, i64 0}
!21 = !{!"long", !10, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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