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

; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%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" }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #2

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9FloodFill10printWallsEv(ptr noundef nonnull align 8 dereferenceable(8457) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  %8 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 15, ptr %3, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %80, %1
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = icmp sge i32 %10, 0
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %83

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %75, %13
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 16
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %78

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  %19 = getelementptr inbounds %class.FloodFill, ptr %7, i32 0, i32 2
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [16 x [16 x %class.Cell]], ptr %19, i64 0, i64 %21
  %23 = load i32, ptr %3, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [16 x %class.Cell], ptr %22, i64 0, i64 %24
  %26 = call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %25, i32 noundef 0)
  %27 = zext i1 %26 to i32
  %28 = mul nsw i32 1, %27
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = add nsw i32 %29, %28
  store i32 %30, ptr %6, align 4, !tbaa !9
  %31 = getelementptr inbounds %class.FloodFill, ptr %7, i32 0, i32 2
  %32 = load i32, ptr %5, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [16 x [16 x %class.Cell]], ptr %31, i64 0, i64 %33
  %35 = load i32, ptr %3, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [16 x %class.Cell], ptr %34, i64 0, i64 %36
  %38 = call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %37, i32 noundef 1)
  %39 = zext i1 %38 to i32
  %40 = mul nsw i32 2, %39
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = add nsw i32 %41, %40
  store i32 %42, ptr %6, align 4, !tbaa !9
  %43 = getelementptr inbounds %class.FloodFill, ptr %7, i32 0, i32 2
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [16 x [16 x %class.Cell]], ptr %43, i64 0, i64 %45
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [16 x %class.Cell], ptr %46, i64 0, i64 %48
  %50 = call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %49, i32 noundef 2)
  %51 = zext i1 %50 to i32
  %52 = mul nsw i32 4, %51
  %53 = load i32, ptr %6, align 4, !tbaa !9
  %54 = add nsw i32 %53, %52
  store i32 %54, ptr %6, align 4, !tbaa !9
  %55 = getelementptr inbounds %class.FloodFill, ptr %7, i32 0, i32 2
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [16 x [16 x %class.Cell]], ptr %55, i64 0, i64 %57
  %59 = load i32, ptr %3, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [16 x %class.Cell], ptr %58, i64 0, i64 %60
  %62 = call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %61, i32 noundef 3)
  %63 = zext i1 %62 to i32
  %64 = mul nsw i32 8, %63
  %65 = load i32, ptr %6, align 4, !tbaa !9
  %66 = add nsw i32 %65, %64
  store i32 %66, ptr %6, align 4, !tbaa !9
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = icmp slt i32 %67, 10
  br i1 %68, label %69, label %71

69:                                               ; preds = %18
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  br label %71

71:                                               ; preds = %69, %18
  %72 = load i32, ptr %6, align 4, !tbaa !9
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %72)
  %74 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %73, ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %75

75:                                               ; preds = %71
  %76 = load i32, ptr %5, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %5, align 4, !tbaa !9
  br label %14, !llvm.loop !11

78:                                               ; preds = %17
  %79 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  br label %80

80:                                               ; preds = %78
  %81 = load i32, ptr %3, align 4, !tbaa !9
  %82 = sub nsw i32 %81, 1
  store i32 %82, ptr %3, align 4, !tbaa !9
  br label %9, !llvm.loop !13

83:                                               ; preds = %12
  ret void
}

declare noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #3

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 = { inlinehint 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%class.Cell = type { i32, i32, i32, i8, i8, [4 x i8], [4 x i8], ptr }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9FloodFill10printWallsEv(ptr noundef nonnull align 8 dereferenceable(8457) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  br label %.preheader

.preheader:                                       ; preds = %1, %5
  %indvars.iv22 = phi i64 [ 15, %1 ], [ %indvars.iv.next23, %5 ]
  br label %7

4:                                                ; preds = %5
  ret void

5:                                                ; preds = %23
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %indvars.iv.next23 = add nsw i64 %indvars.iv22, -1
  %.not = icmp eq i64 %indvars.iv22, 0
  br i1 %.not, label %4, label %.preheader, !llvm.loop !5

7:                                                ; preds = %.preheader, %23
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %23 ]
  %8 = getelementptr inbounds [16 x [16 x %class.Cell]], ptr %3, i64 0, i64 %indvars.iv, i64 %indvars.iv22
  %9 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %8, i32 noundef 0)
  %10 = zext i1 %9 to i32
  %11 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %8, i32 noundef 1)
  %12 = select i1 %11, i32 2, i32 0
  %13 = or disjoint i32 %12, %10
  %14 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %8, i32 noundef 2)
  %15 = select i1 %14, i32 4, i32 0
  %16 = or disjoint i32 %13, %15
  %17 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %8, i32 noundef 3)
  %18 = select i1 %17, i32 8, i32 0
  %19 = or disjoint i32 %16, %18
  %20 = icmp ult i32 %19, 10
  br i1 %20, label %21, label %23

21:                                               ; preds = %7
  %22 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull @.str)
  br label %23

23:                                               ; preds = %21, %7
  %24 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %19)
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull @.str)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 16
  br i1 %exitcond.not, label %5, label %7, !llvm.loop !7
}

declare noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { inlinehint 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" }

!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"}
!7 = distinct !{!7, !6}


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