; 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN11mackAlgoTwo11MackAlgoTwo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(21)) #1 align 2

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

declare void @_ZN11mackAlgoTwo4Maze21setStraightAwayLengthEhh(i8 noundef zeroext, i8 noundef zeroext) #2

declare void @_ZN11mackAlgoTwo4Maze13setDiscoveredEhb(i8 noundef zeroext, i1 noundef zeroext) #2

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

declare void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext, i8 noundef zeroext) #2

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

declare void @_ZN11mackAlgoTwo4Heap4pushEh(i8 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo13checkNeighborEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1, i8 noundef zeroext %2) #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  store i8 %2, ptr %6, align 1, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #4
  %11 = load i8, ptr %5, align 1, !tbaa !9
  %12 = load i8, ptr %6, align 1, !tbaa !9
  %13 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %10, i8 noundef zeroext %11, i8 noundef zeroext %12)
  store i8 %13, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %14 = load i8, ptr %6, align 1, !tbaa !9
  %15 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo20getOppositeDirectionEh(ptr noundef nonnull align 8 dereferenceable(21) %10, i8 noundef zeroext %14)
  store i8 %15, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %16 = load i8, ptr %5, align 1, !tbaa !9
  %17 = call noundef i32 @_ZN11mackAlgoTwo4Maze11getDistanceEh(i8 noundef zeroext %16)
  %18 = load i8, ptr %5, align 1, !tbaa !9
  %19 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %18)
  %20 = zext i8 %19 to i32
  %21 = load i8, ptr %8, align 1, !tbaa !9
  %22 = zext i8 %21 to i32
  %23 = icmp eq i32 %20, %22
  br i1 %23, label %24, label %31

24:                                               ; preds = %3
  %25 = load i8, ptr %5, align 1, !tbaa !9
  %26 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze21getStraightAwayLengthEh(i8 noundef zeroext %25)
  %27 = zext i8 %26 to i32
  %28 = add nsw i32 %27, 1
  %29 = trunc i32 %28 to i8
  %30 = call noundef i32 @_ZN11mackAlgoTwo11MackAlgoTwo19getStraightAwayCostEh(ptr noundef nonnull align 8 dereferenceable(21) %10, i8 noundef zeroext %29)
  br label %33

31:                                               ; preds = %3
  %32 = call noundef i32 @_ZN11mackAlgoTwo11MackAlgoTwo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(21) %10)
  br label %33

33:                                               ; preds = %31, %24
  %34 = phi i32 [ %30, %24 ], [ %32, %31 ]
  %35 = add i32 %17, %34
  store i32 %35, ptr %9, align 4, !tbaa !10
  %36 = load i8, ptr %7, align 1, !tbaa !9
  %37 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze13getDiscoveredEh(i8 noundef zeroext %36)
  br i1 %37, label %38, label %43

38:                                               ; preds = %33
  %39 = load i32, ptr %9, align 4, !tbaa !10
  %40 = load i8, ptr %7, align 1, !tbaa !9
  %41 = call noundef i32 @_ZN11mackAlgoTwo4Maze11getDistanceEh(i8 noundef zeroext %40)
  %42 = icmp ult i32 %39, %41
  br i1 %42, label %43, label %72

43:                                               ; preds = %38, %33
  %44 = load i8, ptr %7, align 1, !tbaa !9
  %45 = load i32, ptr %9, align 4, !tbaa !10
  call void @_ZN11mackAlgoTwo11MackAlgoTwo15setCellDistanceEhj(ptr noundef nonnull align 8 dereferenceable(21) %10, i8 noundef zeroext %44, i32 noundef %45)
  %46 = load i8, ptr %7, align 1, !tbaa !9
  %47 = load i8, ptr %8, align 1, !tbaa !9
  call void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext %46, i8 noundef zeroext %47)
  %48 = load i8, ptr %7, align 1, !tbaa !9
  %49 = load i8, ptr %5, align 1, !tbaa !9
  %50 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %49)
  %51 = zext i8 %50 to i32
  %52 = load i8, ptr %8, align 1, !tbaa !9
  %53 = zext i8 %52 to i32
  %54 = icmp eq i32 %51, %53
  br i1 %54, label %55, label %60

55:                                               ; preds = %43
  %56 = load i8, ptr %5, align 1, !tbaa !9
  %57 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze21getStraightAwayLengthEh(i8 noundef zeroext %56)
  %58 = zext i8 %57 to i32
  %59 = add nsw i32 %58, 1
  br label %61

60:                                               ; preds = %43
  br label %61

61:                                               ; preds = %60, %55
  %62 = phi i32 [ %59, %55 ], [ 1, %60 ]
  %63 = trunc i32 %62 to i8
  call void @_ZN11mackAlgoTwo4Maze21setStraightAwayLengthEhh(i8 noundef zeroext %48, i8 noundef zeroext %63)
  %64 = load i8, ptr %7, align 1, !tbaa !9
  %65 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze13getDiscoveredEh(i8 noundef zeroext %64)
  br i1 %65, label %69, label %66

66:                                               ; preds = %61
  %67 = load i8, ptr %7, align 1, !tbaa !9
  call void @_ZN11mackAlgoTwo4Maze13setDiscoveredEhb(i8 noundef zeroext %67, i1 noundef zeroext true)
  %68 = load i8, ptr %7, align 1, !tbaa !9
  call void @_ZN11mackAlgoTwo4Heap4pushEh(i8 noundef zeroext %68)
  br label %71

69:                                               ; preds = %61
  %70 = load i8, ptr %7, align 1, !tbaa !9
  call void @_ZN11mackAlgoTwo4Heap6updateEh(i8 noundef zeroext %70)
  br label %71

71:                                               ; preds = %69, %66
  br label %72

72:                                               ; preds = %71, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #4
  ret void
}

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

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

declare noundef i32 @_ZN11mackAlgoTwo4Maze11getDistanceEh(i8 noundef zeroext) #2

declare noundef zeroext i8 @_ZN11mackAlgoTwo4Maze21getStraightAwayLengthEh(i8 noundef zeroext) #2

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze13getDiscoveredEh(i8 noundef zeroext) #2

declare void @_ZN11mackAlgoTwo4Heap6updateEh(i8 noundef zeroext) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind 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" }
attributes #3 = { 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 #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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, 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 nounwind uwtable
declare dso_local noundef i32 @_ZN11mackAlgoTwo11MackAlgoTwo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(21)) local_unnamed_addr #0 align 2

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

declare void @_ZN11mackAlgoTwo4Maze21setStraightAwayLengthEhh(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

declare void @_ZN11mackAlgoTwo4Maze13setDiscoveredEhb(i8 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #1

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

declare void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

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

declare void @_ZN11mackAlgoTwo4Heap4pushEh(i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo13checkNeighborEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1, i8 noundef zeroext %2) local_unnamed_addr #2 align 2 {
  %4 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1, i8 noundef zeroext %2)
  %5 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo20getOppositeDirectionEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %2)
  %6 = tail call noundef i32 @_ZN11mackAlgoTwo4Maze11getDistanceEh(i8 noundef zeroext %1)
  %7 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %1)
  %8 = icmp eq i8 %7, %5
  br i1 %8, label %9, label %13

9:                                                ; preds = %3
  %10 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze21getStraightAwayLengthEh(i8 noundef zeroext %1)
  %11 = add i8 %10, 1
  %12 = tail call noundef i32 @_ZN11mackAlgoTwo11MackAlgoTwo19getStraightAwayCostEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %11)
  br label %15

13:                                               ; preds = %3
  %14 = tail call noundef i32 @_ZN11mackAlgoTwo11MackAlgoTwo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(21) %0)
  br label %15

15:                                               ; preds = %13, %9
  %16 = phi i32 [ %12, %9 ], [ %14, %13 ]
  %17 = add i32 %16, %6
  %18 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze13getDiscoveredEh(i8 noundef zeroext %4)
  br i1 %18, label %19, label %22

19:                                               ; preds = %15
  %20 = tail call noundef i32 @_ZN11mackAlgoTwo4Maze11getDistanceEh(i8 noundef zeroext %4)
  %21 = icmp ult i32 %17, %20
  br i1 %21, label %22, label %33

22:                                               ; preds = %19, %15
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo15setCellDistanceEhj(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %4, i32 noundef %17)
  tail call void @_ZN11mackAlgoTwo4Maze16setNextDirectionEhh(i8 noundef zeroext %4, i8 noundef zeroext %5)
  %23 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %1)
  %24 = icmp eq i8 %23, %5
  br i1 %24, label %25, label %28

25:                                               ; preds = %22
  %26 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze21getStraightAwayLengthEh(i8 noundef zeroext %1)
  %27 = add i8 %26, 1
  br label %28

28:                                               ; preds = %22, %25
  %29 = phi i8 [ %27, %25 ], [ 1, %22 ]
  tail call void @_ZN11mackAlgoTwo4Maze21setStraightAwayLengthEhh(i8 noundef zeroext %4, i8 noundef zeroext %29)
  %30 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze13getDiscoveredEh(i8 noundef zeroext %4)
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  tail call void @_ZN11mackAlgoTwo4Maze13setDiscoveredEhb(i8 noundef zeroext %4, i1 noundef zeroext true)
  tail call void @_ZN11mackAlgoTwo4Heap4pushEh(i8 noundef zeroext %4)
  br label %33

32:                                               ; preds = %28
  tail call void @_ZN11mackAlgoTwo4Heap6updateEh(i8 noundef zeroext %4)
  br label %33

33:                                               ; preds = %31, %32, %19
  ret void
}

; 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 #2 align 2

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

declare noundef i32 @_ZN11mackAlgoTwo4Maze11getDistanceEh(i8 noundef zeroext) local_unnamed_addr #1

declare noundef zeroext i8 @_ZN11mackAlgoTwo4Maze21getStraightAwayLengthEh(i8 noundef zeroext) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze13getDiscoveredEh(i8 noundef zeroext) local_unnamed_addr #1

declare void @_ZN11mackAlgoTwo4Heap6updateEh(i8 noundef zeroext) local_unnamed_addr #1

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

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass