; 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 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 @_ZN11mackAlgoTwo11MackAlgoTwo11colorCenterEc(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef signext %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 7, ptr %5, align 1, !tbaa !9
  br label %9

9:                                                ; preds = %34, %2
  %10 = load i8, ptr %5, align 1, !tbaa !9
  %11 = zext i8 %10 to i32
  %12 = icmp sle i32 %11, 8
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  br label %39

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 7, ptr %7, align 1, !tbaa !9
  br label %15

15:                                               ; preds = %28, %14
  %16 = load i8, ptr %7, align 1, !tbaa !9
  %17 = zext i8 %16 to i32
  %18 = icmp sle i32 %17, 8
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %15
  %21 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %8, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !10
  %23 = load i8, ptr %5, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = load i8, ptr %7, align 1, !tbaa !9
  %26 = zext i8 %25 to i32
  %27 = load i8, ptr %4, align 1, !tbaa !9
  call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %22, i32 noundef %24, i32 noundef %26, i8 noundef signext %27)
  br label %28

28:                                               ; preds = %20
  %29 = load i8, ptr %7, align 1, !tbaa !9
  %30 = zext i8 %29 to i32
  %31 = add nsw i32 %30, 1
  %32 = trunc i32 %31 to i8
  store i8 %32, ptr %7, align 1, !tbaa !9
  br label %15, !llvm.loop !13

33:                                               ; preds = %19
  br label %34

34:                                               ; preds = %33
  %35 = load i8, ptr %5, align 1, !tbaa !9
  %36 = zext i8 %35 to i32
  %37 = add nsw i32 %36, 1
  %38 = trunc i32 %37 to i8
  store i8 %38, ptr %5, align 1, !tbaa !9
  br label %9, !llvm.loop !15

39:                                               ; preds = %13
  ret void
}

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 @_ZN11mackAlgoTwo11MackAlgoTwo11colorCenterEc(ptr nocapture noundef nonnull readonly align 8 dereferenceable(21) %0, i8 noundef signext %1) local_unnamed_addr #1 align 2 {
.preheader:
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %3, i32 noundef 7, i32 noundef 7, i8 noundef signext %1)
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %4, i32 noundef 7, i32 noundef 8, i8 noundef signext %1)
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %5, i32 noundef 8, i32 noundef 7, i8 noundef signext %1)
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  tail call void @_ZN3sim14MouseInterface12setTileColorEiic(ptr noundef nonnull align 8 dereferenceable(296) %6, i32 noundef 8, i32 noundef 8, i8 noundef signext %1)
  ret void
}

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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass