; LLVM IR from turi-code/SFrame :: oss_src/fileio/oss_webstor/asyncurl.ll (ZN7webstor8internal9AsyncLoop7destroyEPS1_)

; 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.webstor::internal::AsyncLoop" = type <{ ptr, i8, [7 x i8], %"class.webstor::internal::TaskCtrl", i32, [4 x i8], %"class.webstor::internal::SocketPool", %"class.webstor::internal::ExLockSync", ptr, %"class.std::vector", %"class.std::vector", i64, i8, [7 x i8] }>
%"class.webstor::internal::TaskCtrl" = type { %"class.webstor::internal::auto_scope" }
%"class.webstor::internal::auto_scope" = type { i64 }
%"class.webstor::internal::SocketPool" = type { ptr, %"class.webstor::internal::EventSync" }
%"class.webstor::internal::EventSync" = type <{ %union.pthread_mutex_t, %"class.std::set", i32, [4 x i8] }>
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<webstor::internal::EventWaiter *, webstor::internal::EventWaiter *, std::_Identity<webstor::internal::EventWaiter *>, std::less<webstor::internal::EventWaiter *>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<webstor::internal::EventWaiter *, webstor::internal::EventWaiter *, std::_Identity<webstor::internal::EventWaiter *>, std::less<webstor::internal::EventWaiter *>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.webstor::internal::ExLockSync" = type { %"union.webstor::internal::ExLockSync::Data" }
%"union.webstor::internal::ExLockSync::Data" = type { %union.pthread_mutex_t }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl" }
%"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl" = type { %"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7webstor8internal9AsyncLoop7destroyEPS1_(ptr noundef %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %14, %1
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %16

7:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %"class.webstor::internal::AsyncLoop", ptr %8, i32 0, i32 8
  %10 = load volatile ptr, ptr %9, align 8, !tbaa !9
  store ptr %10, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %14, label %13

13:                                               ; preds = %7
  call void @_ZN7webstor8internal9AsyncLoopD1Ev(ptr noundef nonnull align 8 dereferenceable(241) %11) #3
  call void @_ZdlPvm(ptr noundef %11, i64 noundef 248) #4
  br label %14

14:                                               ; preds = %13, %7
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %15, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %4, !llvm.loop !31

16:                                               ; preds = %4
  ret void
}

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

declare void @_ZN7webstor8internal9AsyncLoopD1Ev(ptr)

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nobuiltin nounwind "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 }
attributes #4 = { builtin 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, !6, i64 176}
!10 = !{!"_ZTSN7webstor8internal9AsyncLoopE", !6, i64 0, !11, i64 8, !12, i64 16, !15, i64 24, !16, i64 32, !26, i64 136, !6, i64 176, !27, i64 184, !27, i64 208, !14, i64 232, !11, i64 240}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSN7webstor8internal8TaskCtrlE", !13, i64 0}
!13 = !{!"_ZTSN7webstor8internal10auto_scopeImNS0_15TaskCtrlDeleterELy0EEE", !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN7webstor8internal10SocketPoolE", !6, i64 0, !17, i64 8}
!17 = !{!"_ZTSN7webstor8internal9EventSyncE", !7, i64 0, !18, i64 40, !15, i64 88}
!18 = !{!"_ZTSSt3setIPN7webstor8internal11EventWaiterESt4lessIS3_ESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE", !20, i64 0}
!20 = !{!"_ZTSNSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !21, i64 0, !23, i64 8}
!21 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN7webstor8internal11EventWaiterEEE", !22, i64 0}
!22 = !{!"_ZTSSt4lessIPN7webstor8internal11EventWaiterEE"}
!23 = !{!"_ZTSSt15_Rb_tree_header", !24, i64 0, !14, i64 32}
!24 = !{!"_ZTSSt18_Rb_tree_node_base", !25, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!25 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!26 = !{!"_ZTSN7webstor8internal10ExLockSyncE", !7, i64 0}
!27 = !{!"_ZTSSt6vectorIPvSaIS0_EE", !28, i64 0}
!28 = !{!"_ZTSSt12_Vector_baseIPvSaIS0_EE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIPvSaIS0_EE12_Vector_implE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIPvSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!31 = distinct !{!31, !32}
!32 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7webstor8internal9AsyncLoop7destroyEPS1_(ptr noundef %0) local_unnamed_addr #0 align 2 {
  %.not4 = icmp eq ptr %0, null
  br i1 %.not4, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.05 = phi ptr [ %3, %.lr.ph ], [ %0, %1 ]
  %2 = getelementptr inbounds i8, ptr %.05, i64 176
  %3 = load volatile ptr, ptr %2, align 8, !tbaa !5
  tail call void @_ZN7webstor8internal9AsyncLoopD1Ev(ptr noundef nonnull align 8 dereferenceable(241) %.05) #2
  tail call void @_ZdlPvm(ptr noundef nonnull %.05, i64 noundef 248) #3
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !30

._crit_edge:                                      ; preds = %.lr.ph, %1
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @_ZN7webstor8internal9AsyncLoopD1Ev(ptr) local_unnamed_addr

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" }
attributes #1 = { nobuiltin nounwind "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 = { nounwind }
attributes #3 = { builtin 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, !7, i64 176}
!6 = !{!"_ZTSN7webstor8internal9AsyncLoopE", !7, i64 0, !10, i64 8, !11, i64 16, !14, i64 24, !15, i64 32, !25, i64 136, !7, i64 176, !26, i64 184, !26, i64 208, !13, i64 232, !10, i64 240}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN7webstor8internal8TaskCtrlE", !12, i64 0}
!12 = !{!"_ZTSN7webstor8internal10auto_scopeImNS0_15TaskCtrlDeleterELy0EEE", !13, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"_ZTSN7webstor8internal10SocketPoolE", !7, i64 0, !16, i64 8}
!16 = !{!"_ZTSN7webstor8internal9EventSyncE", !8, i64 0, !17, i64 40, !14, i64 88}
!17 = !{!"_ZTSSt3setIPN7webstor8internal11EventWaiterESt4lessIS3_ESaIS3_EE", !18, i64 0}
!18 = !{!"_ZTSSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSNSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !20, i64 0, !22, i64 8}
!20 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN7webstor8internal11EventWaiterEEE", !21, i64 0}
!21 = !{!"_ZTSSt4lessIPN7webstor8internal11EventWaiterEE"}
!22 = !{!"_ZTSSt15_Rb_tree_header", !23, i64 0, !13, i64 32}
!23 = !{!"_ZTSSt18_Rb_tree_node_base", !24, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!24 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!25 = !{!"_ZTSN7webstor8internal10ExLockSyncE", !8, i64 0}
!26 = !{!"_ZTSSt6vectorIPvSaIS0_EE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIPvSaIS0_EE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIPvSaIS0_EE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIPvSaIS0_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!30 = distinct !{!30, !31}
!31 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass