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

; 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.Grid = type <{ %"class.sf::Drawable", %"class.std::vector", ptr, ptr, i32, i32, i32, i8, [3 x i8] }>
%"class.sf::Drawable" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::unique_ptr<Node>, std::allocator<std::unique_ptr<Node>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::unique_ptr<Node>, std::allocator<std::unique_ptr<Node>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::unique_ptr<Node>, std::allocator<std::unique_ptr<Node>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::unique_ptr<Node>, std::allocator<std::unique_ptr<Node>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4Grid16isPositionProperEii(ptr noundef nonnull align 8 dereferenceable(61) %0, i32 noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %8 = load ptr, ptr %5, align 8
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.Grid, ptr %8, i32 0, i32 6
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds %class.Grid, ptr %8, i32 0, i32 4
  %13 = load i32, ptr %12, align 8, !tbaa !19
  %14 = mul nsw i32 %11, %13
  %15 = getelementptr inbounds %class.Grid, ptr %8, i32 0, i32 6
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = add nsw i32 %14, %16
  %18 = icmp sgt i32 %9, %17
  br i1 %18, label %36, label %19

19:                                               ; preds = %3
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 0
  br i1 %21, label %36, label %22

22:                                               ; preds = %19
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = getelementptr inbounds %class.Grid, ptr %8, i32 0, i32 6
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %class.Grid, ptr %8, i32 0, i32 5
  %27 = load i32, ptr %26, align 4, !tbaa !20
  %28 = mul nsw i32 %25, %27
  %29 = getelementptr inbounds %class.Grid, ptr %8, i32 0, i32 6
  %30 = load i32, ptr %29, align 8, !tbaa !11
  %31 = add nsw i32 %28, %30
  %32 = icmp sgt i32 %23, %31
  br i1 %32, label %36, label %33

33:                                               ; preds = %22
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %33, %22, %19, %3
  store i1 false, ptr %4, align 1
  br label %38

37:                                               ; preds = %33
  store i1 true, ptr %4, align 1
  br label %38

38:                                               ; preds = %37, %36
  %39 = load i1, ptr %4, align 1
  ret i1 %39
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 56}
!12 = !{!"_ZTS4Grid", !13, i64 0, !14, i64 8, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !18, i64 60}
!13 = !{!"_ZTSN2sf8DrawableE"}
!14 = !{!"_ZTSSt6vectorISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"bool", !7, i64 0}
!19 = !{!12, !10, i64 48}
!20 = !{!12, !10, i64 52}


; 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: read) uwtable
define dso_local noundef zeroext i1 @_ZN4Grid16isPositionProperEii(ptr nocapture noundef nonnull readonly align 8 dereferenceable(61) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load i32, ptr %6, align 8, !tbaa !17
  %8 = add i32 %7, 1
  %9 = mul i32 %8, %5
  %10 = icmp slt i32 %9, %1
  %11 = icmp slt i32 %1, 0
  %or.cond = or i1 %11, %10
  br i1 %or.cond, label %19, label %12

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 52
  %14 = load i32, ptr %13, align 4, !tbaa !18
  %15 = add i32 %14, 1
  %16 = mul i32 %15, %5
  %17 = icmp sge i32 %16, %2
  %18 = icmp sgt i32 %2, -1
  %or.cond3.not = and i1 %18, %17
  br label %19

19:                                               ; preds = %12, %3
  %.0 = phi i1 [ false, %3 ], [ %or.cond3.not, %12 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !15, i64 56}
!6 = !{!"_ZTS4Grid", !7, i64 0, !8, i64 8, !12, i64 32, !12, i64 40, !15, i64 48, !15, i64 52, !15, i64 56, !16, i64 60}
!7 = !{!"_ZTSN2sf8DrawableE"}
!8 = !{!"_ZTSSt6vectorISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE", !9, i64 0}
!9 = !{!"_ZTSSt12_Vector_baseISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE12_Vector_implE", !11, i64 0}
!11 = !{!"_ZTSNSt12_Vector_baseISt10unique_ptrI4NodeSt14default_deleteIS1_EESaIS4_EE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"int", !13, i64 0}
!16 = !{!"bool", !13, i64 0}
!17 = !{!6, !15, i64 48}
!18 = !{!6, !15, i64 52}


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