; LLVM IR from drohmer/cgp :: library/cgp/16_drawable/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.cgp::hierarchy_mesh_drawable" = type { %"class.std::vector", %"class.std::map" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<cgp::hierarchy_mesh_drawable_node, std::allocator<cgp::hierarchy_mesh_drawable_node>>::_Vector_impl" }
%"struct.std::_Vector_base<cgp::hierarchy_mesh_drawable_node, std::allocator<cgp::hierarchy_mesh_drawable_node>>::_Vector_impl" = type { %"struct.std::_Vector_base<cgp::hierarchy_mesh_drawable_node, std::allocator<cgp::hierarchy_mesh_drawable_node>>::_Vector_impl_data" }
%"struct.std::_Vector_base<cgp::hierarchy_mesh_drawable_node, std::allocator<cgp::hierarchy_mesh_drawable_node>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"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 }
%"struct.cgp::hierarchy_mesh_drawable_node" = type { %"struct.cgp::mesh_drawable", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"struct.cgp::affine_rts" }
%"struct.cgp::mesh_drawable" = type <{ %"struct.cgp::opengl_shader_structure", %"struct.cgp::opengl_texture_image_structure", %"class.std::map.3", %"struct.cgp::opengl_vbo_structure", %"struct.cgp::opengl_vbo_structure", %"struct.cgp::opengl_vbo_structure", %"struct.cgp::opengl_vbo_structure", %"class.std::vector.8", %"struct.cgp::opengl_ebo_structure", i32, %"struct.cgp::affine", %"struct.cgp::affine_rts", %"struct.cgp::matrix_stack", %"struct.cgp::material_mesh_drawable_phong", [4 x i8] }>
%"struct.cgp::opengl_shader_structure" = type { i32 }
%"struct.cgp::opengl_texture_image_structure" = type { i32, i32, i32, i32, i32 }
%"class.std::map.3" = type { %"class.std::_Rb_tree.4" }
%"class.std::_Rb_tree.4" = type { %"struct.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, cgp::opengl_texture_image_structure>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, cgp::opengl_texture_image_structure>>, 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>, cgp::opengl_texture_image_structure>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, cgp::opengl_texture_image_structure>>, std::less<std::__cxx11::basic_string<char>>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.cgp::opengl_vbo_structure" = type { %"struct.cgp::opengl_gpu_buffer", i32 }
%"struct.cgp::opengl_gpu_buffer" = type { i32, i32, i32, %"struct.cgp::opengl_gpu_buffer_details" }
%"struct.cgp::opengl_gpu_buffer_details" = type { i32, i32, i32 }
%"class.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<cgp::opengl_vbo_structure, std::allocator<cgp::opengl_vbo_structure>>::_Vector_impl" }
%"struct.std::_Vector_base<cgp::opengl_vbo_structure, std::allocator<cgp::opengl_vbo_structure>>::_Vector_impl" = type { %"struct.std::_Vector_base<cgp::opengl_vbo_structure, std::allocator<cgp::opengl_vbo_structure>>::_Vector_impl_data" }
%"struct.std::_Vector_base<cgp::opengl_vbo_structure, std::allocator<cgp::opengl_vbo_structure>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.cgp::opengl_ebo_structure" = type { %"struct.cgp::opengl_gpu_buffer" }
%"struct.cgp::affine" = type { %"struct.cgp::rotation_transform", %"struct.cgp::numarray_stack.13", float, %"struct.cgp::numarray_stack.13" }
%"struct.cgp::rotation_transform" = type { %"struct.cgp::quaternion" }
%"struct.cgp::quaternion" = type { %"struct.cgp::numarray_stack" }
%"struct.cgp::numarray_stack" = type { float, float, float, float }
%"struct.cgp::numarray_stack.13" = type { float, float, float }
%"struct.cgp::matrix_stack" = type { %"struct.cgp::numarray_stack.14" }
%"struct.cgp::numarray_stack.14" = type { %"struct.cgp::numarray_stack", %"struct.cgp::numarray_stack", %"struct.cgp::numarray_stack", %"struct.cgp::numarray_stack" }
%"struct.cgp::material_mesh_drawable_phong" = type <{ %"struct.cgp::numarray_stack.13", float, %"struct.cgp::phong_parameters", %"struct.cgp::texture_settings_parameters", i8 }>
%"struct.cgp::phong_parameters" = type { float, float, float, float }
%"struct.cgp::texture_settings_parameters" = type { i8, i8, i8 }
%"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.cgp::affine_rts" = type { %"struct.cgp::rotation_transform", %"struct.cgp::numarray_stack.13", float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN3cgp28hierarchy_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
declare dso_local noundef nonnull align 8 dereferenceable(512) ptr @_ZNKSt6vectorIN3cgp28hierarchy_mesh_drawable_nodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3cgp4drawERKNS_23hierarchy_mesh_drawableERKNS_29environment_generic_structureEibRKNS_25uniform_generic_structureE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2, i1 noundef zeroext %3, ptr noundef nonnull align 8 dereferenceable(384) %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  %13 = zext i1 %3 to i8
  store i8 %13, ptr %9, align 1, !tbaa !11
  store ptr %4, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.cgp::hierarchy_mesh_drawable", ptr %14, i32 0, i32 0
  %16 = call noundef i64 @_ZNKSt6vectorIN3cgp28hierarchy_mesh_drawable_nodeESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #4
  %17 = trunc i64 %16 to i32
  store i32 %17, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %35, %5
  %19 = load i32, ptr %12, align 4, !tbaa !9
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %38

23:                                               ; preds = %18
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.cgp::hierarchy_mesh_drawable", ptr %24, i32 0, i32 0
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(512) ptr @_ZNKSt6vectorIN3cgp28hierarchy_mesh_drawable_nodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27) #4
  %29 = getelementptr inbounds %"struct.cgp::hierarchy_mesh_drawable_node", ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !9
  %32 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %33 = trunc i8 %32 to i1
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN3cgp4drawERKNS_13mesh_drawableERKNS_29environment_generic_structureEibRKNS_25uniform_generic_structureEj(ptr noundef nonnull align 8 dereferenceable(412) %29, ptr noundef nonnull align 8 dereferenceable(8) %30, i32 noundef %31, i1 noundef zeroext %33, ptr noundef nonnull align 8 dereferenceable(384) %34, i32 noundef 4)
  br label %35

35:                                               ; preds = %23
  %36 = load i32, ptr %12, align 4, !tbaa !9
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %12, align 4, !tbaa !9
  br label %18, !llvm.loop !15

38:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

declare void @_ZN3cgp4drawERKNS_13mesh_drawableERKNS_29environment_generic_structureEibRKNS_25uniform_generic_structureEj(ptr noundef nonnull align 8 dereferenceable(412), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i1 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(384), i32 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = distinct !{!15, !16}
!16 = !{!"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 @_ZNKSt6vectorIN3cgp28hierarchy_mesh_drawable_nodeESaIS1_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(512) ptr @_ZNKSt6vectorIN3cgp28hierarchy_mesh_drawable_nodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3cgp4drawERKNS_23hierarchy_mesh_drawableERKNS_29environment_generic_structureEibRKNS_25uniform_generic_structureE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2, i1 noundef zeroext %3, ptr noundef nonnull align 8 dereferenceable(384) %4) local_unnamed_addr #1 {
  %6 = tail call noundef i64 @_ZNKSt6vectorIN3cgp28hierarchy_mesh_drawable_nodeESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  %7 = trunc i64 %6 to i32
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = and i64 %6, 2147483647
  br label %.lr.ph

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

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %9 = tail call noundef nonnull align 8 dereferenceable(512) ptr @_ZNKSt6vectorIN3cgp28hierarchy_mesh_drawable_nodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #3
  tail call void @_ZN3cgp4drawERKNS_13mesh_drawableERKNS_29environment_generic_structureEibRKNS_25uniform_generic_structureEj(ptr noundef nonnull align 8 dereferenceable(412) %9, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2, i1 noundef zeroext %3, ptr noundef nonnull align 8 dereferenceable(384) %4, i32 noundef 4)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5
}

declare void @_ZN3cgp4drawERKNS_13mesh_drawableERKNS_29environment_generic_structureEibRKNS_25uniform_generic_structureEj(ptr noundef nonnull align 8 dereferenceable(412), ptr noundef nonnull align 8 dereferenceable(8), i32 noundef, i1 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(384), i32 noundef) local_unnamed_addr #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 = { 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 = { "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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