; LLVM IR from mlcommons/tiny :: benchmark/interface/Middlewares/ST/threadx/common/src/tx_event_flags_cleanup.l_2d8e9bcf (cleanup)

; 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.TX_THREAD_STRUCT = type { i64, i64, ptr, ptr, ptr, i64, i64, i64, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, i64, %struct.TX_TIMER_INTERNAL_STRUCT, ptr, ptr, ptr, ptr, i64, ptr, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, ptr, ptr, ptr, i64 }
%struct.TX_TIMER_INTERNAL_STRUCT = type { i64, i64, ptr, i64, ptr, ptr, ptr }
%struct.TX_EVENT_FLAGS_GROUP_STRUCT = type { i64, ptr, i64, i32, ptr, i32, ptr, ptr, i64, ptr }

@_tx_thread_preempt_disable = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @_tx_event_flags_cleanup(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %11 = call i32 @__disable_interrupts()
  store i32 %11, ptr %5, align 4, !tbaa !11
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %12, i32 0, i32 20
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = icmp eq ptr %14, @_tx_event_flags_cleanup
  br i1 %15, label %16, label %103

16:                                               ; preds = %2
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %18, i32 0, i32 39
  %20 = load i64, ptr %19, align 8, !tbaa !16
  %21 = icmp eq i64 %17, %20
  br i1 %21, label %22, label %102

22:                                               ; preds = %16
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %23, i32 0, i32 21
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  store ptr %25, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %101

28:                                               ; preds = %22
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !18
  %32 = icmp eq i64 %31, 1146504270
  br i1 %32, label %33, label %100

33:                                               ; preds = %28
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %34, i32 0, i32 5
  %36 = load i32, ptr %35, align 8, !tbaa !20
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %99

38:                                               ; preds = %33
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %39, i32 0, i32 20
  store ptr null, ptr %40, align 8, !tbaa !13
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %41, i32 0, i32 5
  %43 = load i32, ptr %42, align 8, !tbaa !20
  store i32 %43, ptr %7, align 4, !tbaa !11
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !21
  store ptr %46, ptr %8, align 8, !tbaa !5
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %82

49:                                               ; preds = %38
  %50 = load i32, ptr %7, align 4, !tbaa !11
  %51 = add i32 %50, -1
  store i32 %51, ptr %7, align 4, !tbaa !11
  %52 = load i32, ptr %7, align 4, !tbaa !11
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %53, i32 0, i32 5
  store i32 %52, ptr %54, align 8, !tbaa !20
  %55 = load i32, ptr %7, align 4, !tbaa !11
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %60

57:                                               ; preds = %49
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %58, i32 0, i32 4
  store ptr null, ptr %59, align 8, !tbaa !21
  br label %81

60:                                               ; preds = %49
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %61, i32 0, i32 22
  %63 = load ptr, ptr %62, align 8, !tbaa !22
  store ptr %63, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %64, i32 0, i32 23
  %66 = load ptr, ptr %65, align 8, !tbaa !23
  store ptr %66, ptr %10, align 8, !tbaa !5
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %68, i32 0, i32 23
  store ptr %67, ptr %69, align 8, !tbaa !23
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %71, i32 0, i32 22
  store ptr %70, ptr %72, align 8, !tbaa !22
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = icmp eq ptr %73, %74
  br i1 %75, label %76, label %80

76:                                               ; preds = %60
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %78, i32 0, i32 4
  store ptr %77, ptr %79, align 8, !tbaa !21
  br label %80

80:                                               ; preds = %76, %60
  br label %81

81:                                               ; preds = %80, %57
  br label %85

82:                                               ; preds = %38
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.TX_EVENT_FLAGS_GROUP_STRUCT, ptr %83, i32 0, i32 3
  store i32 1, ptr %84, align 8, !tbaa !24
  br label %85

85:                                               ; preds = %82, %81
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %86, i32 0, i32 12
  %88 = load i32, ptr %87, align 4, !tbaa !25
  %89 = icmp eq i32 %88, 7
  br i1 %89, label %90, label %98

90:                                               ; preds = %85
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %91, i32 0, i32 27
  store i32 7, ptr %92, align 4, !tbaa !26
  %93 = load volatile i32, ptr @_tx_thread_preempt_disable, align 4, !tbaa !11
  %94 = add i32 %93, 1
  store volatile i32 %94, ptr @_tx_thread_preempt_disable, align 4, !tbaa !11
  %95 = load i32, ptr %5, align 4, !tbaa !11
  call void @__restore_interrupt(i32 noundef %95)
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_tx_thread_system_resume(ptr noundef %96)
  %97 = call i32 @__disable_interrupts()
  store i32 %97, ptr %5, align 4, !tbaa !11
  br label %98

98:                                               ; preds = %90, %85
  br label %99

99:                                               ; preds = %98, %33
  br label %100

100:                                              ; preds = %99, %28
  br label %101

101:                                              ; preds = %100, %22
  br label %102

102:                                              ; preds = %101, %16
  br label %103

103:                                              ; preds = %102, %2
  %104 = load i32, ptr %5, align 4, !tbaa !11
  call void @__restore_interrupt(i32 noundef %104)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #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: alwaysinline nounwind uwtable
declare hidden i32 @__disable_interrupts() #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @__restore_interrupt(i32 noundef) #2

declare void @_tx_thread_system_resume(ptr noundef) #3

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

attributes #0 = { 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 = { alwaysinline 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 = { "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 }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 192}
!14 = !{!"TX_THREAD_STRUCT", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !12, i64 92, !12, i64 96, !12, i64 100, !12, i64 104, !6, i64 112, !6, i64 120, !10, i64 128, !15, i64 136, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !6, i64 232, !12, i64 240, !12, i64 244, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !12, i64 280, !12, i64 284, !12, i64 288, !12, i64 292, !6, i64 296, !6, i64 304, !6, i64 312, !10, i64 320}
!15 = !{!"TX_TIMER_INTERNAL_STRUCT", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!16 = !{!14, !10, i64 320}
!17 = !{!14, !6, i64 200}
!18 = !{!19, !10, i64 0}
!19 = !{!"TX_EVENT_FLAGS_GROUP_STRUCT", !10, i64 0, !6, i64 8, !10, i64 16, !12, i64 24, !6, i64 32, !12, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !6, i64 72}
!20 = !{!19, !12, i64 40}
!21 = !{!19, !6, i64 32}
!22 = !{!14, !6, i64 208}
!23 = !{!14, !6, i64 216}
!24 = !{!19, !12, i64 24}
!25 = !{!14, !12, i64 92}
!26 = !{!14, !12, i64 244}


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

@_tx_thread_preempt_disable = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @_tx_event_flags_cleanup(ptr noundef %0, i64 noundef %1) #0 {
  %3 = tail call i32 @__disable_interrupts()
  %4 = getelementptr inbounds i8, ptr %0, i64 192
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = icmp eq ptr %5, @_tx_event_flags_cleanup
  br i1 %6, label %7, label %47

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 320
  %9 = load i64, ptr %8, align 8, !tbaa !13
  %10 = icmp eq i64 %9, %1
  br i1 %10, label %11, label %47

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %0, i64 200
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %47, label %14

14:                                               ; preds = %11
  %15 = load i64, ptr %13, align 8, !tbaa !15
  %16 = icmp eq i64 %15, 1146504270
  br i1 %16, label %17, label %47

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %13, i64 40
  %19 = load i32, ptr %18, align 8, !tbaa !17
  %.not33 = icmp eq i32 %19, 0
  br i1 %.not33, label %47, label %20

20:                                               ; preds = %17
  store ptr null, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %13, i64 32
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %.not34 = icmp eq ptr %22, null
  br i1 %.not34, label %36, label %23

23:                                               ; preds = %20
  %24 = add i32 %19, -1
  store i32 %24, ptr %18, align 8, !tbaa !17
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store ptr null, ptr %21, align 8, !tbaa !18
  br label %38

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %0, i64 208
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  %30 = getelementptr inbounds i8, ptr %0, i64 216
  %31 = load ptr, ptr %30, align 8, !tbaa !20
  %32 = getelementptr inbounds i8, ptr %29, i64 216
  store ptr %31, ptr %32, align 8, !tbaa !20
  %33 = getelementptr inbounds i8, ptr %31, i64 208
  store ptr %29, ptr %33, align 8, !tbaa !19
  %34 = icmp eq ptr %22, %0
  br i1 %34, label %35, label %38

35:                                               ; preds = %27
  store ptr %29, ptr %21, align 8, !tbaa !18
  br label %38

36:                                               ; preds = %20
  %37 = getelementptr inbounds i8, ptr %13, i64 24
  store i32 1, ptr %37, align 8, !tbaa !21
  br label %38

38:                                               ; preds = %26, %35, %27, %36
  %39 = getelementptr inbounds i8, ptr %0, i64 92
  %40 = load i32, ptr %39, align 4, !tbaa !22
  %41 = icmp eq i32 %40, 7
  br i1 %41, label %42, label %47

42:                                               ; preds = %38
  %43 = getelementptr inbounds i8, ptr %0, i64 244
  store i32 7, ptr %43, align 4, !tbaa !23
  %44 = load volatile i32, ptr @_tx_thread_preempt_disable, align 4, !tbaa !24
  %45 = add i32 %44, 1
  store volatile i32 %45, ptr @_tx_thread_preempt_disable, align 4, !tbaa !24
  tail call void @__restore_interrupt(i32 noundef %3)
  tail call void @_tx_thread_system_resume(ptr noundef nonnull %0) #3
  %46 = tail call i32 @__disable_interrupts()
  br label %47

47:                                               ; preds = %7, %14, %38, %42, %17, %11, %2
  %.0 = phi i32 [ %46, %42 ], [ %3, %38 ], [ %3, %17 ], [ %3, %14 ], [ %3, %11 ], [ %3, %7 ], [ %3, %2 ]
  tail call void @__restore_interrupt(i32 noundef %.0)
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__disable_interrupts() local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @__restore_interrupt(i32 noundef) local_unnamed_addr #1

declare void @_tx_thread_system_resume(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 = { alwaysinline 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 = { "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 }

!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, !10, i64 192}
!6 = !{!"TX_THREAD_STRUCT", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !11, i64 104, !10, i64 112, !10, i64 120, !7, i64 128, !12, i64 136, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216, !7, i64 224, !10, i64 232, !11, i64 240, !11, i64 244, !10, i64 248, !10, i64 256, !10, i64 264, !10, i64 272, !11, i64 280, !11, i64 284, !11, i64 288, !11, i64 292, !10, i64 296, !10, i64 304, !10, i64 312, !7, i64 320}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"TX_TIMER_INTERNAL_STRUCT", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!13 = !{!6, !7, i64 320}
!14 = !{!6, !10, i64 200}
!15 = !{!16, !7, i64 0}
!16 = !{!"TX_EVENT_FLAGS_GROUP_STRUCT", !7, i64 0, !10, i64 8, !7, i64 16, !11, i64 24, !10, i64 32, !11, i64 40, !10, i64 48, !10, i64 56, !7, i64 64, !10, i64 72}
!17 = !{!16, !11, i64 40}
!18 = !{!16, !10, i64 32}
!19 = !{!6, !10, i64 208}
!20 = !{!6, !10, i64 216}
!21 = !{!16, !11, i64 24}
!22 = !{!6, !11, i64 92}
!23 = !{!6, !11, i64 244}
!24 = !{!11, !11, i64 0}


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