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

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

@_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode = external hidden global i8, align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4Grid12getNodeToSetEv(ptr noundef nonnull align 8 dereferenceable(61) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %class.Grid, ptr %3, i32 0, i32 2
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = icmp ne ptr %5, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %1
  store i8 1, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !18
  br label %28

8:                                                ; preds = %1
  %9 = getelementptr inbounds %class.Grid, ptr %3, i32 0, i32 3
  %10 = load ptr, ptr %9, align 8, !tbaa !19
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  store i8 0, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !18
  br label %27

13:                                               ; preds = %8
  %14 = getelementptr inbounds %class.Grid, ptr %3, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = icmp ne ptr %15, null
  br i1 %16, label %17, label %26

17:                                               ; preds = %13
  %18 = getelementptr inbounds %class.Grid, ptr %3, i32 0, i32 3
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %26

21:                                               ; preds = %17
  %22 = load i8, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !18, !range !20, !noundef !21
  %23 = trunc i8 %22 to i1
  %24 = xor i1 %23, true
  %25 = zext i1 %24 to i8
  store i8 %25, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !18
  br label %26

26:                                               ; preds = %21, %17, %13
  br label %27

27:                                               ; preds = %26, %12
  br label %28

28:                                               ; preds = %27, %7
  %29 = load i8, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !18, !range !20, !noundef !21
  %30 = trunc i8 %29 to i1
  ret i1 %30
}

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


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

@_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode = external hidden local_unnamed_addr global i8, align 1

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: read, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_ZN4Grid12getNodeToSetEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(61) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %1
  store i8 1, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !17
  br label %13

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load ptr, ptr %6, align 8, !tbaa !18
  %.not1 = icmp eq ptr %7, null
  br i1 %.not1, label %8, label %9

8:                                                ; preds = %5
  store i8 0, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !17
  br label %13

9:                                                ; preds = %5
  %10 = load i8, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !17, !range !19, !noundef !20
  %11 = xor i8 %10, 1
  store i8 %11, ptr @_ZZN4Grid12getNodeToSetEvE21shouldSetStartingNode, align 1, !tbaa !17
  %12 = icmp eq i8 %10, 0
  br label %13

13:                                               ; preds = %8, %9, %4
  %14 = phi i1 [ false, %8 ], [ %12, %9 ], [ true, %4 ]
  ret i1 %14
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: read, inaccessiblemem: none) 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, !12, i64 32}
!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 = !{!16, !16, i64 0}
!18 = !{!6, !12, i64 40}
!19 = !{i8 0, i8 2}
!20 = !{}


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