; LLVM IR from lfarcaro/ARINC653_ARMV7A_Z7000 :: ARINC653_ARMV7A_Z7000.sw/ARINC653_ARMV7A_Z7000/src/ARINC653 (SEMAPHORE)

; 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._MODULE_INFORMATION_TYPE = type { ptr, %struct._heapRECORD, i32, i32, i32, %struct._CONTEXT_TYPE, i32, ptr, ptr, %struct._HEALTHMONITORINGCALLBACK_INFORMATION_TYPE, i64, i64, i64, %struct._priorityqueueRECORD }
%struct._heapRECORD = type { ptr, i32, i32, i32 }
%struct._CONTEXT_TYPE = type { i32, ptr, ptr, ptr, i32, i8, ptr, ptr, i32, i32, i32, i32 }
%struct._HEALTHMONITORINGCALLBACK_INFORMATION_TYPE = type { i8, ptr, i32, %struct._CONTEXT_TYPE, i8, i8, i8, i8, i32, i32 }
%struct._priorityqueueRECORD = type { ptr, i32, i8, i8 }
%struct._PARTITION_INFORMATION_TYPE = type { i8, ptr, ptr, i32, i32, i32, i32, i8, %struct._heapRECORD, %struct._CONTEXT_TYPE, i32, ptr, ptr, %struct._ERRORHANDLER_INFORMATION_TYPE, %struct._HEALTHMONITORINGCALLBACK_INFORMATION_TYPE, i32, %struct._priorityqueueENTRY, %struct._priorityqueueRECORD, %struct._priorityqueueRECORD, %struct._priorityqueueRECORD, i32, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr }
%struct._ERRORHANDLER_INFORMATION_TYPE = type { i8, ptr, i32, %struct._CONTEXT_TYPE, i8, i8, i8, i8, i32 }
%struct._priorityqueueENTRY = type { i64, i64, ptr, ptr, ptr }
%struct._PARTITION_CONFIGURATION_TYPE = type { i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, i32, ptr, ptr, i32, ptr, ptr }
%struct._SEMAPHORE_INFORMATION_TYPE = type { i32, ptr, i32, i32, i32, %struct._priorityqueueRECORD }

@CORE_MODULE_INFORMATION = external global [2 x %struct._MODULE_INFORMATION_TYPE], align 16

; Function Attrs: nounwind uwtable
define dso_local void @CREATE_SEMAPHORE(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  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 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @ENTER_CORE()
  %17 = call i32 @PORT_GETCORE()
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds [2 x %struct._MODULE_INFORMATION_TYPE], ptr @CORE_MODULE_INFORMATION, i64 0, i64 %18
  store ptr %19, ptr %13, align 8, !tbaa !5
  %20 = load ptr, ptr %13, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %20, i32 0, i32 8
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %26

24:                                               ; preds = %6
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 6, ptr %25, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

26:                                               ; preds = %6
  %27 = load ptr, ptr %13, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %27, i32 0, i32 8
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %30, align 4, !tbaa !18
  %32 = icmp eq i32 %31, 4
  br i1 %32, label %33, label %35

33:                                               ; preds = %26
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 6, ptr %34, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

35:                                               ; preds = %26
  %36 = load ptr, ptr %13, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %36, i32 0, i32 8
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %38, i32 0, i32 31
  %40 = load i32, ptr %39, align 8, !tbaa !22
  store i32 %40, ptr %14, align 4, !tbaa !9
  %41 = load i32, ptr %14, align 4, !tbaa !9
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %42, i32 0, i32 8
  %44 = load ptr, ptr %43, align 8, !tbaa !11
  %45 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !23
  %47 = getelementptr inbounds %struct._PARTITION_CONFIGURATION_TYPE, ptr %46, i32 0, i32 8
  %48 = load i32, ptr %47, align 8, !tbaa !24
  %49 = icmp uge i32 %41, %48
  br i1 %49, label %50, label %52

50:                                               ; preds = %35
  %51 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 5, ptr %51, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

52:                                               ; preds = %35
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  call void @GET_SEMAPHORE_ID(ptr noundef %53, ptr noundef %14, ptr noundef %54)
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = icmp eq i32 %56, 1
  br i1 %57, label %58, label %60

58:                                               ; preds = %52
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 2, ptr %59, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

60:                                               ; preds = %52
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = icmp ugt i32 %61, 65535
  br i1 %62, label %63, label %65

63:                                               ; preds = %60
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 4, ptr %64, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

65:                                               ; preds = %60
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = icmp ugt i32 %66, 65535
  br i1 %67, label %68, label %70

68:                                               ; preds = %65
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 4, ptr %69, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

70:                                               ; preds = %65
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = icmp ugt i32 %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %70
  %75 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 4, ptr %75, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

76:                                               ; preds = %70
  %77 = load i32, ptr %10, align 4, !tbaa !9
  %78 = icmp ne i32 %77, 1
  br i1 %78, label %79, label %84

79:                                               ; preds = %76
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = icmp ne i32 %80, 2
  br i1 %81, label %82, label %84

82:                                               ; preds = %79
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 4, ptr %83, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

84:                                               ; preds = %79, %76
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %85, i32 0, i32 8
  %87 = load ptr, ptr %86, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %87, i32 0, i32 32
  %89 = load ptr, ptr %88, align 8, !tbaa !26
  %90 = load i32, ptr %14, align 4, !tbaa !9
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %89, i64 %91
  store ptr %92, ptr %15, align 8, !tbaa !5
  %93 = load ptr, ptr %13, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %93, i32 0, i32 8
  %95 = load ptr, ptr %94, align 8, !tbaa !11
  %96 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %95, i32 0, i32 8
  %97 = load ptr, ptr %15, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %97, i32 0, i32 1
  call void @HEAP_ALLOCATE(ptr noundef %96, ptr noundef %98, i32 noundef 30, i8 noundef zeroext 0)
  %99 = load ptr, ptr %15, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %99, i32 0, i32 1
  %101 = load ptr, ptr %100, align 8, !tbaa !27
  %102 = icmp eq ptr %101, null
  br i1 %102, label %103, label %105

103:                                              ; preds = %84
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 5, ptr %104, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

105:                                              ; preds = %84
  %106 = load ptr, ptr %7, align 8, !tbaa !5
  %107 = load ptr, ptr %15, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %107, i32 0, i32 1
  %109 = load ptr, ptr %108, align 8, !tbaa !27
  %110 = call zeroext i8 @COMMON_COPYSTRING(ptr noundef %106, ptr noundef %109, i32 noundef 30)
  %111 = icmp ne i8 %110, 0
  br i1 %111, label %114, label %112

112:                                              ; preds = %105
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 5, ptr %113, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 1, ptr %16, align 4
  br label %147

114:                                              ; preds = %105
  %115 = load ptr, ptr %13, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %115, i32 0, i32 8
  %117 = load ptr, ptr %116, align 8, !tbaa !11
  %118 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %117, i32 0, i32 31
  %119 = load i32, ptr %118, align 8, !tbaa !22
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %120, i32 0, i32 0
  store i32 %119, ptr %121, align 8, !tbaa !29
  %122 = load i32, ptr %8, align 4, !tbaa !9
  %123 = load ptr, ptr %15, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %123, i32 0, i32 2
  store i32 %122, ptr %124, align 8, !tbaa !30
  %125 = load i32, ptr %9, align 4, !tbaa !9
  %126 = load ptr, ptr %15, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %126, i32 0, i32 3
  store i32 %125, ptr %127, align 4, !tbaa !31
  %128 = load i32, ptr %10, align 4, !tbaa !9
  %129 = load ptr, ptr %15, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %129, i32 0, i32 4
  store i32 %128, ptr %130, align 8, !tbaa !32
  %131 = load ptr, ptr %15, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %131, i32 0, i32 5
  %133 = load i32, ptr %10, align 4, !tbaa !9
  %134 = icmp eq i32 %133, 2
  %135 = zext i1 %134 to i64
  %136 = select i1 %134, i32 1, i32 0
  %137 = trunc i32 %136 to i8
  call void @PRIORITYQUEUE_CLEAR(ptr noundef %132, i8 noundef zeroext %137, i8 noundef zeroext 0)
  %138 = load ptr, ptr %13, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %138, i32 0, i32 8
  %140 = load ptr, ptr %139, align 8, !tbaa !11
  %141 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %140, i32 0, i32 31
  %142 = load i32, ptr %141, align 8, !tbaa !22
  %143 = add i32 %142, 1
  store i32 %143, ptr %141, align 8, !tbaa !22
  %144 = load i32, ptr %14, align 4, !tbaa !9
  %145 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %144, ptr %145, align 4, !tbaa !9
  %146 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 1, ptr %146, align 4, !tbaa !9
  call void @EXIT_CORE()
  store i32 0, ptr %16, align 4
  br label %147

147:                                              ; preds = %114, %112, %103, %82, %74, %68, %63, %58, %50, %33, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %148 = load i32, ptr %16, align 4
  switch i32 %148, label %150 [
    i32 0, label %149
    i32 1, label %149
  ]

149:                                              ; preds = %147, %147
  ret void

150:                                              ; preds = %147
  unreachable
}

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

declare void @ENTER_CORE() #2

declare i32 @PORT_GETCORE() #2

declare void @EXIT_CORE() #2

; Function Attrs: nounwind uwtable
declare dso_local void @GET_SEMAPHORE_ID(ptr noundef, ptr noundef, ptr noundef) #0

declare void @HEAP_ALLOCATE(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) #2

declare zeroext i8 @COMMON_COPYSTRING(ptr noundef, ptr noundef, i32 noundef) #2

declare void @PRIORITYQUEUE_CLEAR(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 136}
!12 = !{!"_MODULE_INFORMATION_TYPE", !6, i64 0, !13, i64 8, !10, i64 32, !10, i64 36, !10, i64 40, !14, i64 48, !10, i64 120, !6, i64 128, !6, i64 136, !15, i64 144, !16, i64 256, !16, i64 264, !16, i64 272, !17, i64 280}
!13 = !{!"_heapRECORD", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16}
!14 = !{!"_CONTEXT_TYPE", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !7, i64 36, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68}
!15 = !{!"_HEALTHMONITORINGCALLBACK_INFORMATION_TYPE", !7, i64 0, !6, i64 8, !10, i64 16, !14, i64 24, !7, i64 96, !7, i64 97, !7, i64 98, !7, i64 99, !10, i64 100, !10, i64 104}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"_priorityqueueRECORD", !6, i64 0, !10, i64 8, !7, i64 12, !7, i64 13}
!18 = !{!19, !10, i64 28}
!19 = !{!"_PARTITION_INFORMATION_TYPE", !7, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !13, i64 48, !14, i64 72, !10, i64 144, !6, i64 152, !6, i64 160, !20, i64 168, !15, i64 272, !10, i64 384, !21, i64 392, !17, i64 432, !17, i64 448, !17, i64 464, !10, i64 480, !10, i64 484, !6, i64 488, !10, i64 496, !6, i64 504, !10, i64 512, !6, i64 520, !10, i64 528, !6, i64 536, !10, i64 544, !6, i64 552, !10, i64 560, !6, i64 568, !10, i64 576, !6, i64 584}
!20 = !{!"_ERRORHANDLER_INFORMATION_TYPE", !7, i64 0, !6, i64 8, !10, i64 16, !14, i64 24, !7, i64 96, !7, i64 97, !7, i64 98, !7, i64 99, !10, i64 100}
!21 = !{!"_priorityqueueENTRY", !16, i64 0, !16, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!22 = !{!19, !10, i64 560}
!23 = !{!19, !6, i64 16}
!24 = !{!25, !10, i64 40}
!25 = !{!"_PARTITION_CONFIGURATION_TYPE", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !6, i64 48, !10, i64 56, !6, i64 64, !10, i64 72, !6, i64 80, !10, i64 88, !6, i64 96, !10, i64 104, !6, i64 112, !10, i64 120, !6, i64 128, !10, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 168, !10, i64 176, !6, i64 184, !6, i64 192}
!26 = !{!19, !6, i64 568}
!27 = !{!28, !6, i64 8}
!28 = !{!"_SEMAPHORE_INFORMATION_TYPE", !10, i64 0, !6, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !17, i64 32}
!29 = !{!28, !10, i64 0}
!30 = !{!28, !10, i64 16}
!31 = !{!28, !10, i64 20}
!32 = !{!28, !10, i64 24}


; 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._MODULE_INFORMATION_TYPE = type { ptr, %struct._heapRECORD, i32, i32, i32, %struct._CONTEXT_TYPE, i32, ptr, ptr, %struct._HEALTHMONITORINGCALLBACK_INFORMATION_TYPE, i64, i64, i64, %struct._priorityqueueRECORD }
%struct._heapRECORD = type { ptr, i32, i32, i32 }
%struct._CONTEXT_TYPE = type { i32, ptr, ptr, ptr, i32, i8, ptr, ptr, i32, i32, i32, i32 }
%struct._HEALTHMONITORINGCALLBACK_INFORMATION_TYPE = type { i8, ptr, i32, %struct._CONTEXT_TYPE, i8, i8, i8, i8, i32, i32 }
%struct._priorityqueueRECORD = type { ptr, i32, i8, i8 }
%struct._SEMAPHORE_INFORMATION_TYPE = type { i32, ptr, i32, i32, i32, %struct._priorityqueueRECORD }

@CORE_MODULE_INFORMATION = external local_unnamed_addr global [2 x %struct._MODULE_INFORMATION_TYPE], align 16

; Function Attrs: nounwind uwtable
define dso_local void @CREATE_SEMAPHORE(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4, ptr noundef %5) local_unnamed_addr #0 {
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  tail call void @ENTER_CORE() #3
  %8 = tail call i32 @PORT_GETCORE() #3
  %9 = zext i32 %8 to i64
  %10 = getelementptr inbounds [2 x %struct._MODULE_INFORMATION_TYPE], ptr @CORE_MODULE_INFORMATION, i64 0, i64 %9, i32 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %6
  store i32 6, ptr %5, align 4, !tbaa !16
  tail call void @EXIT_CORE() #3
  br label %73

14:                                               ; preds = %6
  %15 = getelementptr inbounds i8, ptr %11, i64 28
  %16 = load i32, ptr %15, align 4, !tbaa !17
  %17 = icmp eq i32 %16, 4
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i32 6, ptr %5, align 4, !tbaa !16
  tail call void @EXIT_CORE() #3
  br label %73

19:                                               ; preds = %14
  %20 = getelementptr inbounds i8, ptr %11, i64 560
  %21 = load i32, ptr %20, align 8, !tbaa !21
  store i32 %21, ptr %7, align 4, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %11, i64 16
  %23 = load ptr, ptr %22, align 8, !tbaa !22
  %24 = getelementptr inbounds i8, ptr %23, i64 40
  %25 = load i32, ptr %24, align 8, !tbaa !23
  %.not = icmp ult i32 %21, %25
  br i1 %.not, label %27, label %26

26:                                               ; preds = %19
  store i32 5, ptr %5, align 4, !tbaa !16
  tail call void @EXIT_CORE() #3
  br label %73

27:                                               ; preds = %19
  call void @GET_SEMAPHORE_ID(ptr noundef %0, ptr noundef nonnull %7, ptr noundef %5)
  %28 = load i32, ptr %5, align 4, !tbaa !16
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  store i32 2, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

31:                                               ; preds = %27
  %32 = icmp ugt i32 %1, 65535
  br i1 %32, label %33, label %34

33:                                               ; preds = %31
  store i32 4, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

34:                                               ; preds = %31
  %35 = icmp ugt i32 %2, 65535
  br i1 %35, label %36, label %37

36:                                               ; preds = %34
  store i32 4, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

37:                                               ; preds = %34
  %38 = icmp ugt i32 %1, %2
  br i1 %38, label %39, label %40

39:                                               ; preds = %37
  store i32 4, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

40:                                               ; preds = %37
  %41 = add i32 %3, -3
  %or.cond = icmp ult i32 %41, -2
  br i1 %or.cond, label %42, label %43

42:                                               ; preds = %40
  store i32 4, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

43:                                               ; preds = %40
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 568
  %46 = load ptr, ptr %45, align 8, !tbaa !25
  %47 = load i32, ptr %7, align 4, !tbaa !16
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds %struct._SEMAPHORE_INFORMATION_TYPE, ptr %46, i64 %48
  %50 = getelementptr inbounds i8, ptr %44, i64 48
  %51 = getelementptr inbounds i8, ptr %49, i64 8
  call void @HEAP_ALLOCATE(ptr noundef nonnull %50, ptr noundef nonnull %51, i32 noundef 30, i8 noundef zeroext 0) #3
  %52 = load ptr, ptr %51, align 8, !tbaa !26
  %53 = icmp eq ptr %52, null
  br i1 %53, label %54, label %55

54:                                               ; preds = %43
  store i32 5, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

55:                                               ; preds = %43
  %56 = call zeroext i8 @COMMON_COPYSTRING(ptr noundef %0, ptr noundef nonnull %52, i32 noundef 30) #3
  %.not45 = icmp eq i8 %56, 0
  br i1 %.not45, label %57, label %58

57:                                               ; preds = %55
  store i32 5, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

58:                                               ; preds = %55
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %59, i64 560
  %61 = load i32, ptr %60, align 8, !tbaa !21
  store i32 %61, ptr %49, align 8, !tbaa !28
  %62 = getelementptr inbounds i8, ptr %49, i64 16
  store i32 %1, ptr %62, align 8, !tbaa !29
  %63 = getelementptr inbounds i8, ptr %49, i64 20
  store i32 %2, ptr %63, align 4, !tbaa !30
  %64 = getelementptr inbounds i8, ptr %49, i64 24
  store i32 %3, ptr %64, align 8, !tbaa !31
  %65 = getelementptr inbounds i8, ptr %49, i64 32
  %66 = icmp eq i32 %3, 2
  %67 = zext i1 %66 to i8
  call void @PRIORITYQUEUE_CLEAR(ptr noundef nonnull %65, i8 noundef zeroext %67, i8 noundef zeroext 0) #3
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i64 560
  %70 = load i32, ptr %69, align 8, !tbaa !21
  %71 = add i32 %70, 1
  store i32 %71, ptr %69, align 8, !tbaa !21
  %72 = load i32, ptr %7, align 4, !tbaa !16
  store i32 %72, ptr %4, align 4, !tbaa !16
  store i32 1, ptr %5, align 4, !tbaa !16
  call void @EXIT_CORE() #3
  br label %73

73:                                               ; preds = %58, %57, %54, %42, %39, %36, %33, %30, %26, %18, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  ret void
}

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

declare void @ENTER_CORE() local_unnamed_addr #2

declare i32 @PORT_GETCORE() local_unnamed_addr #2

declare void @EXIT_CORE() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @GET_SEMAPHORE_ID(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare void @HEAP_ALLOCATE(ptr noundef, ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #2

declare zeroext i8 @COMMON_COPYSTRING(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @PRIORITYQUEUE_CLEAR(ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress 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, !7, i64 136}
!6 = !{!"_MODULE_INFORMATION_TYPE", !7, i64 0, !10, i64 8, !11, i64 32, !11, i64 36, !11, i64 40, !12, i64 48, !11, i64 120, !7, i64 128, !7, i64 136, !13, i64 144, !14, i64 256, !14, i64 264, !14, i64 272, !15, i64 280}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_heapRECORD", !7, i64 0, !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_CONTEXT_TYPE", !11, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !8, i64 36, !7, i64 40, !7, i64 48, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68}
!13 = !{!"_HEALTHMONITORINGCALLBACK_INFORMATION_TYPE", !8, i64 0, !7, i64 8, !11, i64 16, !12, i64 24, !8, i64 96, !8, i64 97, !8, i64 98, !8, i64 99, !11, i64 100, !11, i64 104}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"_priorityqueueRECORD", !7, i64 0, !11, i64 8, !8, i64 12, !8, i64 13}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !11, i64 28}
!18 = !{!"_PARTITION_INFORMATION_TYPE", !8, i64 0, !7, i64 8, !7, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !8, i64 40, !10, i64 48, !12, i64 72, !11, i64 144, !7, i64 152, !7, i64 160, !19, i64 168, !13, i64 272, !11, i64 384, !20, i64 392, !15, i64 432, !15, i64 448, !15, i64 464, !11, i64 480, !11, i64 484, !7, i64 488, !11, i64 496, !7, i64 504, !11, i64 512, !7, i64 520, !11, i64 528, !7, i64 536, !11, i64 544, !7, i64 552, !11, i64 560, !7, i64 568, !11, i64 576, !7, i64 584}
!19 = !{!"_ERRORHANDLER_INFORMATION_TYPE", !8, i64 0, !7, i64 8, !11, i64 16, !12, i64 24, !8, i64 96, !8, i64 97, !8, i64 98, !8, i64 99, !11, i64 100}
!20 = !{!"_priorityqueueENTRY", !14, i64 0, !14, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!21 = !{!18, !11, i64 560}
!22 = !{!18, !7, i64 16}
!23 = !{!24, !11, i64 40}
!24 = !{!"_PARTITION_CONFIGURATION_TYPE", !11, i64 0, !7, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !7, i64 48, !11, i64 56, !7, i64 64, !11, i64 72, !7, i64 80, !11, i64 88, !7, i64 96, !11, i64 104, !7, i64 112, !11, i64 120, !7, i64 128, !11, i64 136, !7, i64 144, !11, i64 152, !7, i64 160, !7, i64 168, !11, i64 176, !7, i64 184, !7, i64 192}
!25 = !{!18, !7, i64 568}
!26 = !{!27, !7, i64 8}
!27 = !{!"_SEMAPHORE_INFORMATION_TYPE", !11, i64 0, !7, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !15, i64 32}
!28 = !{!27, !11, i64 0}
!29 = !{!27, !11, i64 16}
!30 = !{!27, !11, i64 20}
!31 = !{!27, !11, i64 24}


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