; 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 void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext, i8 noundef zeroext) #1

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

declare void @_ZN11mackAlgoTwo4Maze9clearNextEh(i8 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo17reverseLinkedListEh(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
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %10 = load i8, ptr %4, align 1, !tbaa !9
  store i8 %10, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %11 = load i8, ptr %5, align 1, !tbaa !9
  %12 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %11)
  store i8 %12, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  %13 = load i8, ptr %5, align 1, !tbaa !9
  %14 = load i8, ptr %6, align 1, !tbaa !9
  %15 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %9, i8 noundef zeroext %13, i8 noundef zeroext %14)
  store i8 %15, ptr %7, align 1, !tbaa !9
  %16 = load i8, ptr %5, align 1, !tbaa !9
  call void @_ZN11mackAlgoTwo4Maze9clearNextEh(i8 noundef zeroext %16)
  br label %17

17:                                               ; preds = %20, %2
  %18 = load i8, ptr %7, align 1, !tbaa !9
  %19 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %18)
  br i1 %19, label %20, label %31

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %21 = load i8, ptr %7, align 1, !tbaa !9
  %22 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %21)
  store i8 %22, ptr %8, align 1, !tbaa !9
  %23 = load i8, ptr %7, align 1, !tbaa !9
  %24 = load i8, ptr %6, align 1, !tbaa !9
  %25 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo20getOppositeDirectionEh(ptr noundef nonnull align 8 dereferenceable(21) %9, i8 noundef zeroext %24)
  call void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext %23, i8 noundef zeroext %25)
  %26 = load i8, ptr %8, align 1, !tbaa !9
  store i8 %26, ptr %6, align 1, !tbaa !9
  %27 = load i8, ptr %7, align 1, !tbaa !9
  store i8 %27, ptr %5, align 1, !tbaa !9
  %28 = load i8, ptr %7, align 1, !tbaa !9
  %29 = load i8, ptr %6, align 1, !tbaa !9
  %30 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %9, i8 noundef zeroext %28, i8 noundef zeroext %29)
  store i8 %30, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  br label %17, !llvm.loop !10

31:                                               ; preds = %17
  %32 = load i8, ptr %7, align 1, !tbaa !9
  %33 = load i8, ptr %6, align 1, !tbaa !9
  %34 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo20getOppositeDirectionEh(ptr noundef nonnull align 8 dereferenceable(21) %9, i8 noundef zeroext %33)
  call void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext %32, i8 noundef zeroext %34)
  %35 = load i8, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret i8 %35
}

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

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 void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

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

declare void @_ZN11mackAlgoTwo4Maze9clearNextEh(i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo17reverseLinkedListEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1) local_unnamed_addr #1 align 2 {
  %3 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %1)
  %4 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1, i8 noundef zeroext %3)
  tail call void @_ZN11mackAlgoTwo4Maze9clearNextEh(i8 noundef zeroext %1)
  %5 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %4)
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.018 = phi i8 [ %8, %.lr.ph ], [ %4, %2 ]
  %.01617 = phi i8 [ %6, %.lr.ph ], [ %3, %2 ]
  %6 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %.018)
  %7 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo20getOppositeDirectionEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %.01617)
  tail call void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext %.018, i8 noundef zeroext %7)
  %8 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %.018, i8 noundef zeroext %6)
  %9 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %8)
  br i1 %9, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.016.lcssa = phi i8 [ %3, %2 ], [ %6, %.lr.ph ]
  %.0.lcssa = phi i8 [ %4, %2 ], [ %8, %.lr.ph ]
  %10 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo20getOppositeDirectionEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %.016.lcssa)
  tail call void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext %.0.lcssa, i8 noundef zeroext %10)
  ret i8 %.0.lcssa
}

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

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: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass