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

; 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.std::pair" = type { %struct.neighbor_iterator, %struct.neighbor_iterator }
%struct.neighbor_iterator = type { %"struct.Game::Coord", i32, i32 }
%"struct.Game::Coord" = type { 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
declare dso_local void @_Z9out_edgesN4Game5CoordERK4Maze(ptr dead_on_unwind noalias writable sret(%"struct.std::pair") align 4, i64, ptr noundef nonnull align 1 dereferenceable(1)) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z10out_degreeN4Game5CoordERK4Maze(i64 %0, ptr noundef nonnull align 1 dereferenceable(1) %1) #1 {
  %3 = alloca %"struct.Game::Coord", align 4
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca %"struct.Game::Coord", align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.neighbor_iterator, align 4
  store i64 %0, ptr %3, align 4
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %3, i64 8, i1 false), !tbaa.struct !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = load i64, ptr %6, align 4
  call void @_Z9out_edgesN4Game5CoordERK4Maze(ptr dead_on_unwind writable sret(%"struct.std::pair") align 4 %5, i64 %10, ptr noundef nonnull align 1 dereferenceable(1) %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !10
  br label %11

11:                                               ; preds = %15, %2
  %12 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %13 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %14 = call noundef zeroext i1 @_ZN5boost9iteratorsneI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lS2_S6_S7_S8_lEENS0_6detail23enable_if_interoperableIT_T4_NS_3mpl6apply2INS9_12always_bool2ESB_SC_E4typeEE4typeERKNS0_15iterator_facadeISB_T0_T1_T2_T3_EERKNSK_ISC_T5_T6_T7_T8_EE(ptr noundef nonnull align 1 dereferenceable(1) %12, ptr noundef nonnull align 1 dereferenceable(1) %13)
  br i1 %14, label %15, label %24

15:                                               ; preds = %11
  %16 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %17 = call { i64, i64 } @_ZN5boost9iteratorsppI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lEENS0_6detail24postfix_increment_resultIT_T0_T2_T1_E4typeERNS0_15iterator_facadeISB_SC_SE_SD_T3_EEi(ptr noundef nonnull align 1 dereferenceable(1) %16, i32 noundef 0)
  %18 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %19 = extractvalue { i64, i64 } %17, 0
  store i64 %19, ptr %18, align 4
  %20 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %21 = extractvalue { i64, i64 } %17, 1
  store i64 %21, ptr %20, align 4
  %22 = load i32, ptr %7, align 4, !tbaa !10
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %7, align 4, !tbaa !10
  br label %11, !llvm.loop !12

24:                                               ; preds = %11
  %25 = load i32, ptr %7, align 4, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  ret i32 %25
}

; 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) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5boost9iteratorsneI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lS2_S6_S7_S8_lEENS0_6detail23enable_if_interoperableIT_T4_NS_3mpl6apply2INS9_12always_bool2ESB_SC_E4typeEE4typeERKNS0_15iterator_facadeISB_T0_T1_T2_T3_EERKNSK_ISC_T5_T6_T7_T8_EE(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i64 } @_ZN5boost9iteratorsppI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lEENS0_6detail24postfix_increment_resultIT_T0_T2_T1_E4typeERNS0_15iterator_facadeISB_SC_SE_SD_T3_EEi(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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 = !{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.std::pair" = type { %struct.neighbor_iterator, %struct.neighbor_iterator }
%struct.neighbor_iterator = type { %"struct.Game::Coord", i32, i32 }
%"struct.Game::Coord" = type { i32, i32 }

; 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
declare dso_local void @_Z9out_edgesN4Game5CoordERK4Maze(ptr dead_on_unwind noalias writable sret(%"struct.std::pair") align 4, i64, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z10out_degreeN4Game5CoordERK4Maze(i64 %0, ptr noundef nonnull align 1 dereferenceable(1) %1) local_unnamed_addr #1 {
  %3 = alloca %"struct.std::pair", align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #3
  call void @_Z9out_edgesN4Game5CoordERK4Maze(ptr dead_on_unwind nonnull writable sret(%"struct.std::pair") align 4 %3, i64 %0, ptr noundef nonnull align 1 dereferenceable(1) %1)
  %4 = getelementptr inbounds i8, ptr %3, i64 16
  %5 = call noundef zeroext i1 @_ZN5boost9iteratorsneI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lS2_S6_S7_S8_lEENS0_6detail23enable_if_interoperableIT_T4_NS_3mpl6apply2INS9_12always_bool2ESB_SC_E4typeEE4typeERKNS0_15iterator_facadeISB_T0_T1_T2_T3_EERKNSK_ISC_T5_T6_T7_T8_EE(ptr noundef nonnull align 1 dereferenceable(1) %3, ptr noundef nonnull align 1 dereferenceable(1) %4)
  br i1 %5, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.04 = phi i32 [ %7, %.lr.ph ], [ 0, %2 ]
  %6 = call { i64, i64 } @_ZN5boost9iteratorsppI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lEENS0_6detail24postfix_increment_resultIT_T0_T2_T1_E4typeERNS0_15iterator_facadeISB_SC_SE_SD_T3_EEi(ptr noundef nonnull align 1 dereferenceable(1) %3, i32 noundef 0)
  %7 = add nuw nsw i32 %.04, 1
  %8 = call noundef zeroext i1 @_ZN5boost9iteratorsneI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lS2_S6_S7_S8_lEENS0_6detail23enable_if_interoperableIT_T4_NS_3mpl6apply2INS9_12always_bool2ESB_SC_E4typeEE4typeERKNS0_15iterator_facadeISB_T0_T1_T2_T3_EERKNSK_ISC_T5_T6_T7_T8_EE(ptr noundef nonnull align 1 dereferenceable(1) %3, ptr noundef nonnull align 1 dereferenceable(1) %4)
  br i1 %8, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %7, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #3
  ret i32 %.0.lcssa
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN5boost9iteratorsneI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lS2_S6_S7_S8_lEENS0_6detail23enable_if_interoperableIT_T4_NS_3mpl6apply2INS9_12always_bool2ESB_SC_E4typeEE4typeERKNS0_15iterator_facadeISB_T0_T1_T2_T3_EERKNSK_ISC_T5_T6_T7_T8_EE(ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local { i64, i64 } @_ZN5boost9iteratorsppI17neighbor_iteratorSt4pairIN4Game5CoordES5_ENS0_21forward_traversal_tagERS6_lEENS0_6detail24postfix_increment_resultIT_T0_T2_T1_E4typeERNS0_15iterator_facadeISB_SC_SE_SD_T3_EEi(ptr noundef nonnull align 1 dereferenceable(1), i32 noundef) local_unnamed_addr #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 = { inlinehint 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 = { 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,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass