; LLVM IR from vczh/herodb :: Kernel/Source/Vlpp.ll (ZN2vl11EventObject6SignalEv)

; 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.vl::EventObject" = type { %"class.vl::WaitableObject", ptr }
%"class.vl::WaitableObject" = type { %"class.vl::Object" }
%"class.vl::Object" = type { ptr }
%"struct.vl::threading_internal::EventData" = type { i8, i8, %"class.vl::CriticalSection", %"class.vl::ConditionVariable", i64 }
%"class.vl::CriticalSection" = type { %"class.vl::Object", ptr }
%"class.vl::ConditionVariable" = type { %"class.vl::Object", ptr }

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

8:                                                ; preds = %1
  store i1 false, ptr %2, align 1
  br label %43

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %11, i32 0, i32 2
  call void @_ZN2vl15CriticalSection5EnterEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %13 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %14, i32 0, i32 1
  store volatile i8 1, ptr %15, align 1, !tbaa !13
  %16 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %17, i32 0, i32 4
  %19 = load volatile i64, ptr %18, align 8, !tbaa !19
  %20 = icmp ne i64 %19, 0
  br i1 %20, label %21, label %39

21:                                               ; preds = %9
  %22 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %23, i32 0, i32 0
  %25 = load i8, ptr %24, align 8, !tbaa !20, !range !21, !noundef !22
  %26 = trunc i8 %25 to i1
  br i1 %26, label %27, label %34

27:                                               ; preds = %21
  %28 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %29, i32 0, i32 3
  call void @_ZN2vl17ConditionVariable14WakeOnePendingEv(ptr noundef nonnull align 8 dereferenceable(16) %30)
  %31 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %32, i32 0, i32 1
  store volatile i8 0, ptr %33, align 1, !tbaa !13
  br label %38

34:                                               ; preds = %21
  %35 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %36, i32 0, i32 3
  call void @_ZN2vl17ConditionVariable15WakeAllPendingsEv(ptr noundef nonnull align 8 dereferenceable(16) %37)
  br label %38

38:                                               ; preds = %34, %27
  br label %39

39:                                               ; preds = %38, %9
  %40 = getelementptr inbounds %"class.vl::EventObject", ptr %4, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %41, i32 0, i32 2
  call void @_ZN2vl15CriticalSection5LeaveEv(ptr noundef nonnull align 8 dereferenceable(16) %42)
  store i1 true, ptr %2, align 1
  br label %43

43:                                               ; preds = %39, %8
  %44 = load i1, ptr %2, align 1
  ret i1 %44
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl15CriticalSection5LeaveEv(ptr noundef nonnull align 8 dereferenceable(16)) #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 = { 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 8}
!10 = !{!"_ZTSN2vl11EventObjectE", !11, i64 0, !6, i64 8}
!11 = !{!"_ZTSN2vl14WaitableObjectE", !12, i64 0}
!12 = !{!"_ZTSN2vl6ObjectE"}
!13 = !{!14, !15, i64 1}
!14 = !{!"_ZTSN2vl18threading_internal9EventDataE", !15, i64 0, !15, i64 1, !16, i64 8, !17, i64 24, !18, i64 40}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSN2vl15CriticalSectionE", !12, i64 0, !6, i64 8}
!17 = !{!"_ZTSN2vl17ConditionVariableE", !12, i64 0, !6, i64 8}
!18 = !{!"long", !7, i64 0}
!19 = !{!14, !18, i64 40}
!20 = !{!14, !15, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}


; 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 noundef zeroext i1 @_ZN2vl11EventObject6SignalEv(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
  %.not = icmp ne ptr %3, null
  br i1 %.not, label %4, label %21

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  tail call void @_ZN2vl15CriticalSection5EnterEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 1
  store volatile i8 1, ptr %7, align 1, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %6, i64 40
  %9 = load volatile i64, ptr %8, align 8, !tbaa !18
  %.not3 = icmp eq i64 %9, 0
  br i1 %.not3, label %18, label %10

10:                                               ; preds = %4
  %11 = load i8, ptr %6, align 8, !tbaa !19, !range !20, !noundef !21
  %12 = trunc nuw i8 %11 to i1
  %13 = getelementptr inbounds i8, ptr %6, i64 24
  br i1 %12, label %14, label %17

14:                                               ; preds = %10
  tail call void @_ZN2vl17ConditionVariable14WakeOnePendingEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 1
  store volatile i8 0, ptr %16, align 1, !tbaa !12
  br label %18

17:                                               ; preds = %10
  tail call void @_ZN2vl17ConditionVariable15WakeAllPendingsEv(ptr noundef nonnull align 8 dereferenceable(16) %13)
  %.pre = load ptr, ptr %2, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %14, %17, %4
  %19 = phi ptr [ %15, %14 ], [ %.pre, %17 ], [ %6, %4 ]
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  tail call void @_ZN2vl15CriticalSection5LeaveEv(ptr noundef nonnull align 8 dereferenceable(16) %20)
  br label %21

21:                                               ; preds = %1, %18
  ret i1 %.not
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl15CriticalSection5EnterEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl17ConditionVariable14WakeOnePendingEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl17ConditionVariable15WakeAllPendingsEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl15CriticalSection5LeaveEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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, !9, i64 8}
!6 = !{!"_ZTSN2vl11EventObjectE", !7, i64 0, !9, i64 8}
!7 = !{!"_ZTSN2vl14WaitableObjectE", !8, i64 0}
!8 = !{!"_ZTSN2vl6ObjectE"}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!13, !14, i64 1}
!13 = !{!"_ZTSN2vl18threading_internal9EventDataE", !14, i64 0, !14, i64 1, !15, i64 8, !16, i64 24, !17, i64 40}
!14 = !{!"bool", !10, i64 0}
!15 = !{!"_ZTSN2vl15CriticalSectionE", !8, i64 0, !9, i64 8}
!16 = !{!"_ZTSN2vl17ConditionVariableE", !8, i64 0, !9, i64 8}
!17 = !{!"long", !10, i64 0}
!18 = !{!13, !17, i64 40}
!19 = !{!13, !14, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}


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