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

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

@.str.2 = external hidden unnamed_addr constant [1 x i32], align 4

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl12ObjectStringIwEneEPKw(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl11EventObject18CreateAutoUnsignalEbRKNS_12ObjectStringIwEE(ptr noundef nonnull align 8 dereferenceable(16) %0, i1 noundef zeroext %1, ptr noundef nonnull align 8 dereferenceable(48) %2) #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = zext i1 %1 to i8
  store i8 %10, ptr %6, align 1, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = call noundef zeroext i1 @_ZNK2vl12ObjectStringIwEneEPKw(ptr noundef nonnull align 8 dereferenceable(48) %12, ptr noundef @.str.2)
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  br label %37

15:                                               ; preds = %3
  %16 = getelementptr inbounds %"class.vl::EventObject", ptr %11, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  store i1 false, ptr %4, align 1
  br label %37

20:                                               ; preds = %15
  %21 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #5
  invoke void @_ZN2vl18threading_internal9EventDataC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %21)
          to label %22 unwind label %33

22:                                               ; preds = %20
  %23 = getelementptr inbounds %"class.vl::EventObject", ptr %11, i32 0, i32 1
  store ptr %21, ptr %23, align 8, !tbaa !11
  %24 = getelementptr inbounds %"class.vl::EventObject", ptr %11, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %25, i32 0, i32 0
  store i8 1, ptr %26, align 8, !tbaa !15
  %27 = load i8, ptr %6, align 1, !tbaa !9, !range !20, !noundef !21
  %28 = trunc i8 %27 to i1
  %29 = getelementptr inbounds %"class.vl::EventObject", ptr %11, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !11
  %31 = getelementptr inbounds %"struct.vl::threading_internal::EventData", ptr %30, i32 0, i32 1
  %32 = zext i1 %28 to i8
  store volatile i8 %32, ptr %31, align 1, !tbaa !22
  store i1 true, ptr %4, align 1
  br label %37

33:                                               ; preds = %20
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %8, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %9, align 4
  call void @_ZdlPvm(ptr noundef %21, i64 noundef 48) #6
  br label %39

37:                                               ; preds = %22, %19, %14
  %38 = load i1, ptr %4, align 1
  ret i1 %38

39:                                               ; preds = %33
  %40 = load ptr, ptr %8, align 8
  %41 = load i32, ptr %9, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN2vl18threading_internal9EventDataC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

attributes #0 = { 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 #1 = { nobuiltin allocsize(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 #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 = { 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 #4 = { 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" }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN2vl11EventObjectE", !13, i64 0, !6, i64 8}
!13 = !{!"_ZTSN2vl14WaitableObjectE", !14, i64 0}
!14 = !{!"_ZTSN2vl6ObjectE"}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTSN2vl18threading_internal9EventDataE", !10, i64 0, !10, i64 1, !17, i64 8, !18, i64 24, !19, i64 40}
!17 = !{!"_ZTSN2vl15CriticalSectionE", !14, i64 0, !6, i64 8}
!18 = !{!"_ZTSN2vl17ConditionVariableE", !14, i64 0, !6, i64 8}
!19 = !{!"long", !7, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!16, !10, i64 1}


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

@.str.2 = external hidden unnamed_addr constant [1 x i32], align 4

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl12ObjectStringIwEneEPKw(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl11EventObject18CreateAutoUnsignalEbRKNS_12ObjectStringIwEE(ptr nocapture noundef nonnull align 8 dereferenceable(16) %0, i1 noundef zeroext %1, ptr noundef nonnull align 8 dereferenceable(48) %2) local_unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %4 = zext i1 %1 to i8
  %5 = tail call noundef zeroext i1 @_ZNK2vl12ObjectStringIwEneEPKw(ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull @.str.2)
  br i1 %5, label %15, label %6

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

9:                                                ; preds = %6
  %10 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #5
  invoke void @_ZN2vl18threading_internal9EventDataC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %10)
          to label %11 unwind label %13

11:                                               ; preds = %9
  store ptr %10, ptr %7, align 8, !tbaa !5
  store i8 1, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %10, i64 1
  store volatile i8 %4, ptr %12, align 1, !tbaa !18
  br label %15

13:                                               ; preds = %9
  %14 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %10, i64 noundef 48) #6
  resume { ptr, i32 } %14

15:                                               ; preds = %6, %3, %11
  %.0 = phi i1 [ true, %11 ], [ false, %3 ], [ false, %6 ]
  ret i1 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN2vl18threading_internal9EventDataC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

attributes #0 = { 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 #1 = { nobuiltin allocsize(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 #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 = { 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 #4 = { 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" }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { 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, !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 0}
!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, !14, i64 1}


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