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

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

@_tx_timer_created_count = external global i64, align 8
@_tx_timer_created_ptr = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @_tx_timer_create(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i64 %3, ptr %11, align 8, !tbaa !9
  store i64 %4, ptr %12, align 8, !tbaa !9
  store i64 %5, ptr %13, align 8, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %18, i8 0, i64 88, i1 false)
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %20, i32 0, i32 1
  store ptr %19, ptr %21, align 8, !tbaa !13
  %22 = load i64, ptr %12, align 8, !tbaa !9
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %23, i32 0, i32 2
  %25 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %24, i32 0, i32 0
  store i64 %22, ptr %25, align 8, !tbaa !16
  %26 = load i64, ptr %13, align 8, !tbaa !9
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %27, i32 0, i32 2
  %29 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %28, i32 0, i32 1
  store i64 %26, ptr %29, align 8, !tbaa !17
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %31, i32 0, i32 2
  %33 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %32, i32 0, i32 2
  store ptr %30, ptr %33, align 8, !tbaa !18
  %34 = load i64, ptr %11, align 8, !tbaa !9
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %35, i32 0, i32 2
  %37 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %36, i32 0, i32 3
  store i64 %34, ptr %37, align 8, !tbaa !19
  %38 = call i32 @__disable_interrupts()
  store i32 %38, ptr %15, align 4, !tbaa !11
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %39, i32 0, i32 0
  store i64 1096042829, ptr %40, align 8, !tbaa !20
  %41 = load i64, ptr @_tx_timer_created_count, align 8, !tbaa !9
  %42 = icmp eq i64 %41, 0
  br i1 %42, label %43, label %51

43:                                               ; preds = %7
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %44, ptr @_tx_timer_created_ptr, align 8, !tbaa !5
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %46, i32 0, i32 3
  store ptr %45, ptr %47, align 8, !tbaa !21
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %49, i32 0, i32 4
  store ptr %48, ptr %50, align 8, !tbaa !22
  br label %68

51:                                               ; preds = %7
  %52 = load ptr, ptr @_tx_timer_created_ptr, align 8, !tbaa !5
  store ptr %52, ptr %16, align 8, !tbaa !5
  %53 = load ptr, ptr %16, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %53, i32 0, i32 4
  %55 = load ptr, ptr %54, align 8, !tbaa !22
  store ptr %55, ptr %17, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load ptr, ptr %16, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %57, i32 0, i32 4
  store ptr %56, ptr %58, align 8, !tbaa !22
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = load ptr, ptr %17, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %60, i32 0, i32 3
  store ptr %59, ptr %61, align 8, !tbaa !21
  %62 = load ptr, ptr %17, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %63, i32 0, i32 4
  store ptr %62, ptr %64, align 8, !tbaa !22
  %65 = load ptr, ptr %16, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %66, i32 0, i32 3
  store ptr %65, ptr %67, align 8, !tbaa !21
  br label %68

68:                                               ; preds = %51, %43
  %69 = load i64, ptr @_tx_timer_created_count, align 8, !tbaa !9
  %70 = add i64 %69, 1
  store i64 %70, ptr @_tx_timer_created_count, align 8, !tbaa !9
  %71 = load i32, ptr %14, align 4, !tbaa !11
  %72 = icmp eq i32 %71, 1
  br i1 %72, label %73, label %76

73:                                               ; preds = %68
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %74, i32 0, i32 2
  call void @_tx_timer_system_activate(ptr noundef %75)
  br label %76

76:                                               ; preds = %73, %68
  %77 = load i32, ptr %15, align 4, !tbaa !11
  call void @__restore_interrupt(i32 noundef %77)
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

declare void @_tx_timer_system_activate(ptr noundef) #4

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @__restore_interrupt(i32 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #4 = { "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 = { 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 8}
!14 = !{!"TX_TIMER_STRUCT", !10, i64 0, !6, i64 8, !15, i64 16, !6, i64 72, !6, i64 80}
!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 16}
!17 = !{!14, !10, i64 24}
!18 = !{!14, !6, i64 32}
!19 = !{!14, !10, i64 40}
!20 = !{!14, !10, i64 0}
!21 = !{!14, !6, i64 72}
!22 = !{!14, !6, i64 80}


; 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_timer_created_count = external local_unnamed_addr global i64, align 8
@_tx_timer_created_ptr = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @_tx_timer_create(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(88) %0, i8 0, i64 88, i1 false)
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %4, ptr %9, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %5, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %2, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 %3, ptr %12, align 8, !tbaa !15
  %13 = tail call i32 @__disable_interrupts()
  store i64 1096042829, ptr %0, align 8, !tbaa !16
  %14 = load i64, ptr @_tx_timer_created_count, align 8, !tbaa !17
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %21, label %16

16:                                               ; preds = %7
  %17 = load ptr, ptr @_tx_timer_created_ptr, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %17, i64 80
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  store ptr %0, ptr %18, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %19, i64 72
  br label %21

21:                                               ; preds = %7, %16
  %.sink29 = phi ptr [ %20, %16 ], [ @_tx_timer_created_ptr, %7 ]
  %.sink28 = phi ptr [ %17, %16 ], [ %0, %7 ]
  %.sink = phi ptr [ %19, %16 ], [ %0, %7 ]
  store ptr %0, ptr %.sink29, align 8, !tbaa !18
  %22 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %.sink28, ptr %22, align 8
  %23 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr %.sink, ptr %23, align 8
  %24 = add i64 %14, 1
  store i64 %24, ptr @_tx_timer_created_count, align 8, !tbaa !17
  %25 = icmp eq i32 %6, 1
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  tail call void @_tx_timer_system_activate(ptr noundef nonnull %9) #4
  br label %27

27:                                               ; preds = %26, %21
  tail call void @__restore_interrupt(i32 noundef %13)
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

declare void @_tx_timer_system_activate(ptr noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @__restore_interrupt(i32 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 8}
!6 = !{!"TX_TIMER_STRUCT", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 72, !10, i64 80}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"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}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 24}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !7, i64 40}
!16 = !{!6, !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !10, i64 80}


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