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

; 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::AsyncCurl" = type { ptr, ptr }
%"struct.webstor::internal::AsyncState" = type { %"class.webstor::internal::EventSync", i32, i32, ptr }
%"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 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7webstor8internal9AsyncLoop8cancelOpEPv(ptr noundef nonnull align 8 dereferenceable(241), ptr noundef) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7webstor8internal9AsyncCurl8cancelOpEv(ptr noundef nonnull align 8 dereferenceable(16) %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.webstor::internal::AsyncCurl", ptr %3, i32 0, i32 1
  %5 = load ptr, ptr %4, align 8, !tbaa !9
  %6 = getelementptr inbounds %"struct.webstor::internal::AsyncState", ptr %5, i32 0, i32 3
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %16

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.webstor::internal::AsyncCurl", ptr %3, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %"struct.webstor::internal::AsyncState", ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %"class.webstor::internal::AsyncCurl", ptr %3, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !25
  call void @_ZN7webstor8internal9AsyncLoop8cancelOpEPv(ptr noundef nonnull align 8 dereferenceable(241) %13, ptr noundef %15)
  br label %16

16:                                               ; preds = %9, %1
  %17 = getelementptr inbounds %"class.webstor::internal::AsyncCurl", ptr %3, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = getelementptr inbounds %"struct.webstor::internal::AsyncState", ptr %18, i32 0, i32 3
  store ptr null, ptr %19, align 8, !tbaa !11
  %20 = getelementptr inbounds %"class.webstor::internal::AsyncCurl", ptr %3, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !25
  call void @_ZN7webstor8internal10AsyncState9setToCurlEPvPS1_(ptr noundef %21, ptr noundef null)
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7webstor8internal10AsyncState9setToCurlEPvPS1_(ptr noundef, ptr noundef) #1 align 2

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 = { 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" }

!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 8}
!10 = !{!"_ZTSN7webstor8internal9AsyncCurlE", !6, i64 0, !6, i64 8}
!11 = !{!12, !6, i64 104}
!12 = !{!"_ZTSN7webstor8internal10AsyncStateE", !13, i64 0, !24, i64 96, !23, i64 100, !6, i64 104}
!13 = !{!"_ZTSN7webstor8internal9EventSyncE", !7, i64 0, !14, i64 40, !23, i64 88}
!14 = !{!"_ZTSSt3setIPN7webstor8internal11EventWaiterESt4lessIS3_ESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE", !16, i64 0}
!16 = !{!"_ZTSNSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !17, i64 0, !19, i64 8}
!17 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN7webstor8internal11EventWaiterEEE", !18, i64 0}
!18 = !{!"_ZTSSt4lessIPN7webstor8internal11EventWaiterEE"}
!19 = !{!"_ZTSSt15_Rb_tree_header", !20, i64 0, !22, i64 32}
!20 = !{!"_ZTSSt18_Rb_tree_node_base", !21, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!21 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!"int", !7, i64 0}
!24 = !{!"_ZTS8CURLcode", !7, i64 0}
!25 = !{!10, !6, i64 0}


; 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 uwtable
declare dso_local void @_ZN7webstor8internal9AsyncLoop8cancelOpEPv(ptr noundef nonnull align 8 dereferenceable(241), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7webstor8internal9AsyncCurl8cancelOpEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %3, i64 104
  %5 = load ptr, ptr %4, align 8, !tbaa !10
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %8, label %6

6:                                                ; preds = %1
  %7 = load ptr, ptr %0, align 8, !tbaa !24
  tail call void @_ZN7webstor8internal9AsyncLoop8cancelOpEPv(ptr noundef nonnull align 8 dereferenceable(241) %5, ptr noundef %7)
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %6, %1
  %9 = phi ptr [ %.pre, %6 ], [ %3, %1 ]
  %10 = getelementptr inbounds i8, ptr %9, i64 104
  store ptr null, ptr %10, align 8, !tbaa !10
  %11 = load ptr, ptr %0, align 8, !tbaa !24
  tail call void @_ZN7webstor8internal10AsyncState9setToCurlEPvPS1_(ptr noundef %11, ptr noundef null)
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7webstor8internal10AsyncState9setToCurlEPvPS1_(ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

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 = { 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" }

!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 8}
!6 = !{!"_ZTSN7webstor8internal9AsyncCurlE", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 104}
!11 = !{!"_ZTSN7webstor8internal10AsyncStateE", !12, i64 0, !23, i64 96, !22, i64 100, !7, i64 104}
!12 = !{!"_ZTSN7webstor8internal9EventSyncE", !8, i64 0, !13, i64 40, !22, i64 88}
!13 = !{!"_ZTSSt3setIPN7webstor8internal11EventWaiterESt4lessIS3_ESaIS3_EE", !14, i64 0}
!14 = !{!"_ZTSSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSNSt8_Rb_treeIPN7webstor8internal11EventWaiterES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE13_Rb_tree_implIS7_Lb1EEE", !16, i64 0, !18, i64 8}
!16 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIPN7webstor8internal11EventWaiterEEE", !17, i64 0}
!17 = !{!"_ZTSSt4lessIPN7webstor8internal11EventWaiterEE"}
!18 = !{!"_ZTSSt15_Rb_tree_header", !19, i64 0, !21, i64 32}
!19 = !{!"_ZTSSt18_Rb_tree_node_base", !20, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!20 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!21 = !{!"long", !8, i64 0}
!22 = !{!"int", !8, i64 0}
!23 = !{!"_ZTS8CURLcode", !8, i64 0}
!24 = !{!6, !7, i64 0}


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