; LLVM IR from mackorone/mms :: old/v1/src/algo/FloodFill/FloodFill.ll (ZN9FloodFill14extensiveSolveEv)

; 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.FloodFill = type <{ %class.IAlgorithm, ptr, [16 x [16 x %class.Cell]], i32, i32, i32, i32, i8, i8, [6 x i8], %class.History, i8, [7 x i8] }>
%class.IAlgorithm = type { ptr }
%class.Cell = type { i32, i32, i32, i8, i8, [4 x i8], [4 x i8], ptr }
%class.History = type { i32, i32, ptr, %"class.std::stack", %"class.std::queue", %"class.std::__cxx11::list", %"class.std::__cxx11::list.9" }
%"class.std::stack" = type { %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<Cell *, std::allocator<Cell *>>::_Deque_impl" }
%"struct.std::_Deque_base<Cell *, std::allocator<Cell *>>::_Deque_impl" = type { %"struct.std::_Deque_base<Cell *, std::allocator<Cell *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<Cell *, std::allocator<Cell *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::queue" = type { %"class.std::deque.0" }
%"class.std::deque.0" = type { %"class.std::_Deque_base.1" }
%"class.std::_Deque_base.1" = type { %"struct.std::_Deque_base<std::stack<Cell *>, std::allocator<std::stack<Cell *>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::stack<Cell *>, std::allocator<std::stack<Cell *>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::stack<Cell *>, std::allocator<std::stack<Cell *>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::stack<Cell *>, std::allocator<std::stack<Cell *>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator.5", %"struct.std::_Deque_iterator.5" }
%"struct.std::_Deque_iterator.5" = type { ptr, ptr, ptr, ptr }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" }
%"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }
%"class.std::__cxx11::list.9" = type { %"class.std::__cxx11::_List_base.10" }
%"class.std::__cxx11::_List_base.10" = type { %"struct.std::__cxx11::_List_base<std::__cxx11::list<Cellmod>, std::allocator<std::__cxx11::list<Cellmod>>>::_List_impl" }
%"struct.std::__cxx11::_List_base<std::__cxx11::list<Cellmod>, std::allocator<std::__cxx11::list<Cellmod>>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }

; 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: mustprogress uwtable
define dso_local void @_ZN9FloodFill14extensiveSolveEv(ptr noundef nonnull align 8 dereferenceable(8457) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  br label %5

5:                                                ; preds = %10, %9, %1
  call void @_ZN9FloodFill10initializeEv(ptr noundef nonnull align 8 dereferenceable(8457) %4)
  call void @_ZN9FloodFill7exploreEv(ptr noundef nonnull align 8 dereferenceable(8457) %4)
  %6 = getelementptr inbounds %class.FloodFill, ptr %4, i32 0, i32 8
  %7 = load i8, ptr %6, align 1, !tbaa !9, !range !36, !noundef !37
  %8 = trunc i8 %7 to i1
  br i1 %8, label %10, label %9

9:                                                ; preds = %5
  br label %5, !llvm.loop !38

10:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %11 = getelementptr inbounds %class.FloodFill, ptr %4, i32 0, i32 6
  %12 = load i32, ptr %11, align 4, !tbaa !40
  store i32 %12, ptr %3, align 4, !tbaa !41
  call void @_ZN9FloodFill7victoryEv(ptr noundef nonnull align 8 dereferenceable(8457) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  br label %5, !llvm.loop !38
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9FloodFill10initializeEv(ptr noundef nonnull align 8 dereferenceable(8457)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9FloodFill7exploreEv(ptr noundef nonnull align 8 dereferenceable(8457)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9FloodFill7victoryEv(ptr noundef nonnull align 8 dereferenceable(8457)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !13, i64 8225}
!10 = !{!"_ZTS9FloodFill", !11, i64 0, !6, i64 8, !7, i64 16, !12, i64 8208, !12, i64 8212, !12, i64 8216, !12, i64 8220, !13, i64 8224, !13, i64 8225, !14, i64 8232, !13, i64 8456}
!11 = !{!"_ZTS10IAlgorithm"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTS7History", !12, i64 0, !12, i64 4, !6, i64 8, !15, i64 16, !22, i64 96, !28, i64 176, !33, i64 200}
!15 = !{!"_ZTSSt5stackIP4CellSt5dequeIS1_SaIS1_EEE", !16, i64 0}
!16 = !{!"_ZTSSt5dequeIP4CellSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSSt11_Deque_baseIP4CellSaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSNSt11_Deque_baseIP4CellSaIS1_EE11_Deque_implE", !19, i64 0}
!19 = !{!"_ZTSNSt11_Deque_baseIP4CellSaIS1_EE16_Deque_impl_dataE", !6, i64 0, !20, i64 8, !21, i64 16, !21, i64 48}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSSt15_Deque_iteratorIP4CellRS1_PS1_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!22 = !{!"_ZTSSt5queueISt5stackIP4CellSt5dequeIS2_SaIS2_EEES3_IS6_SaIS6_EEE", !23, i64 0}
!23 = !{!"_ZTSSt5dequeISt5stackIP4CellS_IS2_SaIS2_EEESaIS5_EE", !24, i64 0}
!24 = !{!"_ZTSSt11_Deque_baseISt5stackIP4CellSt5dequeIS2_SaIS2_EEESaIS6_EE", !25, i64 0}
!25 = !{!"_ZTSNSt11_Deque_baseISt5stackIP4CellSt5dequeIS2_SaIS2_EEESaIS6_EE11_Deque_implE", !26, i64 0}
!26 = !{!"_ZTSNSt11_Deque_baseISt5stackIP4CellSt5dequeIS2_SaIS2_EEESaIS6_EE16_Deque_impl_dataE", !6, i64 0, !20, i64 8, !27, i64 16, !27, i64 48}
!27 = !{!"_ZTSSt15_Deque_iteratorISt5stackIP4CellSt5dequeIS2_SaIS2_EEERS6_PS6_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!28 = !{!"_ZTSNSt7__cxx114listIiSaIiEEE", !29, i64 0}
!29 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEEE", !30, i64 0}
!30 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEE10_List_implE", !31, i64 0}
!31 = !{!"_ZTSNSt8__detail17_List_node_headerE", !32, i64 0, !20, i64 16}
!32 = !{!"_ZTSNSt8__detail15_List_node_baseE", !6, i64 0, !6, i64 8}
!33 = !{!"_ZTSNSt7__cxx114listINS0_I7CellmodSaIS1_EEESaIS3_EEE", !34, i64 0}
!34 = !{!"_ZTSNSt7__cxx1110_List_baseINS_4listI7CellmodSaIS2_EEESaIS4_EEE", !35, i64 0}
!35 = !{!"_ZTSNSt7__cxx1110_List_baseINS_4listI7CellmodSaIS2_EEESaIS4_EE10_List_implE", !31, i64 0}
!36 = !{i8 0, i8 2}
!37 = !{}
!38 = distinct !{!38, !39}
!39 = !{!"llvm.loop.mustprogress"}
!40 = !{!10, !12, i64 8220}
!41 = !{!12, !12, i64 0}


; 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 noreturn uwtable
define dso_local void @_ZN9FloodFill14extensiveSolveEv(ptr noundef nonnull align 8 dereferenceable(8457) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8225
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %1
  tail call void @_ZN9FloodFill10initializeEv(ptr noundef nonnull align 8 dereferenceable(8457) %0)
  tail call void @_ZN9FloodFill7exploreEv(ptr noundef nonnull align 8 dereferenceable(8457) %0)
  %3 = load i8, ptr %2, align 1, !tbaa !5, !range !35, !noundef !36
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %.backedge.backedge

5:                                                ; preds = %.backedge
  tail call void @_ZN9FloodFill7victoryEv(ptr noundef nonnull align 8 dereferenceable(8457) %0)
  br label %.backedge.backedge

.backedge.backedge:                               ; preds = %5, %.backedge
  br label %.backedge, !llvm.loop !37
}

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

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

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

attributes #0 = { mustprogress noreturn 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" }

!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, !12, i64 8225}
!6 = !{!"_ZTS9FloodFill", !7, i64 0, !8, i64 8, !9, i64 16, !11, i64 8208, !11, i64 8212, !11, i64 8216, !11, i64 8220, !12, i64 8224, !12, i64 8225, !13, i64 8232, !12, i64 8456}
!7 = !{!"_ZTS10IAlgorithm"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"_ZTS7History", !11, i64 0, !11, i64 4, !8, i64 8, !14, i64 16, !21, i64 96, !27, i64 176, !32, i64 200}
!14 = !{!"_ZTSSt5stackIP4CellSt5dequeIS1_SaIS1_EEE", !15, i64 0}
!15 = !{!"_ZTSSt5dequeIP4CellSaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt11_Deque_baseIP4CellSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseIP4CellSaIS1_EE11_Deque_implE", !18, i64 0}
!18 = !{!"_ZTSNSt11_Deque_baseIP4CellSaIS1_EE16_Deque_impl_dataE", !8, i64 0, !19, i64 8, !20, i64 16, !20, i64 48}
!19 = !{!"long", !9, i64 0}
!20 = !{!"_ZTSSt15_Deque_iteratorIP4CellRS1_PS1_E", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!21 = !{!"_ZTSSt5queueISt5stackIP4CellSt5dequeIS2_SaIS2_EEES3_IS6_SaIS6_EEE", !22, i64 0}
!22 = !{!"_ZTSSt5dequeISt5stackIP4CellS_IS2_SaIS2_EEESaIS5_EE", !23, i64 0}
!23 = !{!"_ZTSSt11_Deque_baseISt5stackIP4CellSt5dequeIS2_SaIS2_EEESaIS6_EE", !24, i64 0}
!24 = !{!"_ZTSNSt11_Deque_baseISt5stackIP4CellSt5dequeIS2_SaIS2_EEESaIS6_EE11_Deque_implE", !25, i64 0}
!25 = !{!"_ZTSNSt11_Deque_baseISt5stackIP4CellSt5dequeIS2_SaIS2_EEESaIS6_EE16_Deque_impl_dataE", !8, i64 0, !19, i64 8, !26, i64 16, !26, i64 48}
!26 = !{!"_ZTSSt15_Deque_iteratorISt5stackIP4CellSt5dequeIS2_SaIS2_EEERS6_PS6_E", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!27 = !{!"_ZTSNSt7__cxx114listIiSaIiEEE", !28, i64 0}
!28 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEEE", !29, i64 0}
!29 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEE10_List_implE", !30, i64 0}
!30 = !{!"_ZTSNSt8__detail17_List_node_headerE", !31, i64 0, !19, i64 16}
!31 = !{!"_ZTSNSt8__detail15_List_node_baseE", !8, i64 0, !8, i64 8}
!32 = !{!"_ZTSNSt7__cxx114listINS0_I7CellmodSaIS1_EEESaIS3_EEE", !33, i64 0}
!33 = !{!"_ZTSNSt7__cxx1110_List_baseINS_4listI7CellmodSaIS2_EEESaIS4_EEE", !34, i64 0}
!34 = !{!"_ZTSNSt7__cxx1110_List_baseINS_4listI7CellmodSaIS2_EEESaIS4_EE10_List_implE", !30, i64 0}
!35 = !{i8 0, i8 2}
!36 = !{}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}


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