; LLVM IR from mlcommons/tiny :: benchmark/interface/Middlewares/ST/threadx/common/src (tx_block_release)

; 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_BLOCK_POOL_STRUCT = type { i64, ptr, i32, i32, ptr, ptr, i64, i32, ptr, i32, ptr, ptr }
%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 }

@_tx_thread_preempt_disable = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @_tx_block_release(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %12 = call i32 @__disable_interrupts()
  store i32 %12, ptr %3, align 4, !tbaa !9
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %13, ptr %6, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 -8
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %16, ptr %8, align 8, !tbaa !5
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %18, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %19, i32 0, i32 8
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  store ptr %21, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %68

24:                                               ; preds = %1
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %25, i32 0, i32 9
  %27 = load i32, ptr %26, align 8, !tbaa !14
  %28 = add i32 %27, -1
  store i32 %28, ptr %26, align 8, !tbaa !14
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %29, i32 0, i32 9
  %31 = load i32, ptr %30, align 8, !tbaa !14
  store i32 %31, ptr %9, align 4, !tbaa !9
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %37

34:                                               ; preds = %24
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %35, i32 0, i32 8
  store ptr null, ptr %36, align 8, !tbaa !11
  br label %53

37:                                               ; preds = %24
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %38, i32 0, i32 22
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  store ptr %40, ptr %10, align 8, !tbaa !5
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %42, i32 0, i32 8
  store ptr %41, ptr %43, align 8, !tbaa !11
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %44, i32 0, i32 23
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  store ptr %46, ptr %11, align 8, !tbaa !5
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %48, i32 0, i32 23
  store ptr %47, ptr %49, align 8, !tbaa !18
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %51, i32 0, i32 22
  store ptr %50, ptr %52, align 8, !tbaa !15
  br label %53

53:                                               ; preds = %37, %34
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %54, i32 0, i32 20
  store ptr null, ptr %55, align 8, !tbaa !19
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %56, i32 0, i32 25
  %58 = load ptr, ptr %57, align 8, !tbaa !20
  store ptr %58, ptr %7, align 8, !tbaa !5
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr %59, ptr %6, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %60, ptr %61, align 8, !tbaa !5
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.TX_THREAD_STRUCT, ptr %62, i32 0, i32 27
  store i32 0, ptr %63, align 4, !tbaa !21
  %64 = load volatile i32, ptr @_tx_thread_preempt_disable, align 4, !tbaa !9
  %65 = add i32 %64, 1
  store volatile i32 %65, ptr @_tx_thread_preempt_disable, align 4, !tbaa !9
  %66 = load i32, ptr %3, align 4, !tbaa !9
  call void @__restore_interrupt(i32 noundef %66)
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_tx_thread_system_resume(ptr noundef %67)
  br label %81

68:                                               ; preds = %1
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %69, i32 0, i32 4
  %71 = load ptr, ptr %70, align 8, !tbaa !22
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %71, ptr %72, align 8, !tbaa !5
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %74, i32 0, i32 4
  store ptr %73, ptr %75, align 8, !tbaa !22
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.TX_BLOCK_POOL_STRUCT, ptr %76, i32 0, i32 2
  %78 = load i32, ptr %77, align 8, !tbaa !23
  %79 = add i32 %78, 1
  store i32 %79, ptr %77, align 8, !tbaa !23
  %80 = load i32, ptr %3, align 4, !tbaa !9
  call void @__restore_interrupt(i32 noundef %80)
  br label %81

81:                                               ; preds = %68, %53
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 0
}

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


; 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 noundef i32 @_tx_block_release(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @__disable_interrupts()
  %3 = getelementptr inbounds i8, ptr %0, i64 -8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 56
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %26, label %7

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %4, i64 64
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = add i32 %9, -1
  store i32 %10, ptr %8, align 8, !tbaa !13
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %19, label %12

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %6, i64 208
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %6, i64 216
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %14, i64 216
  store ptr %16, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %16, i64 208
  store ptr %14, ptr %18, align 8, !tbaa !14
  br label %19

19:                                               ; preds = %7, %12
  %.sink = phi ptr [ %14, %12 ], [ null, %7 ]
  store ptr %.sink, ptr %5, align 8
  %20 = getelementptr inbounds i8, ptr %6, i64 192
  store ptr null, ptr %20, align 8, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %6, i64 232
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  store ptr %0, ptr %22, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %6, i64 244
  store i32 0, ptr %23, align 4, !tbaa !20
  %24 = load volatile i32, ptr @_tx_thread_preempt_disable, align 4, !tbaa !21
  %25 = add i32 %24, 1
  store volatile i32 %25, ptr @_tx_thread_preempt_disable, align 4, !tbaa !21
  tail call void @__restore_interrupt(i32 noundef %2)
  tail call void @_tx_thread_system_resume(ptr noundef nonnull %6) #3
  br label %32

26:                                               ; preds = %1
  %27 = getelementptr inbounds i8, ptr %4, i64 24
  %28 = load ptr, ptr %27, align 8, !tbaa !22
  store ptr %28, ptr %3, align 8, !tbaa !5
  store ptr %3, ptr %27, align 8, !tbaa !22
  %29 = getelementptr inbounds i8, ptr %4, i64 16
  %30 = load i32, ptr %29, align 8, !tbaa !23
  %31 = add i32 %30, 1
  store i32 %31, ptr %29, align 8, !tbaa !23
  tail call void @__restore_interrupt(i32 noundef %2)
  br label %32

32:                                               ; preds = %26, %19
  ret i32 0
}

; 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 56}
!10 = !{!"TX_BLOCK_POOL_STRUCT", !11, i64 0, !6, i64 8, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 32, !11, i64 40, !12, i64 48, !6, i64 56, !12, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 64}
!14 = !{!15, !6, i64 208}
!15 = !{!"TX_THREAD_STRUCT", !11, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 48, !11, 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, !11, i64 128, !16, i64 136, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !11, 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, !11, i64 320}
!16 = !{!"TX_TIMER_INTERNAL_STRUCT", !11, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!17 = !{!15, !6, i64 216}
!18 = !{!15, !6, i64 192}
!19 = !{!15, !6, i64 232}
!20 = !{!15, !12, i64 244}
!21 = !{!12, !12, i64 0}
!22 = !{!10, !6, i64 24}
!23 = !{!10, !12, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass