; LLVM IR from eclipse-threadx/threadx :: ports_arch/ARMv7-M/threadx_modules/gnu/module_lib/src/txm_module_thread_shell_e_68e89618 (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_THREAD_ENTRY_INFO_STRUCT = type { ptr, ptr, ptr, ptr, ptr, i64, ptr, i32, ptr, ptr, ptr, ptr }

@_txm_module_entry_info = external dso_local global ptr, align 8
@_txm_module_kernel_call_dispatcher = external dso_local global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @_txm_module_thread_shell_entry(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %6, i32 0, i32 7
  %8 = load i32, ptr %7, align 8, !tbaa !9
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %28

10:                                               ; preds = %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  call void @_gcc_setup(ptr noundef %13)
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %14, ptr @_txm_module_entry_info, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %15, i32 0, i32 11
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr %17, ptr @_txm_module_kernel_call_dispatcher, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %22, %10
  %19 = load ptr, ptr @_txm_module_kernel_call_dispatcher, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  %21 = xor i1 %20, true
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  br label %18, !llvm.loop !15

23:                                               ; preds = %18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %24, i32 0, i32 8
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = call i32 @_txe_thread_resume(ptr noundef %26)
  br label %28

28:                                               ; preds = %23, %2
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %29, i32 0, i32 6
  %31 = load ptr, ptr %30, align 8, !tbaa !18
  store ptr %31, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %37

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  call void %35(ptr noundef %36, i32 noundef 0)
  br label %37

37:                                               ; preds = %34, %28
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %38, i32 0, i32 4
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %41, i32 0, i32 5
  %43 = load i64, ptr %42, align 8, !tbaa !20
  call void %40(i64 noundef %43)
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.TXM_MODULE_THREAD_ENTRY_INFO_STRUCT, ptr %44, i32 0, i32 6
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  store ptr %46, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %49, label %52

49:                                               ; preds = %37
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  call void %50(ptr noundef %51, i32 noundef 1)
  br label %52

52:                                               ; preds = %49, %37
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = call i32 @_txm_module_thread_system_suspend(ptr noundef %53)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

declare void @_gcc_setup(ptr noundef) #2

declare i32 @_txe_thread_resume(ptr noundef) #2

declare i32 @_txm_module_thread_system_suspend(ptr 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 = { "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, !12, i64 56}
!10 = !{!"TXM_MODULE_THREAD_ENTRY_INFO_STRUCT", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !6, i64 48, !12, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 24}
!14 = !{!10, !6, i64 88}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!10, !6, i64 64}
!18 = !{!10, !6, i64 48}
!19 = !{!10, !6, i64 32}
!20 = !{!10, !11, i64 40}


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

@_txm_module_entry_info = external dso_local local_unnamed_addr global ptr, align 8
@_txm_module_kernel_call_dispatcher = external dso_local local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local void @_txm_module_thread_shell_entry(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 56
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %14, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  tail call void @_gcc_setup(ptr noundef %7) #2
  store ptr %1, ptr @_txm_module_entry_info, align 8, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %1, i64 88
  %9 = load ptr, ptr %8, align 8, !tbaa !14
  store ptr %9, ptr @_txm_module_kernel_call_dispatcher, align 8, !tbaa !13
  %.not17 = icmp eq ptr %9, null
  br i1 %.not17, label %.split, label %10, !llvm.loop !15

.split:                                           ; preds = %5, %.split
  br label %.split

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %1, i64 64
  %12 = load ptr, ptr %11, align 8, !tbaa !17
  %13 = tail call i32 @_txe_thread_resume(ptr noundef %12) #2
  br label %14

14:                                               ; preds = %10, %2
  %15 = getelementptr inbounds i8, ptr %1, i64 48
  %16 = load ptr, ptr %15, align 8, !tbaa !18
  %.not18 = icmp eq ptr %16, null
  br i1 %.not18, label %18, label %17

17:                                               ; preds = %14
  tail call void %16(ptr noundef %0, i32 noundef 0) #2
  br label %18

18:                                               ; preds = %17, %14
  %19 = getelementptr inbounds i8, ptr %1, i64 32
  %20 = load ptr, ptr %19, align 8, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %1, i64 40
  %22 = load i64, ptr %21, align 8, !tbaa !20
  tail call void %20(i64 noundef %22) #2
  %23 = load ptr, ptr %15, align 8, !tbaa !18
  %.not19 = icmp eq ptr %23, null
  br i1 %.not19, label %25, label %24

24:                                               ; preds = %18
  tail call void %23(ptr noundef %0, i32 noundef 1) #2
  br label %25

25:                                               ; preds = %24, %18
  %26 = tail call i32 @_txm_module_thread_system_suspend(ptr noundef %0) #2
  ret void
}

declare void @_gcc_setup(ptr noundef) local_unnamed_addr #1

declare i32 @_txe_thread_resume(ptr noundef) local_unnamed_addr #1

declare i32 @_txm_module_thread_system_suspend(ptr 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 = { "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)"}
!5 = !{!6, !11, i64 56}
!6 = !{!"TXM_MODULE_THREAD_ENTRY_INFO_STRUCT", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !7, i64 48, !11, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 24}
!13 = !{!7, !7, i64 0}
!14 = !{!6, !7, i64 88}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !7, i64 64}
!18 = !{!6, !7, i64 48}
!19 = !{!6, !7, i64 32}
!20 = !{!6, !10, i64 40}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass