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

; 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 void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296), i32 noundef, i32 noundef, i8 noundef signext) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo8drawPathEh(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 i32, align 4
  %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
  store i8 0, ptr %6, align 1, !tbaa !9
  br label %11

11:                                               ; preds = %58, %2
  %12 = load i8, ptr %6, align 1, !tbaa !9
  %13 = zext i8 %12 to i32
  %14 = icmp slt i32 %13, 2
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  br label %63

16:                                               ; preds = %11
  br label %17

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

20:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  %21 = load i8, ptr %5, align 1, !tbaa !9
  %22 = load i8, ptr %5, align 1, !tbaa !9
  %23 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %22)
  %24 = call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %9, i8 noundef zeroext %21, i8 noundef zeroext %23)
  store i8 %24, ptr %8, align 1, !tbaa !9
  %25 = load i8, ptr %6, align 1, !tbaa !9
  %26 = zext i8 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %43

28:                                               ; preds = %20
  %29 = load i8, ptr %5, align 1, !tbaa !9
  %30 = load i8, ptr %5, align 1, !tbaa !9
  %31 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %30)
  %32 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhh(i8 noundef zeroext %29, i8 noundef zeroext %31)
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  store i32 6, ptr %7, align 4
  br label %54

34:                                               ; preds = %28
  %35 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !10
  %37 = load i8, ptr %8, align 1, !tbaa !9
  %38 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getXEh(i8 noundef zeroext %37)
  %39 = zext i8 %38 to i32
  %40 = load i8, ptr %8, align 1, !tbaa !9
  %41 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getYEh(i8 noundef zeroext %40)
  %42 = zext i8 %41 to i32
  call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %36, i32 noundef %39, i32 noundef %42, i8 noundef signext 86)
  br label %52

43:                                               ; preds = %20
  %44 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %9, i32 0, i32 1
  %45 = load ptr, ptr %44, align 8, !tbaa !10
  %46 = load i8, ptr %8, align 1, !tbaa !9
  %47 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getXEh(i8 noundef zeroext %46)
  %48 = zext i8 %47 to i32
  %49 = load i8, ptr %8, align 1, !tbaa !9
  %50 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getYEh(i8 noundef zeroext %49)
  %51 = zext i8 %50 to i32
  call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %45, i32 noundef %48, i32 noundef %51, i8 noundef signext 66)
  br label %52

52:                                               ; preds = %43, %34
  %53 = load i8, ptr %8, align 1, !tbaa !9
  store i8 %53, ptr %5, align 1, !tbaa !9
  store i32 0, ptr %7, align 4
  br label %54

54:                                               ; preds = %52, %33
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  %55 = load i32, ptr %7, align 4
  switch i32 %55, label %64 [
    i32 0, label %56
    i32 6, label %57
  ]

56:                                               ; preds = %54
  br label %17, !llvm.loop !13

57:                                               ; preds = %54, %17
  br label %58

58:                                               ; preds = %57
  %59 = load i8, ptr %6, align 1, !tbaa !9
  %60 = zext i8 %59 to i32
  %61 = add nsw i32 %60, 1
  %62 = trunc i32 %61 to i8
  store i8 %62, ptr %6, align 1, !tbaa !9
  br label %11, !llvm.loop !15

63:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret void

64:                                               ; preds = %54
  unreachable
}

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

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

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

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, !6, i64 8}
!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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296), i32 noundef, i32 noundef, i8 noundef signext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo8drawPathEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1) local_unnamed_addr #1 align 2 {
.preheader:
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %1)
  br i1 %3, label %.lr.ph.split.us, label %.thread

.lr.ph.split.us:                                  ; preds = %.preheader, %8
  %.120.us = phi i8 [ %5, %8 ], [ %1, %.preheader ]
  %4 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %.120.us)
  %5 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %.120.us, i8 noundef zeroext %4)
  %6 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %.120.us)
  %7 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhh(i8 noundef zeroext %.120.us, i8 noundef zeroext %6)
  br i1 %7, label %8, label %.thread

8:                                                ; preds = %.lr.ph.split.us
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getXEh(i8 noundef zeroext %5)
  %11 = zext i8 %10 to i32
  %12 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getYEh(i8 noundef zeroext %5)
  %13 = zext i8 %12 to i32
  tail call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %9, i32 noundef %11, i32 noundef %13, i8 noundef signext 86)
  %14 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %5)
  br i1 %14, label %.lr.ph.split.us, label %.thread

.thread:                                          ; preds = %8, %.lr.ph.split.us, %.preheader
  %.1.lcssa = phi i8 [ %1, %.preheader ], [ %.120.us, %.lr.ph.split.us ], [ %5, %8 ]
  %15 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %.1.lcssa)
  br i1 %15, label %.lr.ph.split.1, label %.thread.1

.lr.ph.split.1:                                   ; preds = %.thread, %.lr.ph.split.1
  %.120.1 = phi i8 [ %17, %.lr.ph.split.1 ], [ %.1.lcssa, %.thread ]
  %16 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze16getNextDirectionEh(i8 noundef zeroext %.120.1)
  %17 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo11MackAlgoTwo18getNeighboringCellEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %.120.1, i8 noundef zeroext %16)
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getXEh(i8 noundef zeroext %17)
  %20 = zext i8 %19 to i32
  %21 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze4getYEh(i8 noundef zeroext %17)
  %22 = zext i8 %21 to i32
  tail call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %18, i32 noundef %20, i32 noundef %22, i8 noundef signext 66)
  %23 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7hasNextEh(i8 noundef zeroext %17)
  br i1 %23, label %.lr.ph.split.1, label %.thread.1

.thread.1:                                        ; preds = %.lr.ph.split.1, %.thread
  ret void
}

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

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

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

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, !8, i64 8}
!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass