; 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: mustprogress nounwind uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo22moveForwardUpdateStateEv(ptr noundef nonnull align 8 dereferenceable(21) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %3, i32 0, i32 4
  %5 = load i8, ptr %4, align 2, !tbaa !9
  %6 = zext i8 %5 to i32
  %7 = icmp eq i32 %6, 1
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  br label %16

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %3, i32 0, i32 4
  %11 = load i8, ptr %10, align 2, !tbaa !9
  %12 = zext i8 %11 to i32
  %13 = icmp eq i32 %12, 3
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, i32 -1, i32 0
  br label %16

16:                                               ; preds = %9, %8
  %17 = phi i32 [ 1, %8 ], [ %15, %9 ]
  %18 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %3, i32 0, i32 2
  %19 = load i8, ptr %18, align 8, !tbaa !12
  %20 = zext i8 %19 to i32
  %21 = add nsw i32 %20, %17
  %22 = trunc i32 %21 to i8
  store i8 %22, ptr %18, align 8, !tbaa !12
  %23 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %3, i32 0, i32 4
  %24 = load i8, ptr %23, align 2, !tbaa !9
  %25 = zext i8 %24 to i32
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %16
  br label %35

28:                                               ; preds = %16
  %29 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %3, i32 0, i32 4
  %30 = load i8, ptr %29, align 2, !tbaa !9
  %31 = zext i8 %30 to i32
  %32 = icmp eq i32 %31, 2
  %33 = zext i1 %32 to i64
  %34 = select i1 %32, i32 -1, i32 0
  br label %35

35:                                               ; preds = %28, %27
  %36 = phi i32 [ 1, %27 ], [ %34, %28 ]
  %37 = getelementptr inbounds %"class.mackAlgoTwo::MackAlgoTwo", ptr %3, i32 0, i32 3
  %38 = load i8, ptr %37, align 1, !tbaa !13
  %39 = zext i8 %38 to i32
  %40 = add nsw i32 %39, %36
  %41 = trunc i32 %40 to i8
  store i8 %41, ptr %37, align 1, !tbaa !13
  ret void
}

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

!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 18}
!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}


; 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(argmem: readwrite) uwtable
define dso_local void @_ZN11mackAlgoTwo11MackAlgoTwo22moveForwardUpdateStateEv(ptr nocapture noundef nonnull align 8 dereferenceable(21) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 18
  %3 = load i8, ptr %2, align 2, !tbaa !5
  %4 = icmp eq i8 %3, 1
  %5 = icmp eq i8 %3, 3
  %6 = sext i1 %5 to i8
  %7 = select i1 %4, i8 1, i8 %6
  %8 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load i8, ptr %8, align 8, !tbaa !11
  %10 = add i8 %7, %9
  store i8 %10, ptr %8, align 8, !tbaa !11
  %11 = icmp eq i8 %3, 0
  %12 = icmp eq i8 %3, 2
  %13 = sext i1 %12 to i8
  %14 = select i1 %11, i8 1, i8 %13
  %15 = getelementptr inbounds i8, ptr %0, i64 17
  %16 = load i8, ptr %15, align 1, !tbaa !12
  %17 = add i8 %14, %16
  store i8 %17, ptr %15, align 1, !tbaa !12
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !9, i64 18}
!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}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass