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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo5resetEv(ptr noundef nonnull align 8 dereferenceable(21) %0) #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  %8 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %7, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  call void @_ZN3sim14MouseInterface13resetPositionEv(ptr noundef nonnull align 8 dereferenceable(296) %9)
  call void @_ZN11mackAlgoTwo11MackAlgoTwo29acknowledgeResetButtonPressedEv(ptr noundef nonnull align 8 dereferenceable(21) %7)
  %10 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %7, i32 0, i32 2
  store i8 0, ptr %10, align 8, !tbaa !12
  %11 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %7, i32 0, i32 3
  store i8 0, ptr %11, align 1, !tbaa !13
  %12 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %7, i32 0, i32 6
  %13 = load i8, ptr %12, align 4, !tbaa !14
  %14 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %7, i32 0, i32 4
  store i8 %13, ptr %14, align 2, !tbaa !15
  %15 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %7, i32 0, i32 5
  store i8 0, ptr %15, align 1, !tbaa !16
  %16 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext 0, i8 noundef zeroext 0)
  call void @_ZN11mackAlgoTwo4Maze21setStraightAwayLengthEhh(i8 noundef zeroext %16, i8 noundef zeroext 0)
  br label %17

17:                                               ; preds = %50, %1
  %18 = call noundef zeroext i8 @_ZN11mackAlgoTwo7History4sizeEv()
  %19 = zext i8 %18 to i32
  %20 = icmp slt i32 0, %19
  br i1 %20, label %21, label %51

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %22 = call noundef i32 @_ZN11mackAlgoTwo7History3popEv()
  store i32 %22, ptr %3, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  %23 = load i32, ptr %3, align 4, !tbaa !17
  %24 = call noundef zeroext i8 @_ZN11mackAlgoTwo7History4cellEj(i32 noundef %23)
  store i8 %24, ptr %4, align 1, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %25 = load i32, ptr %3, align 4, !tbaa !17
  %26 = call noundef zeroext i8 @_ZN11mackAlgoTwo7History4dataEj(i32 noundef %25)
  store i8 %26, ptr %5, align 1, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  store i8 0, ptr %6, align 1, !tbaa !19
  br label %27

27:                                               ; preds = %45, %21
  %28 = load i8, ptr %6, align 1, !tbaa !19
  %29 = zext i8 %28 to i32
  %30 = icmp slt i32 %29, 4
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  br label %50

32:                                               ; preds = %27
  %33 = load i8, ptr %5, align 1, !tbaa !19
  %34 = zext i8 %33 to i32
  %35 = load i8, ptr %6, align 1, !tbaa !19
  %36 = zext i8 %35 to i32
  %37 = add nsw i32 %36, 4
  %38 = ashr i32 %34, %37
  %39 = and i32 %38, 1
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %44

41:                                               ; preds = %32
  %42 = load i8, ptr %4, align 1, !tbaa !19
  %43 = load i8, ptr %6, align 1, !tbaa !19
  call void @_ZN11mackAlgoTwo11MackAlgoTwo13unsetCellWallEhhb(ptr noundef nonnull align 8 dereferenceable(21) %7, i8 noundef zeroext %42, i8 noundef zeroext %43, i1 noundef zeroext true)
  br label %44

44:                                               ; preds = %41, %32
  br label %45

45:                                               ; preds = %44
  %46 = load i8, ptr %6, align 1, !tbaa !19
  %47 = zext i8 %46 to i32
  %48 = add nsw i32 %47, 1
  %49 = trunc i32 %48 to i8
  store i8 %49, ptr %6, align 1, !tbaa !19
  br label %27, !llvm.loop !20

50:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %17, !llvm.loop !22

51:                                               ; preds = %17
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo29acknowledgeResetButtonPressedEv(ptr noundef nonnull align 8 dereferenceable(21)) #2 align 2

declare void @_ZN3sim14MouseInterface13resetPositionEv(ptr noundef nonnull align 8 dereferenceable(296)) #1

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

declare noundef zeroext i8 @_ZN11mackAlgoTwo7History4sizeEv() #1

declare noundef i32 @_ZN11mackAlgoTwo7History3popEv() #1

declare noundef zeroext i8 @_ZN11mackAlgoTwo7History4cellEj(i32 noundef) #1

declare noundef zeroext i8 @_ZN11mackAlgoTwo7History4dataEj(i32 noundef) #1

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

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 = !{!10, !6, i64 8}
!10 = !{!"_ZTSN11mackAlgoTwo11MackAlgoTwoE", !11, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20}
!11 = !{!"_ZTS15IMouseAlgorithm"}
!12 = !{!10, !7, i64 16}
!13 = !{!10, !7, i64 17}
!14 = !{!10, !7, i64 20}
!15 = !{!10, !7, i64 18}
!16 = !{!10, !7, i64 19}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo5resetEv(ptr noundef nonnull align 8 dereferenceable(21) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @_ZN3sim14MouseInterface13resetPositionEv(ptr noundef nonnull align 8 dereferenceable(296) %3)
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo29acknowledgeResetButtonPressedEv(ptr noundef nonnull align 8 dereferenceable(21) %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 0, ptr %4, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 17
  store i8 0, ptr %5, align 1, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  %7 = load i8, ptr %6, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 18
  store i8 %7, ptr %8, align 2, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 19
  store i8 0, ptr %9, align 1, !tbaa !15
  %10 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext 0, i8 noundef zeroext 0)
  tail call void @_ZN11mackAlgoTwo4Maze21setStraightAwayLengthEhh(i8 noundef zeroext %10, i8 noundef zeroext 0)
  %11 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo7History4sizeEv()
  %.not11 = icmp eq i8 %11, 0
  br i1 %.not11, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.loopexit
  %12 = tail call noundef i32 @_ZN11mackAlgoTwo7History3popEv()
  %13 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo7History4cellEj(i32 noundef %12)
  %14 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo7History4dataEj(i32 noundef %12)
  %15 = zext i8 %14 to i32
  %16 = and i32 %15, 16
  %.not9 = icmp eq i32 %16, 0
  br i1 %.not9, label %18, label %17

17:                                               ; preds = %.lr.ph
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo13unsetCellWallEhhb(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %13, i8 noundef zeroext 0, i1 noundef zeroext true)
  br label %18

18:                                               ; preds = %.lr.ph, %17
  %19 = and i32 %15, 32
  %.not9.1 = icmp eq i32 %19, 0
  br i1 %.not9.1, label %21, label %20

20:                                               ; preds = %18
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo13unsetCellWallEhhb(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %13, i8 noundef zeroext 1, i1 noundef zeroext true)
  br label %21

21:                                               ; preds = %20, %18
  %22 = and i32 %15, 64
  %.not9.2 = icmp eq i32 %22, 0
  br i1 %.not9.2, label %24, label %23

23:                                               ; preds = %21
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo13unsetCellWallEhhb(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %13, i8 noundef zeroext 2, i1 noundef zeroext true)
  br label %24

24:                                               ; preds = %23, %21
  %.not9.3 = icmp sgt i8 %14, -1
  br i1 %.not9.3, label %.loopexit, label %25

25:                                               ; preds = %24
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo13unsetCellWallEhhb(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %13, i8 noundef zeroext 3, i1 noundef zeroext true)
  br label %.loopexit

.loopexit:                                        ; preds = %25, %24
  %26 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo7History4sizeEv()
  %.not = icmp eq i8 %26, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

._crit_edge:                                      ; preds = %.loopexit, %1
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo29acknowledgeResetButtonPressedEv(ptr noundef nonnull align 8 dereferenceable(21)) local_unnamed_addr #1 align 2

declare void @_ZN3sim14MouseInterface13resetPositionEv(ptr noundef nonnull align 8 dereferenceable(296)) local_unnamed_addr #0

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

declare noundef zeroext i8 @_ZN11mackAlgoTwo7History4sizeEv() local_unnamed_addr #0

declare noundef i32 @_ZN11mackAlgoTwo7History3popEv() local_unnamed_addr #0

declare noundef zeroext i8 @_ZN11mackAlgoTwo7History4cellEj(i32 noundef) local_unnamed_addr #0

declare noundef zeroext i8 @_ZN11mackAlgoTwo7History4dataEj(i32 noundef) local_unnamed_addr #0

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

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"}
!11 = !{!6, !9, i64 16}
!12 = !{!6, !9, i64 17}
!13 = !{!6, !9, i64 20}
!14 = !{!6, !9, i64 18}
!15 = !{!6, !9, i64 19}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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