; LLVM IR from Whittler23/A-star-algorithm-SFML :: src/grid.ll (ZN4Grid13processEventsERN2sf5EventER14MousePositions)

; 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.sf::Event" = type { i32, %union.anon }
%union.anon = type { %"struct.sf::Event::MouseWheelScrollEvent" }
%"struct.sf::Event::MouseWheelScrollEvent" = type { i32, float, i32, i32 }
%struct.MousePositions = type { %"class.sf::Vector2.2", %"class.sf::Vector2" }
%"class.sf::Vector2.2" = type { float, float }
%"class.sf::Vector2" = type { i32, i32 }
%"struct.sf::Event::MouseButtonEvent" = type { i32, i32, i32 }

; 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
define dso_local void @_ZN4Grid13processEventsERN2sf5EventER14MousePositions(ptr noundef nonnull align 8 dereferenceable(61) %0, ptr noundef nonnull align 4 dereferenceable(20) %1, ptr noundef nonnull align 4 dereferenceable(16) %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.sf::Event", ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !9
  switch i32 %13, label %61 [
    i32 9, label %14
  ]

14:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.MousePositions, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %"class.sf::Vector2.2", ptr %16, i32 0, i32 0
  %18 = load float, ptr %17, align 4, !tbaa !12
  %19 = fptosi float %18 to i32
  store i32 %19, ptr %7, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.MousePositions, ptr %20, i32 0, i32 0
  %22 = getelementptr inbounds %"class.sf::Vector2.2", ptr %21, i32 0, i32 1
  %23 = load float, ptr %22, align 4, !tbaa !19
  %24 = fptosi float %23 to i32
  store i32 %24, ptr %8, align 4, !tbaa !18
  %25 = load i32, ptr %7, align 4, !tbaa !18
  %26 = load i32, ptr %8, align 4, !tbaa !18
  %27 = call noundef zeroext i1 @_ZN4Grid16isPositionProperEii(ptr noundef nonnull align 8 dereferenceable(61) %10, i32 noundef %25, i32 noundef %26)
  br i1 %27, label %29, label %28

28:                                               ; preds = %14
  store i32 1, ptr %9, align 4
  br label %58

29:                                               ; preds = %14
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.sf::Event", ptr %30, i32 0, i32 1
  %32 = getelementptr inbounds %"struct.sf::Event::MouseButtonEvent", ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !20
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %46

35:                                               ; preds = %29
  %36 = call noundef zeroext i1 @_ZN4Grid12getNodeToSetEv(ptr noundef nonnull align 8 dereferenceable(61) %10)
  br i1 %36, label %37, label %41

37:                                               ; preds = %35
  %38 = load i32, ptr %7, align 4, !tbaa !18
  %39 = load i32, ptr %8, align 4, !tbaa !18
  %40 = call noundef ptr @_ZN4Grid14getNodeInWorldEii(ptr noundef nonnull align 8 dereferenceable(61) %10, i32 noundef %38, i32 noundef %39)
  call void @_ZN4Grid15setStartingNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61) %10, ptr noundef %40)
  br label %45

41:                                               ; preds = %35
  %42 = load i32, ptr %7, align 4, !tbaa !18
  %43 = load i32, ptr %8, align 4, !tbaa !18
  %44 = call noundef ptr @_ZN4Grid14getNodeInWorldEii(ptr noundef nonnull align 8 dereferenceable(61) %10, i32 noundef %42, i32 noundef %43)
  call void @_ZN4Grid15setTargetedNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61) %10, ptr noundef %44)
  br label %45

45:                                               ; preds = %41, %37
  br label %57

46:                                               ; preds = %29
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.sf::Event", ptr %47, i32 0, i32 1
  %49 = getelementptr inbounds %"struct.sf::Event::MouseButtonEvent", ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !20
  %51 = icmp eq i32 %50, 1
  br i1 %51, label %52, label %56

52:                                               ; preds = %46
  %53 = load i32, ptr %7, align 4, !tbaa !18
  %54 = load i32, ptr %8, align 4, !tbaa !18
  %55 = call noundef ptr @_ZN4Grid14getNodeInWorldEii(ptr noundef nonnull align 8 dereferenceable(61) %10, i32 noundef %53, i32 noundef %54)
  call void @_ZN4Grid14handleObstacleEP4Node(ptr noundef nonnull align 8 dereferenceable(61) %10, ptr noundef %55)
  br label %56

56:                                               ; preds = %52, %46
  br label %57

57:                                               ; preds = %56, %45
  store i32 0, ptr %9, align 4
  br label %58

58:                                               ; preds = %57, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %59 = load i32, ptr %9, align 4
  switch i32 %59, label %62 [
    i32 0, label %60
    i32 1, label %61
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60, %58, %3
  ret void

62:                                               ; preds = %58
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Grid16isPositionProperEii(ptr noundef nonnull align 8 dereferenceable(61), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Grid12getNodeToSetEv(ptr noundef nonnull align 8 dereferenceable(61)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Grid15setStartingNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61), ptr noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4Grid14getNodeInWorldEii(ptr noundef nonnull align 8 dereferenceable(61), i32 noundef, i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Grid15setTargetedNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61), ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Grid14handleObstacleEP4Node(ptr noundef nonnull align 8 dereferenceable(61), ptr noundef) #1 align 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 = { 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 #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, !11, i64 0}
!10 = !{!"_ZTSN2sf5EventE", !11, i64 0, !7, i64 4}
!11 = !{!"_ZTSN2sf5Event9EventTypeE", !7, i64 0}
!12 = !{!13, !15, i64 0}
!13 = !{!"_ZTS14MousePositions", !14, i64 0, !16, i64 8}
!14 = !{!"_ZTSN2sf7Vector2IfEE", !15, i64 0, !15, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"_ZTSN2sf7Vector2IiEE", !17, i64 0, !17, i64 4}
!17 = !{!"int", !7, i64 0}
!18 = !{!17, !17, i64 0}
!19 = !{!13, !15, i64 4}
!20 = !{!7, !7, i64 0}


; 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
define dso_local void @_ZN4Grid13processEventsERN2sf5EventER14MousePositions(ptr noundef nonnull align 8 dereferenceable(61) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(20) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %2) local_unnamed_addr #0 align 2 {
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %cond = icmp eq i32 %4, 9
  br i1 %cond, label %5, label %22

5:                                                ; preds = %3
  %6 = load float, ptr %2, align 4, !tbaa !10
  %7 = fptosi float %6 to i32
  %8 = getelementptr inbounds i8, ptr %2, i64 4
  %9 = load float, ptr %8, align 4, !tbaa !16
  %10 = fptosi float %9 to i32
  %11 = tail call noundef zeroext i1 @_ZN4Grid16isPositionProperEii(ptr noundef nonnull align 8 dereferenceable(61) %0, i32 noundef %7, i32 noundef %10)
  br i1 %11, label %12, label %22

12:                                               ; preds = %5
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !17
  switch i32 %14, label %22 [
    i32 0, label %15
    i32 1, label %20
  ]

15:                                               ; preds = %12
  %16 = tail call noundef zeroext i1 @_ZN4Grid12getNodeToSetEv(ptr noundef nonnull align 8 dereferenceable(61) %0)
  %17 = tail call noundef ptr @_ZN4Grid14getNodeInWorldEii(ptr noundef nonnull align 8 dereferenceable(61) %0, i32 noundef %7, i32 noundef %10)
  br i1 %16, label %18, label %19

18:                                               ; preds = %15
  tail call void @_ZN4Grid15setStartingNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61) %0, ptr noundef %17)
  br label %22

19:                                               ; preds = %15
  tail call void @_ZN4Grid15setTargetedNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61) %0, ptr noundef %17)
  br label %22

20:                                               ; preds = %12
  %21 = tail call noundef ptr @_ZN4Grid14getNodeInWorldEii(ptr noundef nonnull align 8 dereferenceable(61) %0, i32 noundef %7, i32 noundef %10)
  tail call void @_ZN4Grid14handleObstacleEP4Node(ptr noundef nonnull align 8 dereferenceable(61) %0, ptr noundef %21)
  br label %22

22:                                               ; preds = %5, %12, %20, %18, %19, %3
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Grid16isPositionProperEii(ptr noundef nonnull align 8 dereferenceable(61), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN4Grid12getNodeToSetEv(ptr noundef nonnull align 8 dereferenceable(61)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Grid15setStartingNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4Grid14getNodeInWorldEii(ptr noundef nonnull align 8 dereferenceable(61), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Grid15setTargetedNodeEP4Node(ptr noundef nonnull align 8 dereferenceable(61), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Grid14handleObstacleEP4Node(ptr noundef nonnull align 8 dereferenceable(61), ptr noundef) local_unnamed_addr #0 align 2

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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN2sf5EventE", !7, i64 0, !8, i64 4}
!7 = !{!"_ZTSN2sf5Event9EventTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !13, i64 0}
!11 = !{!"_ZTS14MousePositions", !12, i64 0, !14, i64 8}
!12 = !{!"_ZTSN2sf7Vector2IfEE", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"_ZTSN2sf7Vector2IiEE", !15, i64 0, !15, i64 4}
!15 = !{!"int", !8, i64 0}
!16 = !{!11, !13, i64 4}
!17 = !{!8, !8, i64 0}


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