; LLVM IR from eclipse-threadx/threadx :: ports_module/cortex_a35/ac6/example_build/sample_threadx_module_manager (entry)

; 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.TXM_MODULE_INSTANCE_STRUCT = type { i64, ptr, i64, i64, ptr, i64, ptr, ptr, i64, ptr, i64, ptr, ptr, ptr, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, [8 x %struct.TXM_MODULE_MPU_INFO_STRUCT], i64, i64, %struct.TX_THREAD_STRUCT, %struct.TX_THREAD_STRUCT, %struct.TX_QUEUE_STRUCT, [104 x i64], i64, i64, i64, i64, i64, i32, ptr, i64, ptr, ptr }
%struct.TXM_MODULE_MPU_INFO_STRUCT = type { i64, i64 }
%struct.TX_THREAD_STRUCT = type { i64, i64, ptr, ptr, ptr, i64, i64, i64, ptr, ptr, ptr, i32, 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, i32, i32, i32, i32, ptr, ptr, ptr, i64 }
%struct.TX_TIMER_INTERNAL_STRUCT = type { i64, i64, ptr, i64, ptr, ptr, ptr }
%struct.TX_QUEUE_STRUCT = type { i64, ptr, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr }

@MODULE_DATA = external dso_local global [4096 x i64], align 16
@object_memory = external dso_local global [16384 x i8], align 16
@my_module = external dso_local global %struct.TXM_MODULE_INSTANCE_STRUCT, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

declare i32 @_tx_thread_sleep(i64 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @module_manager_entry(i64 noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  store i64 %0, ptr %2, align 8, !tbaa !5
  %4 = call i32 @_txm_module_manager_initialize(ptr noundef @MODULE_DATA, i64 noundef 32768)
  %5 = call i32 @_txm_module_manager_object_pool_create(ptr noundef @object_memory, i64 noundef 16384)
  %6 = call i32 @_txm_module_manager_absolute_load(ptr noundef @my_module, ptr noundef @.str.2, ptr noundef inttoptr (i64 2149056512 to ptr))
  %7 = call i32 @_txm_module_manager_start(ptr noundef @my_module)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %8

8:                                                ; preds = %13, %1
  %9 = load i32, ptr %3, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 10
  br i1 %10, label %11, label %16

11:                                               ; preds = %8
  %12 = call i32 @_tx_thread_sleep(i64 noundef 10)
  br label %13

13:                                               ; preds = %11
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr %3, align 4, !tbaa !9
  br label %8, !llvm.loop !11

16:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %17 = call i32 @_txm_module_manager_stop(ptr noundef @my_module)
  %18 = call i32 @_txm_module_manager_unload(ptr noundef @my_module)
  %19 = call i32 @_txm_module_manager_absolute_load(ptr noundef @my_module, ptr noundef @.str.2, ptr noundef inttoptr (i64 2149056512 to ptr))
  %20 = call i32 @_txm_module_manager_start(ptr noundef @my_module)
  br label %21

21:                                               ; preds = %21, %16
  %22 = call i32 @_tx_thread_sleep(i64 noundef 10)
  br label %21
}

declare i32 @_txm_module_manager_initialize(ptr noundef, i64 noundef) #0

declare i32 @_txm_module_manager_object_pool_create(ptr noundef, i64 noundef) #0

declare i32 @_txm_module_manager_absolute_load(ptr noundef, ptr noundef, ptr noundef) #0

declare i32 @_txm_module_manager_start(ptr noundef) #0

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

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

declare i32 @_txm_module_manager_stop(ptr noundef) #0

declare i32 @_txm_module_manager_unload(ptr noundef) #0

attributes #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

%struct.TXM_MODULE_INSTANCE_STRUCT = type { i64, ptr, i64, i64, ptr, i64, ptr, ptr, i64, ptr, i64, ptr, ptr, ptr, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, [8 x %struct.TXM_MODULE_MPU_INFO_STRUCT], i64, i64, %struct.TX_THREAD_STRUCT, %struct.TX_THREAD_STRUCT, %struct.TX_QUEUE_STRUCT, [104 x i64], i64, i64, i64, i64, i64, i32, ptr, i64, ptr, ptr }
%struct.TXM_MODULE_MPU_INFO_STRUCT = type { i64, i64 }
%struct.TX_THREAD_STRUCT = type { i64, i64, ptr, ptr, ptr, i64, i64, i64, ptr, ptr, ptr, i32, 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, i32, i32, i32, i32, ptr, ptr, ptr, i64 }
%struct.TX_TIMER_INTERNAL_STRUCT = type { i64, i64, ptr, i64, ptr, ptr, ptr }
%struct.TX_QUEUE_STRUCT = type { i64, ptr, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr }

@MODULE_DATA = external dso_local global [4096 x i64], align 16
@object_memory = external dso_local global [16384 x i8], align 16
@my_module = external dso_local global %struct.TXM_MODULE_INSTANCE_STRUCT, align 8
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

declare i32 @_tx_thread_sleep(i64 noundef) local_unnamed_addr #0

; Function Attrs: noreturn nounwind uwtable
define dso_local void @module_manager_entry(i64 noundef %0) local_unnamed_addr #1 {
  %2 = tail call i32 @_txm_module_manager_initialize(ptr noundef nonnull @MODULE_DATA, i64 noundef 32768) #2
  %3 = tail call i32 @_txm_module_manager_object_pool_create(ptr noundef nonnull @object_memory, i64 noundef 16384) #2
  %4 = tail call i32 @_txm_module_manager_absolute_load(ptr noundef nonnull @my_module, ptr noundef nonnull @.str.2, ptr noundef nonnull inttoptr (i64 2149056512 to ptr)) #2
  %5 = tail call i32 @_txm_module_manager_start(ptr noundef nonnull @my_module) #2
  %6 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %7 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %8 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %9 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %10 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %11 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %12 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %13 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %14 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %15 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  %16 = tail call i32 @_txm_module_manager_stop(ptr noundef nonnull @my_module) #2
  %17 = tail call i32 @_txm_module_manager_unload(ptr noundef nonnull @my_module) #2
  %18 = tail call i32 @_txm_module_manager_absolute_load(ptr noundef nonnull @my_module, ptr noundef nonnull @.str.2, ptr noundef nonnull inttoptr (i64 2149056512 to ptr)) #2
  %19 = tail call i32 @_txm_module_manager_start(ptr noundef nonnull @my_module) #2
  br label %20

20:                                               ; preds = %20, %1
  %21 = tail call i32 @_tx_thread_sleep(i64 noundef 10) #2
  br label %20
}

declare i32 @_txm_module_manager_initialize(ptr noundef, i64 noundef) local_unnamed_addr #0

declare i32 @_txm_module_manager_object_pool_create(ptr noundef, i64 noundef) local_unnamed_addr #0

declare i32 @_txm_module_manager_absolute_load(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @_txm_module_manager_start(ptr noundef) local_unnamed_addr #0

declare i32 @_txm_module_manager_stop(ptr noundef) local_unnamed_addr #0

declare i32 @_txm_module_manager_unload(ptr noundef) local_unnamed_addr #0

attributes #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 = { noreturn 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 }

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


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass