; LLVM IR from chronokings/huntercoin :: src/gamemovecreator.ll (Z15CheckLinearPathRKN4Game5CoordES2_)

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

%"struct.Game::CharacterState" = type <{ %"struct.Game::Coord", i8, [3 x i8], %"struct.Game::Coord", [4 x i8], %"class.std::vector", %"struct.Game::CollectedLootInfo", i8, [7 x i8] }>
%"struct.Game::Coord" = type { i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl" }
%"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl" = type { %"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.Game::CollectedLootInfo" = type { %"struct.Game::LootInfo", i32, i32 }
%"struct.Game::LootInfo" = type { i64, i32, i32 }

declare i32 @__gxx_personality_v0(...)

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z15CheckLinearPathRKN4Game5CoordES2_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1) #2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.Game::CharacterState", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr %5) #6
  call void @_ZN4Game14CharacterStateC2Ev(ptr noundef nonnull align 8 dereferenceable(73) %5)
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.Game::CharacterState", ptr %5, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  %10 = getelementptr inbounds %"struct.Game::CharacterState", ptr %5, i32 0, i32 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !9
  %11 = getelementptr inbounds %"struct.Game::CharacterState", ptr %5, i32 0, i32 5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZNSt6vectorIN4Game5CoordESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef nonnull align 4 dereferenceable(8) %12)
          to label %13 unwind label %20

13:                                               ; preds = %2
  br label %14

14:                                               ; preds = %19, %13
  %15 = getelementptr inbounds %"struct.Game::CharacterState", ptr %5, i32 0, i32 5
  %16 = call noundef zeroext i1 @_ZNKSt6vectorIN4Game5CoordESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #6
  %17 = xor i1 %16, true
  br i1 %17, label %18, label %24

18:                                               ; preds = %14
  invoke void @_ZN4Game14CharacterState19MoveTowardsWaypointEv(ptr noundef nonnull align 8 dereferenceable(73) %5)
          to label %19 unwind label %20

19:                                               ; preds = %18
  br label %14, !llvm.loop !12

20:                                               ; preds = %24, %18, %2
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %6, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %7, align 4
  call void @_ZN4Game14CharacterStateD2Ev(ptr noundef nonnull align 8 dereferenceable(73) %5) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #6
  br label %29

24:                                               ; preds = %14
  %25 = getelementptr inbounds %"struct.Game::CharacterState", ptr %5, i32 0, i32 0
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = invoke noundef zeroext i1 @_ZNK4Game5CoordeqERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %25, ptr noundef nonnull align 4 dereferenceable(8) %26)
          to label %28 unwind label %20

28:                                               ; preds = %24
  call void @_ZN4Game14CharacterStateD2Ev(ptr noundef nonnull align 8 dereferenceable(73) %5) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %5) #6
  ret i1 %27

29:                                               ; preds = %20
  %30 = load ptr, ptr %6, align 8
  %31 = load i32, ptr %7, align 4
  %32 = insertvalue { ptr, i32 } poison, ptr %30, 0
  %33 = insertvalue { ptr, i32 } %32, i32 %31, 1
  resume { ptr, i32 } %33
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Game14CharacterStateC2Ev(ptr noundef nonnull align 8 dereferenceable(73)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN4Game5CoordESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

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

declare void @_ZN4Game14CharacterState19MoveTowardsWaypointEv(ptr noundef nonnull align 8 dereferenceable(73)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4Game5CoordeqERKS0_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4Game14CharacterStateD2Ev(ptr noundef nonnull align 8 dereferenceable(73)) unnamed_addr #5 align 2

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


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

%"struct.Game::CharacterState" = type <{ %"struct.Game::Coord", i8, [3 x i8], %"struct.Game::Coord", [4 x i8], %"class.std::vector", %"struct.Game::CollectedLootInfo", i8, [7 x i8] }>
%"struct.Game::Coord" = type { i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl" }
%"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl" = type { %"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Game::Coord, std::allocator<Game::Coord>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.Game::CollectedLootInfo" = type { %"struct.Game::LootInfo", i32, i32 }
%"struct.Game::LootInfo" = type { i64, i32, i32 }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 noundef zeroext i1 @_Z15CheckLinearPathRKN4Game5CoordES2_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.Game::CharacterState", align 8
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %3) #5
  call void @_ZN4Game14CharacterStateC2Ev(ptr noundef nonnull align 8 dereferenceable(73) %3)
  %4 = load i64, ptr %0, align 4
  store i64 %4, ptr %3, align 8
  %5 = getelementptr inbounds i8, ptr %3, i64 12
  store i64 %4, ptr %5, align 4
  %6 = getelementptr inbounds i8, ptr %3, i64 24
  invoke void @_ZNSt6vectorIN4Game5CoordESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 4 dereferenceable(8) %1)
          to label %.preheader unwind label %.loopexit.split-lp

.preheader:                                       ; preds = %2, %8
  %7 = call noundef zeroext i1 @_ZNKSt6vectorIN4Game5CoordESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #5
  br i1 %7, label %10, label %8

8:                                                ; preds = %.preheader
  invoke void @_ZN4Game14CharacterState19MoveTowardsWaypointEv(ptr noundef nonnull align 8 dereferenceable(73) %3)
          to label %.preheader unwind label %.loopexit, !llvm.loop !5

.loopexit:                                        ; preds = %8
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %9

.loopexit.split-lp:                               ; preds = %2
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %9

9:                                                ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @_ZN4Game14CharacterStateD2Ev(ptr noundef nonnull align 8 dereferenceable(73) %3) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #5
  resume { ptr, i32 } %lpad.phi

10:                                               ; preds = %.preheader
  %11 = call noundef zeroext i1 @_ZNK4Game5CoordeqERKS0_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %1)
  call void @_ZN4Game14CharacterStateD2Ev(ptr noundef nonnull align 8 dereferenceable(73) %3) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %3) #5
  ret i1 %11
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Game14CharacterStateC2Ev(ptr noundef nonnull align 8 dereferenceable(73)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN4Game5CoordESaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #1 align 2

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

declare void @_ZN4Game14CharacterState19MoveTowardsWaypointEv(ptr noundef nonnull align 8 dereferenceable(73)) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4Game14CharacterStateD2Ev(ptr noundef nonnull align 8 dereferenceable(73)) unnamed_addr #4 align 2

attributes #0 = { mustprogress 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 = { "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 = { inlinehint 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 #5 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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