; LLVM IR from yangfengzzz/DigitalVox4 :: editor/imgui_node_editor.ll (ZN3vox10NodeEditor6Detail5Style8PopColorEi)

; 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.vox::NodeEditor::Detail::Style" = type { %"struct.vox::NodeEditor::Style", %"class.std::vector", %"class.std::vector.8" }
%"struct.vox::NodeEditor::Style" = type { %struct.ImVec4, float, float, float, float, float, float, float, %struct.ImVec2, %struct.ImVec2, float, float, float, float, %struct.ImVec2, %struct.ImVec2, %struct.ImVec2, float, float, float, float, float, float, [18 x %struct.ImVec4] }
%struct.ImVec4 = type { float, float, float, float }
%struct.ImVec2 = type { float, float }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::ColorModifier, std::allocator<vox::NodeEditor::Detail::Style::ColorModifier>>::_Vector_impl" }
%"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::ColorModifier, std::allocator<vox::NodeEditor::Detail::Style::ColorModifier>>::_Vector_impl" = type { %"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::ColorModifier, std::allocator<vox::NodeEditor::Detail::Style::ColorModifier>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::ColorModifier, std::allocator<vox::NodeEditor::Detail::Style::ColorModifier>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::VarModifier, std::allocator<vox::NodeEditor::Detail::Style::VarModifier>>::_Vector_impl" }
%"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::VarModifier, std::allocator<vox::NodeEditor::Detail::Style::VarModifier>>::_Vector_impl" = type { %"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::VarModifier, std::allocator<vox::NodeEditor::Detail::Style::VarModifier>>::_Vector_impl_data" }
%"struct.std::_Vector_base<vox::NodeEditor::Detail::Style::VarModifier, std::allocator<vox::NodeEditor::Detail::Style::VarModifier>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.vox::NodeEditor::Detail::Style::ColorModifier" = type { i32, %struct.ImVec4 }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3vox10NodeEditor6Detail5Style8PopColorEi(ptr noundef nonnull align 8 dereferenceable(464) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  br label %7

7:                                                ; preds = %10, %2
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %10, label %24

10:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %11 = getelementptr inbounds %"struct.vox::NodeEditor::Detail::Style", ptr %6, i32 0, i32 1
  %12 = call noundef nonnull align 4 dereferenceable(20) ptr @_ZNSt6vectorIN3vox10NodeEditor6Detail5Style13ColorModifierESaIS4_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #3
  store ptr %12, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.vox::NodeEditor::Detail::Style::ColorModifier", ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds %"struct.vox::NodeEditor::Style", ptr %6, i32 0, i32 23
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.vox::NodeEditor::Detail::Style::ColorModifier", ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 4, !tbaa !11
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [18 x %struct.ImVec4], ptr %15, i64 0, i64 %19
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %14, i64 16, i1 false), !tbaa.struct !16
  %21 = getelementptr inbounds %"struct.vox::NodeEditor::Detail::Style", ptr %6, i32 0, i32 1
  call void @_ZNSt6vectorIN3vox10NodeEditor6Detail5Style13ColorModifierESaIS4_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %21) #3
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = add nsw i32 %22, -1
  store i32 %23, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %7, !llvm.loop !18

24:                                               ; preds = %7
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(20) ptr @_ZNSt6vectorIN3vox10NodeEditor6Detail5Style13ColorModifierESaIS4_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN3vox10NodeEditor6Detail5Style13ColorModifierE", !13, i64 0, !14, i64 4}
!13 = !{!"_ZTSN3vox10NodeEditor10StyleColorE", !7, i64 0}
!14 = !{!"_ZTS6ImVec4", !15, i64 0, !15, i64 4, !15, i64 8, !15, i64 12}
!15 = !{!"float", !7, i64 0}
!16 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 4, !17, i64 12, i64 4, !17}
!17 = !{!15, !15, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%struct.ImVec4 = type { float, float, float, float }

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3vox10NodeEditor6Detail5Style8PopColorEi(ptr noundef nonnull align 8 dereferenceable(464) %0, i32 noundef %1) local_unnamed_addr #1 align 2 {
  %3 = icmp sgt i32 %1, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 416
  %5 = getelementptr inbounds i8, ptr %0, i64 124
  br label %6

6:                                                ; preds = %.lr.ph, %6
  %.04 = phi i32 [ %1, %.lr.ph ], [ %12, %6 ]
  %7 = tail call noundef nonnull align 4 dereferenceable(20) ptr @_ZNSt6vectorIN3vox10NodeEditor6Detail5Style13ColorModifierESaIS4_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #2
  %8 = getelementptr inbounds i8, ptr %7, i64 4
  %9 = load i32, ptr %7, align 4, !tbaa !5
  %10 = zext i32 %9 to i64
  %11 = getelementptr inbounds [18 x %struct.ImVec4], ptr %5, i64 0, i64 %10
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %11, ptr noundef nonnull align 4 dereferenceable(16) %8, i64 16, i1 false), !tbaa.struct !12
  tail call void @_ZNSt6vectorIN3vox10NodeEditor6Detail5Style13ColorModifierESaIS4_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %4) #2
  %12 = add nsw i32 %.04, -1
  %13 = icmp ugt i32 %.04, 1
  br i1 %13, label %6, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %6, %2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(20) ptr @_ZNSt6vectorIN3vox10NodeEditor6Detail5Style13ColorModifierESaIS4_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIN3vox10NodeEditor6Detail5Style13ColorModifierESaIS4_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree 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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN3vox10NodeEditor6Detail5Style13ColorModifierE", !7, i64 0, !10, i64 4}
!7 = !{!"_ZTSN3vox10NodeEditor10StyleColorE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS6ImVec4", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"float", !8, i64 0}
!12 = !{i64 0, i64 4, !13, i64 4, i64 4, !13, i64 8, i64 4, !13, i64 12, i64 4, !13}
!13 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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