; LLVM IR from mackorone/mms :: old/v2/src/mouse/mackAlgo (MackAlgo)

; 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

declare void @_ZN8mackAlgo4Cell17setSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(53), i32 noundef) #1

declare void @_ZN8mackAlgo4Cell18setSourceDirectionEi(ptr noundef nonnull align 8 dereferenceable(53), i32 noundef) #1

declare void @_ZN8mackAlgo4Cell9setParentEPS0_(ptr noundef nonnull align 8 dereferenceable(53), ptr noundef) #1

declare void @_ZN8mackAlgo4Cell11setDistanceEf(ptr noundef nonnull align 8 dereferenceable(53), float noundef) #1

declare void @_ZN8mackAlgo4Cell11setExaminedEb(ptr noundef nonnull align 8 dereferenceable(53), i1 noundef zeroext) #1

declare noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53)) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8mackAlgo8MackAlgo15inspectNeighborEPNS_4CellES2_i(ptr noundef nonnull align 8 dereferenceable(14372) %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  store i8 0, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = call noundef float @_ZNK8mackAlgo4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(53) %12)
  store float %13, ptr %10, align 4, !tbaa !13
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = call noundef i32 @_ZNK8mackAlgo4Cell18getSourceDirectionEv(ptr noundef nonnull align 8 dereferenceable(53) %14)
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = icmp eq i32 %15, %16
  br i1 %17, label %18, label %25

18:                                               ; preds = %4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call noundef i32 @_ZNK8mackAlgo4Cell21getStraightAwayLengthEv(ptr noundef nonnull align 8 dereferenceable(53) %19)
  %21 = add nsw i32 %20, 1
  %22 = call noundef float @_ZN8mackAlgo8MackAlgo19getStraightAwayCostEi(ptr noundef nonnull align 8 dereferenceable(14372) %11, i32 noundef %21)
  %23 = load float, ptr %10, align 4, !tbaa !13
  %24 = fadd float %23, %22
  store float %24, ptr %10, align 4, !tbaa !13
  br label %29

25:                                               ; preds = %4
  %26 = call noundef float @_ZN8mackAlgo8MackAlgo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(14372) %11)
  %27 = load float, ptr %10, align 4, !tbaa !13
  %28 = fadd float %27, %26
  store float %28, ptr %10, align 4, !tbaa !13
  br label %29

29:                                               ; preds = %25, %18
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %30)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %32)
  %34 = icmp ne i32 %31, %33
  br i1 %34, label %40, label %35

35:                                               ; preds = %29
  %36 = load float, ptr %10, align 4, !tbaa !13
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call noundef float @_ZNK8mackAlgo4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(53) %37)
  %39 = fcmp olt float %36, %38
  br i1 %39, label %40, label %70

40:                                               ; preds = %35, %29
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %41)
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %43)
  %45 = icmp ne i32 %42, %44
  br i1 %45, label %46, label %51

46:                                               ; preds = %40
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %48)
  call void @_ZN8mackAlgo4Cell17setSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(53) %47, i32 noundef %49)
  store i8 1, ptr %9, align 1, !tbaa !11
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN8mackAlgo4Cell11setExaminedEb(ptr noundef nonnull align 8 dereferenceable(53) %50, i1 noundef zeroext false)
  br label %51

51:                                               ; preds = %46, %40
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN8mackAlgo4Cell9setParentEPS0_(ptr noundef nonnull align 8 dereferenceable(53) %52, ptr noundef %53)
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load float, ptr %10, align 4, !tbaa !13
  call void @_ZN8mackAlgo4Cell11setDistanceEf(ptr noundef nonnull align 8 dereferenceable(53) %54, float noundef %55)
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN8mackAlgo4Cell18setSourceDirectionEi(ptr noundef nonnull align 8 dereferenceable(53) %56, i32 noundef %57)
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = call noundef i32 @_ZNK8mackAlgo4Cell18getSourceDirectionEv(ptr noundef nonnull align 8 dereferenceable(53) %58)
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = icmp eq i32 %59, %60
  br i1 %61, label %62, label %67

62:                                               ; preds = %51
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call noundef i32 @_ZNK8mackAlgo4Cell21getStraightAwayLengthEv(ptr noundef nonnull align 8 dereferenceable(53) %64)
  %66 = add nsw i32 %65, 1
  call void @_ZN8mackAlgo4Cell21setStraightAwayLengthEi(ptr noundef nonnull align 8 dereferenceable(53) %63, i32 noundef %66)
  br label %69

67:                                               ; preds = %51
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN8mackAlgo4Cell21setStraightAwayLengthEi(ptr noundef nonnull align 8 dereferenceable(53) %68, i32 noundef 1)
  br label %69

69:                                               ; preds = %67, %62
  br label %70

70:                                               ; preds = %69, %35
  %71 = load i8, ptr %9, align 1, !tbaa !11, !range !15, !noundef !16
  %72 = trunc i8 %71 to i1
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  ret i1 %72
}

declare noundef i32 @_ZNK8mackAlgo4Cell18getSourceDirectionEv(ptr noundef nonnull align 8 dereferenceable(53)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN8mackAlgo8MackAlgo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(14372)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN8mackAlgo8MackAlgo19getStraightAwayCostEi(ptr noundef nonnull align 8 dereferenceable(14372), i32 noundef) #3 align 2

declare noundef float @_ZNK8mackAlgo4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(53)) #1

declare noundef i32 @_ZNK8mackAlgo4Cell21getStraightAwayLengthEv(ptr noundef nonnull align 8 dereferenceable(53)) #1

declare void @_ZN8mackAlgo4Cell21setStraightAwayLengthEi(ptr noundef nonnull align 8 dereferenceable(53), i32 noundef) #1

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 = { 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 #4 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}


; 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 @_ZN8mackAlgo4Cell17setSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(53), i32 noundef) local_unnamed_addr #0

declare void @_ZN8mackAlgo4Cell18setSourceDirectionEi(ptr noundef nonnull align 8 dereferenceable(53), i32 noundef) local_unnamed_addr #0

declare void @_ZN8mackAlgo4Cell9setParentEPS0_(ptr noundef nonnull align 8 dereferenceable(53), ptr noundef) local_unnamed_addr #0

declare void @_ZN8mackAlgo4Cell11setDistanceEf(ptr noundef nonnull align 8 dereferenceable(53), float noundef) local_unnamed_addr #0

declare void @_ZN8mackAlgo4Cell11setExaminedEb(ptr noundef nonnull align 8 dereferenceable(53), i1 noundef zeroext) local_unnamed_addr #0

declare noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8mackAlgo8MackAlgo15inspectNeighborEPNS_4CellES2_i(ptr noundef nonnull align 8 dereferenceable(14372) %0, ptr noundef nonnull %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = tail call noundef float @_ZNK8mackAlgo4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  %6 = tail call noundef i32 @_ZNK8mackAlgo4Cell18getSourceDirectionEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  %7 = icmp eq i32 %6, %3
  br i1 %7, label %8, label %12

8:                                                ; preds = %4
  %9 = tail call noundef i32 @_ZNK8mackAlgo4Cell21getStraightAwayLengthEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  %10 = add nsw i32 %9, 1
  %11 = tail call noundef float @_ZN8mackAlgo8MackAlgo19getStraightAwayCostEi(ptr noundef nonnull align 8 dereferenceable(14372) %0, i32 noundef %10)
  br label %14

12:                                               ; preds = %4
  %13 = tail call noundef float @_ZN8mackAlgo8MackAlgo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(14372) %0)
  br label %14

14:                                               ; preds = %12, %8
  %.pn = phi float [ %11, %8 ], [ %13, %12 ]
  %.0 = fadd float %5, %.pn
  %15 = tail call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %2)
  %16 = tail call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  %.not = icmp eq i32 %15, %16
  br i1 %.not, label %17, label %20

17:                                               ; preds = %14
  %18 = tail call noundef float @_ZNK8mackAlgo4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(53) %2)
  %19 = fcmp olt float %.0, %18
  br i1 %19, label %20, label %31

20:                                               ; preds = %17, %14
  %21 = tail call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %2)
  %22 = tail call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  %.not28 = icmp ne i32 %21, %22
  br i1 %.not28, label %23, label %25

23:                                               ; preds = %20
  %24 = tail call noundef i32 @_ZNK8mackAlgo4Cell17getSequenceNumberEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  tail call void @_ZN8mackAlgo4Cell17setSequenceNumberEi(ptr noundef nonnull align 8 dereferenceable(53) %2, i32 noundef %24)
  tail call void @_ZN8mackAlgo4Cell11setExaminedEb(ptr noundef nonnull align 8 dereferenceable(53) %2, i1 noundef zeroext false)
  br label %25

25:                                               ; preds = %23, %20
  tail call void @_ZN8mackAlgo4Cell9setParentEPS0_(ptr noundef nonnull align 8 dereferenceable(53) %2, ptr noundef nonnull %1)
  tail call void @_ZN8mackAlgo4Cell11setDistanceEf(ptr noundef nonnull align 8 dereferenceable(53) %2, float noundef %.0)
  tail call void @_ZN8mackAlgo4Cell18setSourceDirectionEi(ptr noundef nonnull align 8 dereferenceable(53) %2, i32 noundef %3)
  %26 = tail call noundef i32 @_ZNK8mackAlgo4Cell18getSourceDirectionEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  %27 = icmp eq i32 %26, %3
  br i1 %27, label %28, label %.sink.split

28:                                               ; preds = %25
  %29 = tail call noundef i32 @_ZNK8mackAlgo4Cell21getStraightAwayLengthEv(ptr noundef nonnull align 8 dereferenceable(53) %1)
  %30 = add nsw i32 %29, 1
  br label %.sink.split

.sink.split:                                      ; preds = %25, %28
  %.sink = phi i32 [ %30, %28 ], [ 1, %25 ]
  tail call void @_ZN8mackAlgo4Cell21setStraightAwayLengthEi(ptr noundef nonnull align 8 dereferenceable(53) %2, i32 noundef %.sink)
  br label %31

31:                                               ; preds = %.sink.split, %17
  %.1 = phi i1 [ false, %17 ], [ %.not28, %.sink.split ]
  ret i1 %.1
}

declare noundef i32 @_ZNK8mackAlgo4Cell18getSourceDirectionEv(ptr noundef nonnull align 8 dereferenceable(53)) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN8mackAlgo8MackAlgo11getTurnCostEv(ptr noundef nonnull align 8 dereferenceable(14372)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN8mackAlgo8MackAlgo19getStraightAwayCostEi(ptr noundef nonnull align 8 dereferenceable(14372), i32 noundef) local_unnamed_addr #2 align 2

declare noundef float @_ZNK8mackAlgo4Cell11getDistanceEv(ptr noundef nonnull align 8 dereferenceable(53)) local_unnamed_addr #0

declare noundef i32 @_ZNK8mackAlgo4Cell21getStraightAwayLengthEv(ptr noundef nonnull align 8 dereferenceable(53)) local_unnamed_addr #0

declare void @_ZN8mackAlgo4Cell21setStraightAwayLengthEi(ptr noundef nonnull align 8 dereferenceable(53), i32 noundef) local_unnamed_addr #0

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


; Effective O3 passes: AggressiveInstCombinePass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass