; LLVM IR from differentprogramming/pauselessgc :: pevents/pevents.ll (ZN8neosmart8SetEventEPNS_17neosmart_event_t_E)

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

%"struct.neosmart::neosmart_event_t_" = type <{ %union.pthread_cond_t, %union.pthread_mutex_t, i8, %"struct.std::atomic", [6 x i8] }>
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%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 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i8 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E = external hidden unnamed_addr constant [41 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext, i32 noundef) #2 align 2

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

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN8neosmart8SetEventEPNS_17neosmart_event_t_E(ptr noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %6, i32 0, i32 1
  %8 = call i32 @pthread_mutex_lock(ptr noundef %7) #4
  store i32 %8, ptr %4, align 4, !tbaa !9
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  br label %14

12:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 365, ptr noundef @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #5
  unreachable

13:                                               ; No predecessors!
  br label %14

14:                                               ; preds = %13, %11
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %15, i32 0, i32 2
  %17 = load i8, ptr %16, align 8, !tbaa !11, !range !16, !noundef !17
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %40

19:                                               ; preds = %14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %20, i32 0, i32 3
  call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %21, i1 noundef zeroext true, i32 noundef 3) #4
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %22, i32 0, i32 1
  %24 = call i32 @pthread_mutex_unlock(ptr noundef %23) #4
  store i32 %24, ptr %4, align 4, !tbaa !9
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %19
  br label %30

28:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 453, ptr noundef @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #5
  unreachable

29:                                               ; No predecessors!
  br label %30

30:                                               ; preds = %29, %27
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %31, i32 0, i32 0
  %33 = call i32 @pthread_cond_signal(ptr noundef %32) #4
  store i32 %33, ptr %4, align 4, !tbaa !9
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %30
  br label %39

37:                                               ; preds = %30
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 456, ptr noundef @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #5
  unreachable

38:                                               ; No predecessors!
  br label %39

39:                                               ; preds = %38, %36
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %62

40:                                               ; preds = %14
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %41, i32 0, i32 3
  call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %42, i1 noundef zeroext true, i32 noundef 3) #4
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %43, i32 0, i32 1
  %45 = call i32 @pthread_mutex_unlock(ptr noundef %44) #4
  store i32 %45, ptr %4, align 4, !tbaa !9
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %49

48:                                               ; preds = %40
  br label %51

49:                                               ; preds = %40
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 518, ptr noundef @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #5
  unreachable

50:                                               ; No predecessors!
  br label %51

51:                                               ; preds = %50, %48
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.neosmart::neosmart_event_t_", ptr %52, i32 0, i32 0
  %54 = call i32 @pthread_cond_broadcast(ptr noundef %53) #4
  store i32 %54, ptr %4, align 4, !tbaa !9
  %55 = load i32, ptr %4, align 4, !tbaa !9
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %51
  br label %60

58:                                               ; preds = %51
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 521, ptr noundef @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #5
  unreachable

59:                                               ; No predecessors!
  br label %60

60:                                               ; preds = %59, %57
  br label %61

61:                                               ; preds = %60
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %62

62:                                               ; preds = %61, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %63 = load i32, ptr %2, align 4
  ret i32 %63
}

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_cond_broadcast(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { 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 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 88}
!12 = !{!"_ZTSN8neosmart17neosmart_event_t_E", !7, i64 0, !7, i64 48, !13, i64 88, !14, i64 89}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSSt6atomicIbE", !15, i64 0}
!15 = !{!"_ZTSSt13__atomic_baseIbE", !13, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}


; 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 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E = external hidden unnamed_addr constant [41 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN8neosmart8SetEventEPNS_17neosmart_event_t_E(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  %3 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %2) #3
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %6, label %5

5:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 365, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #4
  unreachable

6:                                                ; preds = %1
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  %8 = load i8, ptr %7, align 8, !tbaa !5, !range !12, !noundef !13
  %9 = trunc nuw i8 %8 to i1
  %10 = getelementptr inbounds i8, ptr %0, i64 89
  tail call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %10, i1 noundef zeroext true, i32 noundef 3) #3
  %11 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %2) #3
  %12 = icmp eq i32 %11, 0
  br i1 %9, label %13, label %19

13:                                               ; preds = %6
  br i1 %12, label %15, label %14

14:                                               ; preds = %13
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 453, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #4
  unreachable

15:                                               ; preds = %13
  %16 = tail call i32 @pthread_cond_signal(ptr noundef nonnull %0) #3
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %25, label %18

18:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 456, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #4
  unreachable

19:                                               ; preds = %6
  br i1 %12, label %21, label %20

20:                                               ; preds = %19
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 518, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #4
  unreachable

21:                                               ; preds = %19
  %22 = tail call i32 @pthread_cond_broadcast(ptr noundef nonnull %0) #3
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 521, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8neosmart8SetEventEPNS_17neosmart_event_t_E) #4
  unreachable

25:                                               ; preds = %21, %15
  ret i32 0
}

; Function Attrs: nounwind
declare i32 @pthread_cond_signal(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @pthread_cond_broadcast(ptr noundef) local_unnamed_addr #2

attributes #0 = { noreturn 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 = { 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 #2 = { 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 = { noreturn 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 88}
!6 = !{!"_ZTSN8neosmart17neosmart_event_t_E", !7, i64 0, !7, i64 48, !9, i64 88, !10, i64 89}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"bool", !7, i64 0}
!10 = !{!"_ZTSSt6atomicIbE", !11, i64 0}
!11 = !{!"_ZTSSt13__atomic_baseIbE", !9, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}


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