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

%"class.mackAlgoTwo::MackAlgoTwo" = type <{ %class.IMouseAlgorithm, ptr, i8, i8, i8, i8, i8, [3 x i8] }>
%class.IMouseAlgorithm = type { ptr }

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo13isOneCellAwayEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1) #2 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %10 = load i8, ptr %5, align 1, !tbaa !9
  %11 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getXEh(i8 noundef zeroext %10)
  store i8 %11, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  %12 = load i8, ptr %5, align 1, !tbaa !9
  %13 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getYEh(i8 noundef zeroext %12)
  store i8 %13, ptr %7, align 1, !tbaa !9
  %14 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %15 = load i8, ptr %14, align 8, !tbaa !10
  %16 = zext i8 %15 to i32
  %17 = load i8, ptr %6, align 1, !tbaa !9
  %18 = zext i8 %17 to i32
  %19 = icmp eq i32 %16, %18
  br i1 %19, label %20, label %35

20:                                               ; preds = %2
  %21 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = zext i8 %22 to i32
  %24 = add nsw i32 %23, 1
  %25 = load i8, ptr %7, align 1, !tbaa !9
  %26 = zext i8 %25 to i32
  %27 = icmp eq i32 %24, %26
  br i1 %27, label %28, label %35

28:                                               ; preds = %20
  %29 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %30 = load i8, ptr %29, align 8, !tbaa !10
  %31 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %32 = load i8, ptr %31, align 1, !tbaa !13
  %33 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %30, i8 noundef zeroext %32, i8 noundef zeroext 0)
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %105

35:                                               ; preds = %28, %20, %2
  %36 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %37 = load i8, ptr %36, align 8, !tbaa !10
  %38 = zext i8 %37 to i32
  %39 = load i8, ptr %6, align 1, !tbaa !9
  %40 = zext i8 %39 to i32
  %41 = icmp eq i32 %38, %40
  br i1 %41, label %42, label %57

42:                                               ; preds = %35
  %43 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = zext i8 %44 to i32
  %46 = sub nsw i32 %45, 1
  %47 = load i8, ptr %7, align 1, !tbaa !9
  %48 = zext i8 %47 to i32
  %49 = icmp eq i32 %46, %48
  br i1 %49, label %50, label %57

50:                                               ; preds = %42
  %51 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %52 = load i8, ptr %51, align 8, !tbaa !10
  %53 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %54 = load i8, ptr %53, align 1, !tbaa !13
  %55 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %52, i8 noundef zeroext %54, i8 noundef zeroext 2)
  br i1 %55, label %57, label %56

56:                                               ; preds = %50
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %105

57:                                               ; preds = %50, %42, %35
  %58 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %59 = load i8, ptr %58, align 8, !tbaa !10
  %60 = zext i8 %59 to i32
  %61 = add nsw i32 %60, 1
  %62 = load i8, ptr %6, align 1, !tbaa !9
  %63 = zext i8 %62 to i32
  %64 = icmp eq i32 %61, %63
  br i1 %64, label %65, label %79

65:                                               ; preds = %57
  %66 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %67 = load i8, ptr %66, align 1, !tbaa !13
  %68 = zext i8 %67 to i32
  %69 = load i8, ptr %7, align 1, !tbaa !9
  %70 = zext i8 %69 to i32
  %71 = icmp eq i32 %68, %70
  br i1 %71, label %72, label %79

72:                                               ; preds = %65
  %73 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %74 = load i8, ptr %73, align 8, !tbaa !10
  %75 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %76 = load i8, ptr %75, align 1, !tbaa !13
  %77 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %74, i8 noundef zeroext %76, i8 noundef zeroext 1)
  br i1 %77, label %79, label %78

78:                                               ; preds = %72
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %105

79:                                               ; preds = %72, %65, %57
  %80 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %81 = load i8, ptr %80, align 8, !tbaa !10
  %82 = zext i8 %81 to i32
  %83 = sub nsw i32 %82, 1
  %84 = load i8, ptr %6, align 1, !tbaa !9
  %85 = zext i8 %84 to i32
  %86 = icmp eq i32 %83, %85
  br i1 %86, label %87, label %101

87:                                               ; preds = %79
  %88 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %89 = load i8, ptr %88, align 1, !tbaa !13
  %90 = zext i8 %89 to i32
  %91 = load i8, ptr %7, align 1, !tbaa !9
  %92 = zext i8 %91 to i32
  %93 = icmp eq i32 %90, %92
  br i1 %93, label %94, label %101

94:                                               ; preds = %87
  %95 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 2
  %96 = load i8, ptr %95, align 8, !tbaa !10
  %97 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 3
  %98 = load i8, ptr %97, align 1, !tbaa !13
  %99 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %96, i8 noundef zeroext %98, i8 noundef zeroext 3)
  br i1 %99, label %101, label %100

100:                                              ; preds = %94
  store i1 true, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %105

101:                                              ; preds = %94, %87, %79
  br label %102

102:                                              ; preds = %101
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %105

105:                                              ; preds = %104, %100, %78, %56, %34
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  %106 = load i1, ptr %3, align 1
  ret i1 %106
}

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext, i8 noundef zeroext, 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 = !{!11, !7, i64 16}
!11 = !{!"_ZTSN11mackAlgoTwo11MackAlgoTwoE", !12, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20}
!12 = !{!"_ZTS15IMouseAlgorithm"}
!13 = !{!11, !7, i64 17}


; 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 i8 @_ZN11mackAlgoTwo4Maze4getXEh(i8 noundef zeroext) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo13isOneCellAwayEh(ptr nocapture noundef nonnull readonly align 8 dereferenceable(21) %0, i8 noundef zeroext %1) local_unnamed_addr #1 align 2 {
  %3 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getXEh(i8 noundef zeroext %1)
  %4 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getYEh(i8 noundef zeroext %1)
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i8, ptr %5, align 8, !tbaa !5
  %7 = zext i8 %3 to i32
  %8 = icmp eq i8 %6, %3
  br i1 %8, label %9, label %18

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 17
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = zext i8 %11 to i32
  %13 = add nuw nsw i32 %12, 1
  %14 = zext i8 %4 to i32
  %15 = icmp eq i32 %13, %14
  br i1 %15, label %16, label %.thread

16:                                               ; preds = %9
  %17 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %3, i8 noundef zeroext %11, i8 noundef zeroext 0)
  br i1 %17, label %._crit_edge, label %49

._crit_edge:                                      ; preds = %16
  %.pre = load i8, ptr %5, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %._crit_edge, %2
  %19 = phi i8 [ %.pre, %._crit_edge ], [ %6, %2 ]
  %20 = icmp eq i8 %19, %3
  br i1 %20, label %.thread, label %29

.thread:                                          ; preds = %9, %18
  %21 = getelementptr inbounds i8, ptr %0, i64 17
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = zext i8 %22 to i32
  %24 = add nsw i32 %23, -1
  %25 = zext i8 %4 to i32
  %26 = icmp eq i32 %24, %25
  br i1 %26, label %27, label %29

27:                                               ; preds = %.thread
  %28 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %3, i8 noundef zeroext %22, i8 noundef zeroext 2)
  br i1 %28, label %._crit_edge11, label %49

._crit_edge11:                                    ; preds = %27
  %.pre12 = load i8, ptr %5, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %._crit_edge11, %.thread, %18
  %30 = phi i8 [ %.pre12, %._crit_edge11 ], [ %3, %.thread ], [ %19, %18 ]
  %31 = zext i8 %30 to i32
  %32 = add nuw nsw i32 %31, 1
  %33 = icmp eq i32 %32, %7
  %34 = getelementptr inbounds i8, ptr %0, i64 17
  %35 = load i8, ptr %34, align 1
  %36 = icmp eq i8 %35, %4
  %or.cond = select i1 %33, i1 %36, i1 false
  br i1 %or.cond, label %37, label %39

37:                                               ; preds = %29
  %38 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %30, i8 noundef zeroext %4, i8 noundef zeroext 1)
  br i1 %38, label %._crit_edge13, label %49

._crit_edge13:                                    ; preds = %37
  %.pre14 = load i8, ptr %5, align 8, !tbaa !5
  %.pre15 = zext i8 %.pre14 to i32
  br label %39

39:                                               ; preds = %._crit_edge13, %29
  %.pre-phi = phi i32 [ %.pre15, %._crit_edge13 ], [ %31, %29 ]
  %40 = phi i8 [ %.pre14, %._crit_edge13 ], [ %30, %29 ]
  %41 = add nsw i32 %.pre-phi, -1
  %42 = icmp eq i32 %41, %7
  %43 = getelementptr inbounds i8, ptr %0, i64 17
  %44 = load i8, ptr %43, align 1
  %45 = icmp eq i8 %44, %4
  %or.cond20 = select i1 %42, i1 %45, i1 false
  br i1 %or.cond20, label %46, label %48

46:                                               ; preds = %39
  %47 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext %40, i8 noundef zeroext %4, i8 noundef zeroext 3)
  br i1 %47, label %48, label %49

48:                                               ; preds = %39, %46
  br label %49

49:                                               ; preds = %46, %37, %27, %16, %48
  %.0 = phi i1 [ false, %48 ], [ true, %16 ], [ true, %27 ], [ true, %37 ], [ true, %46 ]
  ret i1 %.0
}

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze6isWallEhhh(i8 noundef zeroext, i8 noundef zeroext, 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 = !{!6, !9, i64 16}
!6 = !{!"_ZTSN11mackAlgoTwo11MackAlgoTwoE", !7, i64 0, !8, i64 8, !9, i64 16, !9, i64 17, !9, i64 18, !9, i64 19, !9, i64 20}
!7 = !{!"_ZTS15IMouseAlgorithm"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !9, i64 17}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass