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

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

; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo8inCenterEhh(ptr noundef nonnull align 8 dereferenceable(21) %0, i8 noundef zeroext %1, i8 noundef zeroext %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !9
  store i8 %2, ptr %7, align 1, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #2
  store i8 7, ptr %8, align 1, !tbaa !9
  br label %12

12:                                               ; preds = %45, %3
  %13 = load i8, ptr %8, align 1, !tbaa !9
  %14 = zext i8 %13 to i32
  %15 = icmp sle i32 %14, 8
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  store i32 2, ptr %9, align 4
  br label %50

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #2
  store i8 7, ptr %10, align 1, !tbaa !9
  br label %18

18:                                               ; preds = %37, %17
  %19 = load i8, ptr %10, align 1, !tbaa !9
  %20 = zext i8 %19 to i32
  %21 = icmp sle i32 %20, 8
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 5, ptr %9, align 4
  br label %42

23:                                               ; preds = %18
  %24 = load i8, ptr %6, align 1, !tbaa !9
  %25 = zext i8 %24 to i32
  %26 = load i8, ptr %8, align 1, !tbaa !9
  %27 = zext i8 %26 to i32
  %28 = icmp eq i32 %25, %27
  br i1 %28, label %29, label %36

29:                                               ; preds = %23
  %30 = load i8, ptr %7, align 1, !tbaa !9
  %31 = zext i8 %30 to i32
  %32 = load i8, ptr %10, align 1, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = icmp eq i32 %31, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %29
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %42

36:                                               ; preds = %29, %23
  br label %37

37:                                               ; preds = %36
  %38 = load i8, ptr %10, align 1, !tbaa !9
  %39 = zext i8 %38 to i32
  %40 = add nsw i32 %39, 1
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %10, align 1, !tbaa !9
  br label %18, !llvm.loop !10

42:                                               ; preds = %35, %22
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #2
  %43 = load i32, ptr %9, align 4
  switch i32 %43, label %50 [
    i32 5, label %44
  ]

44:                                               ; preds = %42
  br label %45

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

50:                                               ; preds = %42, %16
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  %51 = load i32, ptr %9, align 4
  switch i32 %51, label %55 [
    i32 2, label %52
    i32 1, label %53
  ]

52:                                               ; preds = %50
  store i1 false, ptr %4, align 1
  br label %53

53:                                               ; preds = %52, %50
  %54 = load i1, ptr %4, align 1
  ret i1 %54

55:                                               ; preds = %50
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind 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 = { 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 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_ZN11mackAlgoTwo11MackAlgoTwo8inCenterEhh(ptr nocapture noundef nonnull readnone align 8 dereferenceable(21) %0, i8 noundef zeroext %1, i8 noundef zeroext %2) local_unnamed_addr #0 align 2 {
.preheader:
  switch i8 %1, label %.loopexit [
    i8 7, label %.preheader.split.preheader
    i8 8, label %.preheader.split.preheader.1
  ]

.preheader.split.preheader:                       ; preds = %.preheader
  %.off = add i8 %2, -7
  %switch = icmp ult i8 %.off, 2
  br i1 %switch, label %.loopexit.loopexit, label %.loopexit

.preheader.split.preheader.1:                     ; preds = %.preheader
  %.off30 = add i8 %2, -7
  %switch31 = icmp ult i8 %.off30, 2
  br i1 %switch31, label %.loopexit.loopexit, label %.loopexit

.loopexit.loopexit:                               ; preds = %.preheader.split.preheader.1, %.preheader.split.preheader
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader.split.preheader.1, %.preheader.split.preheader, %.preheader, %.loopexit.loopexit
  %3 = phi i1 [ true, %.loopexit.loopexit ], [ false, %.preheader.split.preheader ], [ false, %.preheader ], [ false, %.preheader.split.preheader.1 ]
  ret i1 %3
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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)"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass