; LLVM IR from mackorone/mms :: old/v2/src/mouse/mackAlgoTwo (MackAlgoTwo)

; 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"

; 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 zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21), i8 noundef zeroext, i8 noundef zeroext) #2 align 2

declare noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext) #1

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhh(i8 noundef zeroext, i8 noundef zeroext) #1

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

8:                                                ; preds = %18, %2
  %9 = load i8, ptr %5, align 1, !tbaa !9
  %10 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %9)
  br i1 %10, label %11, label %16

11:                                               ; preds = %8
  %12 = load i8, ptr %5, align 1, !tbaa !9
  %13 = load i8, ptr %5, align 1, !tbaa !9
  %14 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %13)
  %15 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhh(i8 noundef zeroext %12, i8 noundef zeroext %14)
  br label %16

16:                                               ; preds = %11, %8
  %17 = phi i1 [ false, %8 ], [ %15, %11 ]
  br i1 %17, label %18, label %23

18:                                               ; preds = %16
  %19 = load i8, ptr %5, align 1, !tbaa !9
  %20 = load i8, ptr %5, align 1, !tbaa !9
  %21 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %20)
  %22 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %6, i8 noundef zeroext %19, i8 noundef zeroext %21)
  store i8 %22, ptr %5, align 1, !tbaa !9
  br label %8, !llvm.loop !10

23:                                               ; preds = %16
  %24 = load i8, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret i8 %24
}

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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21), i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1 align 2

declare noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext) local_unnamed_addr #0

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhh(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo15getFirstUnknownEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1) local_unnamed_addr #1 align 2 {
  %3 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %1)
  br i1 %3, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2, %6
  %.07 = phi i8 [ %8, %6 ], [ %1, %2 ]
  %4 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %.07)
  %5 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhh(i8 noundef zeroext %.07, i8 noundef zeroext %4)
  br i1 %5, label %6, label %.critedge

6:                                                ; preds = %.lr.ph
  %7 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %.07)
  %8 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %.07, i8 noundef zeroext %7)
  %9 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %8)
  br i1 %9, label %.lr.ph, label %.critedge, !llvm.loop !5

.critedge:                                        ; preds = %.lr.ph, %6, %2
  %.0.lcssa = phi i8 [ %1, %2 ], [ %8, %6 ], [ %.07, %.lr.ph ]
  ret i8 %.0.lcssa
}

attributes #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass