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

; 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.Cellmod = type { ptr, ptr, i32, i8, i8, [4 x i8], [4 x i8] }

; 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

declare noundef i32 @_ZN4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(32)) #1

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

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

declare noundef ptr @_ZN4Cell7getPrevEv(ptr noundef nonnull align 8 dereferenceable(32)) #1

declare noundef zeroext i1 @_ZN4Cell11getExploredEv(ptr noundef nonnull align 8 dereferenceable(32)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9FloodFill18appendModifiedCellEPNSt7__cxx114listI7CellmodSaIS2_EEEP4Cell(ptr noundef nonnull align 8 dereferenceable(8457) %0, ptr noundef %1, ptr noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %struct.Cellmod, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #3
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Cellmod, ptr %7, i32 0, i32 0
  store ptr %10, ptr %11, align 8, !tbaa !9
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = call noundef i32 @_ZN4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  %14 = getelementptr inbounds %struct.Cellmod, ptr %7, i32 0, i32 2
  store i32 %13, ptr %14, align 8, !tbaa !13
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call noundef ptr @_ZN4Cell7getPrevEv(ptr noundef nonnull align 8 dereferenceable(32) %15)
  %17 = getelementptr inbounds %struct.Cellmod, ptr %7, i32 0, i32 1
  store ptr %16, ptr %17, align 8, !tbaa !14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef zeroext i1 @_ZN4Cell11getExploredEv(ptr noundef nonnull align 8 dereferenceable(32) %18)
  %20 = getelementptr inbounds %struct.Cellmod, ptr %7, i32 0, i32 3
  %21 = zext i1 %19 to i8
  store i8 %21, ptr %20, align 4, !tbaa !15
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = call noundef zeroext i1 @_ZN4Cell12getTraversedEv(ptr noundef nonnull align 8 dereferenceable(32) %22)
  %24 = getelementptr inbounds %struct.Cellmod, ptr %7, i32 0, i32 4
  %25 = zext i1 %23 to i8
  store i8 %25, ptr %24, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !17
  br label %26

26:                                               ; preds = %47, %3
  %27 = load i32, ptr %8, align 4, !tbaa !17
  %28 = icmp slt i32 %27, 4
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %50

30:                                               ; preds = %26
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = load i32, ptr %8, align 4, !tbaa !17
  %33 = call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %31, i32 noundef %32)
  %34 = getelementptr inbounds %struct.Cellmod, ptr %7, i32 0, i32 5
  %35 = load i32, ptr %8, align 4, !tbaa !17
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [4 x i8], ptr %34, i64 0, i64 %36
  %38 = zext i1 %33 to i8
  store i8 %38, ptr %37, align 1, !tbaa !18
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !17
  %41 = call noundef zeroext i1 @_ZN4Cell16getWallInspectedEi(ptr noundef nonnull align 8 dereferenceable(32) %39, i32 noundef %40)
  %42 = getelementptr inbounds %struct.Cellmod, ptr %7, i32 0, i32 6
  %43 = load i32, ptr %8, align 4, !tbaa !17
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [4 x i8], ptr %42, i64 0, i64 %44
  %46 = zext i1 %41 to i8
  store i8 %46, ptr %45, align 1, !tbaa !18
  br label %47

47:                                               ; preds = %30
  %48 = load i32, ptr %8, align 4, !tbaa !17
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %8, align 4, !tbaa !17
  br label %26, !llvm.loop !19

50:                                               ; preds = %29
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNSt7__cxx114listI7CellmodSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %51, ptr noundef nonnull align 8 dereferenceable(32) %7)
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #3
  ret void
}

declare noundef zeroext i1 @_ZN4Cell12getTraversedEv(ptr noundef nonnull align 8 dereferenceable(32)) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { 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, !6, i64 0}
!10 = !{!"_ZTS7Cellmod", !6, i64 0, !6, i64 8, !11, i64 16, !12, i64 20, !12, i64 21, !7, i64 22, !7, i64 26}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !6, i64 8}
!15 = !{!10, !12, i64 20}
!16 = !{!10, !12, i64 21}
!17 = !{!11, !11, i64 0}
!18 = !{!12, !12, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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.Cellmod = type { ptr, ptr, i32, i8, i8, [4 x i8], [4 x i8] }

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

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

declare noundef i32 @_ZN4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

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

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

declare noundef ptr @_ZN4Cell7getPrevEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN4Cell11getExploredEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9FloodFill18appendModifiedCellEPNSt7__cxx114listI7CellmodSaIS2_EEEP4Cell(ptr nocapture noundef nonnull readnone align 8 dereferenceable(8457) %0, ptr noundef %1, ptr noundef nonnull %2) local_unnamed_addr #2 align 2 {
  %4 = alloca %struct.Cellmod, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #3
  store ptr %2, ptr %4, align 8, !tbaa !5
  %5 = tail call noundef i32 @_ZN4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %6 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 %5, ptr %6, align 8, !tbaa !12
  %7 = tail call noundef ptr @_ZN4Cell7getPrevEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %8 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %7, ptr %8, align 8, !tbaa !13
  %9 = tail call noundef zeroext i1 @_ZN4Cell11getExploredEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %10 = getelementptr inbounds i8, ptr %4, i64 20
  %11 = tail call noundef zeroext i1 @_ZN4Cell12getTraversedEv(ptr noundef nonnull align 8 dereferenceable(32) %2)
  %12 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 0)
  %13 = tail call noundef zeroext i1 @_ZN4Cell16getWallInspectedEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 0)
  %14 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 1)
  %15 = tail call noundef zeroext i1 @_ZN4Cell16getWallInspectedEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 1)
  %16 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 2)
  %17 = tail call noundef zeroext i1 @_ZN4Cell16getWallInspectedEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 2)
  %18 = getelementptr inbounds i8, ptr %4, i64 28
  %19 = zext i1 %17 to i8
  store i8 %19, ptr %18, align 4, !tbaa !14
  %20 = tail call noundef zeroext i1 @_ZN4Cell6isWallEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 3)
  %21 = insertelement <8 x i1> poison, i1 %9, i64 0
  %22 = insertelement <8 x i1> %21, i1 %11, i64 1
  %23 = insertelement <8 x i1> %22, i1 %12, i64 2
  %24 = insertelement <8 x i1> %23, i1 %14, i64 3
  %25 = insertelement <8 x i1> %24, i1 %16, i64 4
  %26 = insertelement <8 x i1> %25, i1 %20, i64 5
  %27 = insertelement <8 x i1> %26, i1 %13, i64 6
  %28 = insertelement <8 x i1> %27, i1 %15, i64 7
  %29 = zext <8 x i1> %28 to <8 x i8>
  store <8 x i8> %29, ptr %10, align 4, !tbaa !14
  %30 = tail call noundef zeroext i1 @_ZN4Cell16getWallInspectedEi(ptr noundef nonnull align 8 dereferenceable(32) %2, i32 noundef 3)
  %31 = getelementptr inbounds i8, ptr %4, i64 29
  %32 = zext i1 %30 to i8
  store i8 %32, ptr %31, align 1, !tbaa !14
  call void @_ZNSt7__cxx114listI7CellmodSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(32) %4)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #3
  ret void
}

declare noundef zeroext i1 @_ZN4Cell12getTraversedEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx114listI7CellmodSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 = { 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 = !{!"_ZTS7Cellmod", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 20, !11, i64 21, !8, i64 22, !8, i64 26}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!6, !7, i64 8}
!14 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass