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

; 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

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

declare noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext, i8 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo9readWallsEv(ptr noundef nonnull align 8 dereferenceable(21) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #3
  %9 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 2
  %10 = load i8, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 3
  %12 = load i8, ptr %11, align 1, !tbaa !12
  %13 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext %10, i8 noundef zeroext %12)
  store i8 %13, ptr %3, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  store i8 0, ptr %4, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 -1, ptr %5, align 4, !tbaa !14
  br label %14

14:                                               ; preds = %65, %1
  %15 = load i32, ptr %5, align 4, !tbaa !14
  %16 = icmp sle i32 %15, 1
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %68

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %19 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 4
  %20 = load i8, ptr %19, align 2, !tbaa !16
  %21 = zext i8 %20 to i32
  %22 = load i32, ptr %5, align 4, !tbaa !14
  %23 = add nsw i32 %21, %22
  %24 = add nsw i32 %23, 4
  %25 = srem i32 %24, 4
  %26 = trunc i32 %25 to i8
  store i8 %26, ptr %6, align 1, !tbaa !13
  %27 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 2
  %28 = load i8, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 3
  %30 = load i8, ptr %29, align 1, !tbaa !12
  %31 = load i8, ptr %6, align 1, !tbaa !13
  %32 = call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhhh(i8 noundef zeroext %28, i8 noundef zeroext %30, i8 noundef zeroext %31)
  br i1 %32, label %64, label %33

33:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  %34 = load i8, ptr %6, align 1, !tbaa !13
  %35 = call noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo8readWallEh(ptr noundef nonnull align 8 dereferenceable(21) %8, i8 noundef zeroext %34)
  %36 = zext i1 %35 to i8
  store i8 %36, ptr %7, align 1, !tbaa !17
  %37 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 2
  %38 = load i8, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 3
  %40 = load i8, ptr %39, align 1, !tbaa !12
  %41 = call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext %38, i8 noundef zeroext %40)
  %42 = load i8, ptr %6, align 1, !tbaa !13
  %43 = load i8, ptr %7, align 1, !tbaa !17, !range !19, !noundef !20
  %44 = trunc i8 %43 to i1
  call void @_ZN11mackAlgoTwo11MackAlgoTwo11setCellWallEhhbb(ptr noundef nonnull align 8 dereferenceable(21) %8, i8 noundef zeroext %41, i8 noundef zeroext %42, i1 noundef zeroext %44, i1 noundef zeroext true)
  %45 = load i8, ptr %6, align 1, !tbaa !13
  %46 = zext i8 %45 to i32
  %47 = add nsw i32 %46, 4
  %48 = shl i32 1, %47
  %49 = load i8, ptr %4, align 1, !tbaa !13
  %50 = zext i8 %49 to i32
  %51 = or i32 %50, %48
  %52 = trunc i32 %51 to i8
  store i8 %52, ptr %4, align 1, !tbaa !13
  %53 = load i8, ptr %7, align 1, !tbaa !17, !range !19, !noundef !20
  %54 = trunc i8 %53 to i1
  br i1 %54, label %55, label %63

55:                                               ; preds = %33
  %56 = load i8, ptr %6, align 1, !tbaa !13
  %57 = zext i8 %56 to i32
  %58 = shl i32 1, %57
  %59 = load i8, ptr %4, align 1, !tbaa !13
  %60 = zext i8 %59 to i32
  %61 = or i32 %60, %58
  %62 = trunc i32 %61 to i8
  store i8 %62, ptr %4, align 1, !tbaa !13
  br label %63

63:                                               ; preds = %55, %33
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  br label %64

64:                                               ; preds = %63, %18
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %5, align 4, !tbaa !14
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %5, align 4, !tbaa !14
  br label %14, !llvm.loop !21

68:                                               ; preds = %17
  %69 = load i8, ptr %3, align 1, !tbaa !13
  %70 = load i8, ptr %4, align 1, !tbaa !13
  call void @_ZN11mackAlgoTwo7History3addEhh(i8 noundef zeroext %69, i8 noundef zeroext %70)
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret void
}

declare noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhhh(i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
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 = { 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, !7, i64 16}
!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 17}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!10, !7, i64 18}
!17 = !{!18, !18, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = distinct !{!21, !22}
!22 = !{!"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"

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

declare noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo9readWallsEv(ptr noundef nonnull align 8 dereferenceable(21) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load i8, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 17
  %5 = load i8, ptr %4, align 1, !tbaa !11
  %6 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext %3, i8 noundef zeroext %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 18
  %8 = load i8, ptr %7, align 2, !tbaa !12
  %9 = add i8 %8, 3
  %10 = and i8 %9, 3
  %11 = load i8, ptr %2, align 8, !tbaa !5
  %12 = load i8, ptr %4, align 1, !tbaa !11
  %13 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhhh(i8 noundef zeroext %11, i8 noundef zeroext %12, i8 noundef zeroext %10)
  br i1 %13, label %23, label %14

14:                                               ; preds = %1
  %15 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo8readWallEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %10)
  %16 = load i8, ptr %2, align 8, !tbaa !5
  %17 = load i8, ptr %4, align 1, !tbaa !11
  %18 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext %16, i8 noundef zeroext %17)
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo11setCellWallEhhbb(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %18, i8 noundef zeroext %10, i1 noundef zeroext %15, i1 noundef zeroext true)
  %19 = shl nuw i8 16, %10
  %20 = shl nuw nsw i8 1, %10
  %21 = select i1 %15, i8 %20, i8 0
  %22 = or disjoint i8 %21, %19
  br label %23

23:                                               ; preds = %14, %1
  %.2 = phi i8 [ 0, %1 ], [ %22, %14 ]
  %24 = load i8, ptr %7, align 2, !tbaa !12
  %25 = and i8 %24, 3
  %26 = load i8, ptr %2, align 8, !tbaa !5
  %27 = load i8, ptr %4, align 1, !tbaa !11
  %28 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhhh(i8 noundef zeroext %26, i8 noundef zeroext %27, i8 noundef zeroext %25)
  br i1 %28, label %38, label %29

29:                                               ; preds = %23
  %30 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo8readWallEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %25)
  %31 = load i8, ptr %2, align 8, !tbaa !5
  %32 = load i8, ptr %4, align 1, !tbaa !11
  %33 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext %31, i8 noundef zeroext %32)
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo11setCellWallEhhbb(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %33, i8 noundef zeroext %25, i1 noundef zeroext %30, i1 noundef zeroext true)
  %34 = shl nuw i8 16, %25
  %35 = shl nuw nsw i8 1, %25
  %36 = select i1 %30, i8 %35, i8 0
  %37 = or disjoint i8 %36, %34
  %.1.1 = or i8 %37, %.2
  br label %38

38:                                               ; preds = %29, %23
  %.2.1 = phi i8 [ %.2, %23 ], [ %.1.1, %29 ]
  %39 = load i8, ptr %7, align 2, !tbaa !12
  %40 = add i8 %39, 1
  %41 = and i8 %40, 3
  %42 = load i8, ptr %2, align 8, !tbaa !5
  %43 = load i8, ptr %4, align 1, !tbaa !11
  %44 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo4Maze7isKnownEhhh(i8 noundef zeroext %42, i8 noundef zeroext %43, i8 noundef zeroext %41)
  br i1 %44, label %54, label %45

45:                                               ; preds = %38
  %46 = tail call noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo8readWallEh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %41)
  %47 = load i8, ptr %2, align 8, !tbaa !5
  %48 = load i8, ptr %4, align 1, !tbaa !11
  %49 = tail call noundef zeroext i8 @_ZN11mackAlgoTwo4Maze7getCellEhh(i8 noundef zeroext %47, i8 noundef zeroext %48)
  tail call void @_ZN11mackAlgoTwo11MackAlgoTwo11setCellWallEhhbb(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %49, i8 noundef zeroext %41, i1 noundef zeroext %46, i1 noundef zeroext true)
  %50 = shl nuw i8 16, %41
  %51 = shl nuw nsw i8 1, %41
  %52 = select i1 %46, i8 %51, i8 0
  %53 = or disjoint i8 %52, %50
  %.1.2 = or i8 %53, %.2.1
  br label %54

54:                                               ; preds = %45, %38
  %.2.2 = phi i8 [ %.2.1, %38 ], [ %.1.2, %45 ]
  tail call void @_ZN11mackAlgoTwo7History3addEhh(i8 noundef zeroext %6, i8 noundef zeroext %.2.2)
  ret void
}

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

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

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

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

!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}
!12 = !{!6, !9, i64 18}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass