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

; 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_list_start = external global ptr, align 8
@_tx_timer_list_end = external global ptr, align 8
@_tx_timer_current_ptr = external global ptr, align 8
@_tx_timer_expired_timer_ptr = external global ptr, align 8

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

22:                                               ; preds = %6
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %23, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %25, ptr %26, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %22, %6
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %28, i32 0, i32 2
  store ptr %29, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %17, align 4, !tbaa !9
  %30 = load ptr, ptr %14, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %30, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !15
  store i64 %32, ptr %16, align 8, !tbaa !16
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %33, i32 0, i32 6
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %117

37:                                               ; preds = %27
  store i32 1, ptr %17, align 4, !tbaa !9
  store i32 0, ptr %18, align 4, !tbaa !9
  %38 = load ptr, ptr %14, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %38, i32 0, i32 6
  %40 = load ptr, ptr %39, align 8, !tbaa !17
  %41 = load ptr, ptr @_tx_timer_list_start, align 8, !tbaa !5
  %42 = icmp uge ptr %40, %41
  br i1 %42, label %43, label %51

43:                                               ; preds = %37
  %44 = load ptr, ptr %14, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %44, i32 0, i32 6
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = load ptr, ptr @_tx_timer_list_end, align 8, !tbaa !5
  %48 = icmp ult ptr %46, %47
  br i1 %48, label %49, label %50

49:                                               ; preds = %43
  store i32 1, ptr %18, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %49, %43
  br label %51

51:                                               ; preds = %50, %37
  %52 = load i32, ptr %18, align 4, !tbaa !9
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %54, label %100

54:                                               ; preds = %51
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  store ptr %57, ptr %15, align 8, !tbaa !5
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %58, i32 0, i32 6
  %60 = load ptr, ptr %59, align 8, !tbaa !17
  %61 = load ptr, ptr @_tx_timer_current_ptr, align 8, !tbaa !5
  %62 = icmp uge ptr %60, %61
  br i1 %62, label %63, label %71

63:                                               ; preds = %54
  %64 = load ptr, ptr %15, align 8, !tbaa !5
  %65 = load ptr, ptr @_tx_timer_current_ptr, align 8, !tbaa !5
  %66 = ptrtoint ptr %64 to i64
  %67 = ptrtoint ptr %65 to i64
  %68 = sub i64 %66, %67
  %69 = sdiv exact i64 %68, 8
  %70 = add i64 %69, 1
  store i64 %70, ptr %16, align 8, !tbaa !16
  br label %87

71:                                               ; preds = %54
  %72 = load ptr, ptr %15, align 8, !tbaa !5
  %73 = load ptr, ptr @_tx_timer_list_start, align 8, !tbaa !5
  %74 = ptrtoint ptr %72 to i64
  %75 = ptrtoint ptr %73 to i64
  %76 = sub i64 %74, %75
  %77 = sdiv exact i64 %76, 8
  store i64 %77, ptr %16, align 8, !tbaa !16
  %78 = load i64, ptr %16, align 8, !tbaa !16
  %79 = load ptr, ptr @_tx_timer_list_end, align 8, !tbaa !5
  %80 = load ptr, ptr @_tx_timer_current_ptr, align 8, !tbaa !5
  %81 = ptrtoint ptr %79 to i64
  %82 = ptrtoint ptr %80 to i64
  %83 = sub i64 %81, %82
  %84 = sdiv exact i64 %83, 8
  %85 = add i64 %84, 1
  %86 = add i64 %78, %85
  store i64 %86, ptr %16, align 8, !tbaa !16
  br label %87

87:                                               ; preds = %71, %63
  %88 = load ptr, ptr %14, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %88, i32 0, i32 0
  %90 = load i64, ptr %89, align 8, !tbaa !15
  %91 = icmp ugt i64 %90, 32
  br i1 %91, label %92, label %99

92:                                               ; preds = %87
  %93 = load ptr, ptr %14, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %93, i32 0, i32 0
  %95 = load i64, ptr %94, align 8, !tbaa !15
  %96 = sub i64 %95, 32
  %97 = load i64, ptr %16, align 8, !tbaa !16
  %98 = add i64 %96, %97
  store i64 %98, ptr %16, align 8, !tbaa !16
  br label %99

99:                                               ; preds = %92, %87
  br label %116

100:                                              ; preds = %51
  %101 = load ptr, ptr @_tx_timer_expired_timer_ptr, align 8, !tbaa !5
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  %103 = icmp eq ptr %101, %102
  br i1 %103, label %104, label %105

104:                                              ; preds = %100
  store i64 0, ptr %16, align 8, !tbaa !16
  br label %115

105:                                              ; preds = %100
  %106 = load i64, ptr %16, align 8, !tbaa !16
  %107 = icmp ugt i64 %106, 32
  br i1 %107, label %108, label %113

108:                                              ; preds = %105
  %109 = load ptr, ptr %14, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %109, i32 0, i32 0
  %111 = load i64, ptr %110, align 8, !tbaa !15
  %112 = sub i64 %111, 32
  store i64 %112, ptr %16, align 8, !tbaa !16
  br label %114

113:                                              ; preds = %105
  store i64 0, ptr %16, align 8, !tbaa !16
  br label %114

114:                                              ; preds = %113, %108
  br label %115

115:                                              ; preds = %114, %104
  br label %116

116:                                              ; preds = %115, %99
  br label %117

117:                                              ; preds = %116, %27
  %118 = load ptr, ptr %9, align 8, !tbaa !5
  %119 = icmp ne ptr %118, null
  br i1 %119, label %120, label %123

120:                                              ; preds = %117
  %121 = load i32, ptr %17, align 4, !tbaa !9
  %122 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %121, ptr %122, align 4, !tbaa !9
  br label %123

123:                                              ; preds = %120, %117
  %124 = load ptr, ptr %10, align 8, !tbaa !5
  %125 = icmp ne ptr %124, null
  br i1 %125, label %126, label %129

126:                                              ; preds = %123
  %127 = load i64, ptr %16, align 8, !tbaa !16
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  store i64 %127, ptr %128, align 8, !tbaa !16
  br label %129

129:                                              ; preds = %126, %123
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  %131 = icmp ne ptr %130, null
  br i1 %131, label %132, label %137

132:                                              ; preds = %129
  %133 = load ptr, ptr %14, align 8, !tbaa !5
  %134 = getelementptr inbounds %struct.TX_TIMER_INTERNAL_STRUCT, ptr %133, i32 0, i32 1
  %135 = load i64, ptr %134, align 8, !tbaa !18
  %136 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 %135, ptr %136, align 8, !tbaa !16
  br label %137

137:                                              ; preds = %132, %129
  %138 = load ptr, ptr %12, align 8, !tbaa !5
  %139 = icmp ne ptr %138, null
  br i1 %139, label %140, label %145

140:                                              ; preds = %137
  %141 = load ptr, ptr %7, align 8, !tbaa !5
  %142 = getelementptr inbounds %struct.TX_TIMER_STRUCT, ptr %141, i32 0, i32 3
  %143 = load ptr, ptr %142, align 8, !tbaa !19
  %144 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %143, ptr %144, align 8, !tbaa !5
  br label %145

145:                                              ; preds = %140, %137
  %146 = load i32, ptr %13, align 4, !tbaa !9
  call void @__restore_interrupt(i32 noundef %146)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  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

; 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 = { 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 8}
!12 = !{!"TX_TIMER_STRUCT", !13, i64 0, !6, i64 8, !14, i64 16, !6, i64 72, !6, i64 80}
!13 = !{!"long", !7, i64 0}
!14 = !{!"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}
!15 = !{!14, !13, i64 0}
!16 = !{!13, !13, i64 0}
!17 = !{!14, !6, i64 48}
!18 = !{!14, !13, i64 8}
!19 = !{!12, !6, i64 72}


; 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_list_start = external local_unnamed_addr global ptr, align 8
@_tx_timer_list_end = external local_unnamed_addr global ptr, align 8
@_tx_timer_current_ptr = external local_unnamed_addr global ptr, align 8
@_tx_timer_expired_timer_ptr = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @_tx_timer_info_get(ptr noundef readonly %0, ptr noundef writeonly %1, ptr noundef writeonly %2, ptr noundef writeonly %3, ptr noundef writeonly %4, ptr noundef writeonly %5) local_unnamed_addr #0 {
  %7 = tail call i32 @__disable_interrupts()
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %11, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %10, ptr %1, align 8, !tbaa !12
  br label %11

11:                                               ; preds = %8, %6
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %.not46 = icmp eq ptr %15, null
  br i1 %.not46, label %47, label %16

16:                                               ; preds = %11
  %17 = load ptr, ptr @_tx_timer_list_start, align 8, !tbaa !12
  %.not47 = icmp uge ptr %15, %17
  %18 = load ptr, ptr @_tx_timer_list_end, align 8
  %19 = icmp ult ptr %15, %18
  %or.cond = select i1 %.not47, i1 %19, i1 false
  br i1 %or.cond, label %.critedge, label %42

.critedge:                                        ; preds = %16
  %20 = load ptr, ptr @_tx_timer_current_ptr, align 8, !tbaa !12
  %.not48 = icmp ult ptr %15, %20
  %21 = ptrtoint ptr %15 to i64
  br i1 %.not48, label %27, label %22

22:                                               ; preds = %.critedge
  %23 = ptrtoint ptr %20 to i64
  %24 = sub i64 %21, %23
  %25 = ashr exact i64 %24, 3
  %26 = add nsw i64 %25, 1
  br label %37

27:                                               ; preds = %.critedge
  %28 = ptrtoint ptr %17 to i64
  %29 = sub i64 %21, %28
  %30 = ashr exact i64 %29, 3
  %31 = ptrtoint ptr %18 to i64
  %32 = ptrtoint ptr %20 to i64
  %33 = sub i64 %31, %32
  %34 = ashr exact i64 %33, 3
  %35 = add nsw i64 %30, 1
  %36 = add nsw i64 %35, %34
  br label %37

37:                                               ; preds = %27, %22
  %.033 = phi i64 [ %26, %22 ], [ %36, %27 ]
  %38 = icmp ugt i64 %13, 32
  br i1 %38, label %39, label %47

39:                                               ; preds = %37
  %40 = add i64 %13, -32
  %41 = add i64 %40, %.033
  br label %47

42:                                               ; preds = %16
  %43 = load ptr, ptr @_tx_timer_expired_timer_ptr, align 8, !tbaa !12
  %44 = icmp ne ptr %43, %12
  %45 = icmp ugt i64 %13, 32
  %or.cond54 = select i1 %44, i1 %45, i1 false
  %46 = add i64 %13, -32
  %spec.select = select i1 %or.cond54, i64 %46, i64 0
  br label %47

47:                                               ; preds = %42, %39, %37, %11
  %.1 = phi i64 [ %41, %39 ], [ %.033, %37 ], [ %13, %11 ], [ %spec.select, %42 ]
  %.032 = phi i32 [ 1, %39 ], [ 1, %37 ], [ 0, %11 ], [ 1, %42 ]
  %.not49 = icmp eq ptr %2, null
  br i1 %.not49, label %49, label %48

48:                                               ; preds = %47
  store i32 %.032, ptr %2, align 4, !tbaa !15
  br label %49

49:                                               ; preds = %48, %47
  %.not50 = icmp eq ptr %3, null
  br i1 %.not50, label %51, label %50

50:                                               ; preds = %49
  store i64 %.1, ptr %3, align 8, !tbaa !17
  br label %51

51:                                               ; preds = %50, %49
  %.not51 = icmp eq ptr %4, null
  br i1 %.not51, label %55, label %52

52:                                               ; preds = %51
  %53 = getelementptr inbounds i8, ptr %0, i64 24
  %54 = load i64, ptr %53, align 8, !tbaa !18
  store i64 %54, ptr %4, align 8, !tbaa !17
  br label %55

55:                                               ; preds = %52, %51
  %.not52 = icmp eq ptr %5, null
  br i1 %.not52, label %59, label %56

56:                                               ; preds = %55
  %57 = getelementptr inbounds i8, ptr %0, i64 72
  %58 = load ptr, ptr %57, align 8, !tbaa !19
  store ptr %58, ptr %5, align 8, !tbaa !12
  br label %59

59:                                               ; preds = %56, %55
  tail call void @__restore_interrupt(i32 noundef %7)
  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

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

!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 = !{!10, !10, i64 0}
!13 = !{!11, !7, i64 0}
!14 = !{!11, !10, i64 48}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !8, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!11, !7, i64 8}
!19 = !{!6, !10, i64 72}


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