; LLVM IR from aspuru-guzik-group/qtorch :: XregGraphGen/main.ll (Z16alreadyConnectedSt10shared_ptrI9GraphNodeES1_)

; 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.anon = type { %"class.std::shared_ptr", ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%struct.GraphNode = type { i32, i8, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::shared_ptr<GraphNode>, std::allocator<std::shared_ptr<GraphNode>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::shared_ptr<GraphNode>, std::allocator<std::shared_ptr<GraphNode>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::shared_ptr<GraphNode>, std::allocator<std::shared_ptr<GraphNode>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::shared_ptr<GraphNode>, std::allocator<std::shared_ptr<GraphNode>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z16alreadyConnectedSt10shared_ptrI9GraphNodeES1_(ptr noundef %0, ptr noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca %class.anon, align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %class.anon, align 8
  %10 = alloca ptr, align 8
  %11 = 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 1, ptr %5) #4
  store i8 0, ptr %5, align 1, !tbaa !9
  %12 = call noundef ptr @_ZNKSt19__shared_ptr_accessI9GraphNodeLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #4
  %13 = getelementptr inbounds %struct.GraphNode, ptr %12, i32 0, i32 2
  %14 = call ptr @_ZNSt6vectorISt10shared_ptrI9GraphNodeESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #4
  %15 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %14, ptr %15, align 8
  %16 = call noundef ptr @_ZNKSt19__shared_ptr_accessI9GraphNodeLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #4
  %17 = getelementptr inbounds %struct.GraphNode, ptr %16, i32 0, i32 2
  %18 = call ptr @_ZNSt6vectorISt10shared_ptrI9GraphNodeESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #4
  %19 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  store ptr %18, ptr %19, align 8
  %20 = getelementptr inbounds %class.anon, ptr %9, i32 0, i32 0
  call void @_ZNSt10shared_ptrI9GraphNodeEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  %21 = getelementptr inbounds %class.anon, ptr %9, i32 0, i32 1
  store ptr %5, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8
  %24 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8
  invoke void @"_ZSt8for_eachIN9__gnu_cxx17__normal_iteratorIPSt10shared_ptrI9GraphNodeESt6vectorIS4_SaIS4_EEEEZ16alreadyConnectedS4_S4_E3$_0ET0_T_SC_SB_"(ptr dead_on_unwind writable sret(%class.anon) align 8 %6, ptr %23, ptr %25, ptr noundef %9)
          to label %26 unwind label %29

26:                                               ; preds = %2
  call void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24) %6) #4
  call void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24) %9) #4
  %27 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %28 = trunc i8 %27 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  ret i1 %28

29:                                               ; preds = %2
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %10, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, ptr %11, align 4
  call void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24) %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  br label %33

33:                                               ; preds = %29
  %34 = load ptr, ptr %10, align 8
  %35 = load i32, ptr %11, align 4
  %36 = insertvalue { ptr, i32 } poison, ptr %34, 0
  %37 = insertvalue { ptr, i32 } %36, i32 %35, 1
  resume { ptr, i32 } %37
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZSt8for_eachIN9__gnu_cxx17__normal_iteratorIPSt10shared_ptrI9GraphNodeESt6vectorIS4_SaIS4_EEEEZ16alreadyConnectedS4_S4_E3$_0ET0_T_SC_SB_"(ptr dead_on_unwind noalias writable sret(%class.anon) align 8, ptr, ptr, ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessI9GraphNodeLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrI9GraphNodeEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


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

%class.anon = type { %"class.std::shared_ptr", ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z16alreadyConnectedSt10shared_ptrI9GraphNodeES1_(ptr noundef nonnull %0, ptr noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i8, align 1
  %4 = alloca %class.anon, align 8
  %5 = alloca %class.anon, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #4
  store i8 0, ptr %3, align 1, !tbaa !5
  %6 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI9GraphNodeLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #4
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = tail call ptr @_ZNSt6vectorISt10shared_ptrI9GraphNodeESaIS2_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %9 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessI9GraphNodeLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %0) #4
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = tail call ptr @_ZNSt6vectorISt10shared_ptrI9GraphNodeESaIS2_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #4
  call void @_ZNSt10shared_ptrI9GraphNodeEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %1) #4
  %12 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %3, ptr %12, align 8, !tbaa !9
  invoke void @"_ZSt8for_eachIN9__gnu_cxx17__normal_iteratorIPSt10shared_ptrI9GraphNodeESt6vectorIS4_SaIS4_EEEEZ16alreadyConnectedS4_S4_E3$_0ET0_T_SC_SB_"(ptr dead_on_unwind nonnull writable sret(%class.anon) align 8 %4, ptr %8, ptr %11, ptr noundef nonnull %5)
          to label %13 unwind label %16

13:                                               ; preds = %2
  call void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  call void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  %14 = load i8, ptr %3, align 1, !tbaa !5, !range !11, !noundef !12
  %15 = trunc nuw i8 %14 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #4
  ret i1 %15

16:                                               ; preds = %2
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24) %5) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #4
  resume { ptr, i32 } %17
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZSt8for_eachIN9__gnu_cxx17__normal_iteratorIPSt10shared_ptrI9GraphNodeESt6vectorIS4_SaIS4_EEEEZ16alreadyConnectedS4_S4_E3$_0ET0_T_SC_SB_"(ptr dead_on_unwind noalias writable sret(%class.anon) align 8, ptr, ptr, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt19__shared_ptr_accessI9GraphNodeLN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrI9GraphNodeEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden void @"_ZZ16alreadyConnectedSt10shared_ptrI9GraphNodeES1_EN3$_0D2Ev"(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


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