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

; 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._PROCESS_INFORMATION_TYPE = type { ptr, ptr, i32, i32, i32, i64, i64, i64, i64, i64, %struct._CONTEXT_TYPE, %struct._priorityqueueENTRY, %struct._priorityqueueENTRY, %struct._priorityqueueENTRY, %struct._priorityqueueENTRY, i8, i8, ptr, i32, ptr, ptr }
%struct._PROCESS_ATTRIBUTE_TYPE = type { ptr, ptr, i32, i32, i64, i64, i32 }

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

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

declare void @ENTER_CORE() #1

declare i32 @PORT_GETCORE() #1

declare void @EXIT_CORE() #1

declare void @PRIORITYQUEUE_REMOVE(ptr noundef) #1

declare void @PRIORITYQUEUE_ENQUEUE(ptr noundef, ptr noundef) #1

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

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

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  store i32 6, ptr %15, align 4, !tbaa !18
  call void @EXIT_CORE()
  store i32 1, ptr %6, align 4
  br label %179

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %17, i32 0, i32 8
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %19, i32 0, i32 12
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %25

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

25:                                               ; preds = %16
  %26 = load i64, ptr %3, align 8, !tbaa !5
  %27 = icmp slt i64 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %25
  %29 = load i64, ptr %3, align 8, !tbaa !5
  %30 = icmp ne i64 %29, -1
  br i1 %30, label %31, label %33

31:                                               ; preds = %28
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  store i32 4, ptr %32, align 4, !tbaa !18
  call void @EXIT_CORE()
  store i32 1, ptr %6, align 4
  br label %179

33:                                               ; preds = %28, %25
  %34 = load ptr, ptr %5, align 8, !tbaa !9
  %35 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %34, i32 0, i32 8
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %36, i32 0, i32 4
  %38 = load i32, ptr %37, align 4, !tbaa !23
  %39 = icmp ne i32 %38, 4
  br i1 %39, label %49, label %40

40:                                               ; preds = %33
  %41 = load ptr, ptr %5, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %41, i32 0, i32 8
  %43 = load ptr, ptr %42, align 8, !tbaa !11
  %44 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %43, i32 0, i32 13
  %45 = getelementptr inbounds %struct._ERRORHANDLER_INFORMATION_TYPE, ptr %44, i32 0, i32 7
  %46 = load i8, ptr %45, align 1, !tbaa !24
  %47 = zext i8 %46 to i32
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %51

49:                                               ; preds = %40, %33
  %50 = load ptr, ptr %4, align 8, !tbaa !9
  store i32 2, ptr %50, align 4, !tbaa !18
  call void @EXIT_CORE()
  store i32 1, ptr %6, align 4
  br label %179

51:                                               ; preds = %40
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %52, i32 0, i32 8
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %54, i32 0, i32 12
  %56 = load ptr, ptr %55, align 8, !tbaa !19
  %57 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !25
  %59 = getelementptr inbounds %struct._PROCESS_ATTRIBUTE_TYPE, ptr %58, i32 0, i32 4
  %60 = load i64, ptr %59, align 8, !tbaa !27
  %61 = icmp ne i64 %60, 0
  br i1 %61, label %62, label %96

62:                                               ; preds = %51
  %63 = load i64, ptr %3, align 8, !tbaa !5
  %64 = icmp eq i64 %63, -1
  br i1 %64, label %93, label %65

65:                                               ; preds = %62
  %66 = load ptr, ptr %5, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %66, i32 0, i32 10
  %68 = load i64, ptr %67, align 8, !tbaa !29
  %69 = load ptr, ptr %5, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %69, i32 0, i32 11
  %71 = load i64, ptr %70, align 8, !tbaa !30
  %72 = add nsw i64 %68, %71
  %73 = load i64, ptr %3, align 8, !tbaa !5
  %74 = add nsw i64 %72, %73
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %75, i32 0, i32 8
  %77 = load ptr, ptr %76, align 8, !tbaa !11
  %78 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %77, i32 0, i32 12
  %79 = load ptr, ptr %78, align 8, !tbaa !19
  %80 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %79, i32 0, i32 6
  %81 = load i64, ptr %80, align 8, !tbaa !31
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %82, i32 0, i32 8
  %84 = load ptr, ptr %83, align 8, !tbaa !11
  %85 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %84, i32 0, i32 12
  %86 = load ptr, ptr %85, align 8, !tbaa !19
  %87 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %86, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !25
  %89 = getelementptr inbounds %struct._PROCESS_ATTRIBUTE_TYPE, ptr %88, i32 0, i32 4
  %90 = load i64, ptr %89, align 8, !tbaa !27
  %91 = add nsw i64 %81, %90
  %92 = icmp sgt i64 %74, %91
  br i1 %92, label %93, label %95

93:                                               ; preds = %65, %62
  %94 = load ptr, ptr %4, align 8, !tbaa !9
  store i32 6, ptr %94, align 4, !tbaa !18
  call void @EXIT_CORE()
  store i32 1, ptr %6, align 4
  br label %179

95:                                               ; preds = %65
  br label %96

96:                                               ; preds = %95, %51
  %97 = load ptr, ptr %5, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %97, i32 0, i32 8
  %99 = load ptr, ptr %98, align 8, !tbaa !11
  %100 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %99, i32 0, i32 12
  %101 = load ptr, ptr %100, align 8, !tbaa !19
  %102 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %101, i32 0, i32 12
  call void @PRIORITYQUEUE_REMOVE(ptr noundef %102)
  %103 = load i64, ptr %3, align 8, !tbaa !5
  %104 = icmp ne i64 %103, -1
  br i1 %104, label %105, label %121

105:                                              ; preds = %96
  %106 = load ptr, ptr %5, align 8, !tbaa !9
  %107 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %106, i32 0, i32 10
  %108 = load i64, ptr %107, align 8, !tbaa !29
  %109 = load ptr, ptr %5, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %109, i32 0, i32 11
  %111 = load i64, ptr %110, align 8, !tbaa !30
  %112 = add nsw i64 %108, %111
  %113 = load i64, ptr %3, align 8, !tbaa !5
  %114 = add nsw i64 %112, %113
  %115 = load ptr, ptr %5, align 8, !tbaa !9
  %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 12
  %119 = load ptr, ptr %118, align 8, !tbaa !19
  %120 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %119, i32 0, i32 7
  store i64 %114, ptr %120, align 8, !tbaa !32
  br label %128

121:                                              ; preds = %96
  %122 = load ptr, ptr %5, align 8, !tbaa !9
  %123 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %122, i32 0, i32 8
  %124 = load ptr, ptr %123, align 8, !tbaa !11
  %125 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %124, i32 0, i32 12
  %126 = load ptr, ptr %125, align 8, !tbaa !19
  %127 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %126, i32 0, i32 7
  store i64 -1, ptr %127, align 8, !tbaa !32
  br label %128

128:                                              ; preds = %121, %105
  %129 = load ptr, ptr %5, align 8, !tbaa !9
  %130 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %129, i32 0, i32 8
  %131 = load ptr, ptr %130, align 8, !tbaa !11
  %132 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %131, i32 0, i32 12
  %133 = load ptr, ptr %132, align 8, !tbaa !19
  %134 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %133, i32 0, i32 7
  %135 = load i64, ptr %134, align 8, !tbaa !32
  %136 = icmp ne i64 %135, -1
  br i1 %136, label %137, label %177

137:                                              ; preds = %128
  %138 = load ptr, ptr %5, align 8, !tbaa !9
  %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 12
  %142 = load ptr, ptr %141, align 8, !tbaa !19
  %143 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %142, i32 0, i32 7
  %144 = load i64, ptr %143, align 8, !tbaa !32
  %145 = load ptr, ptr %5, align 8, !tbaa !9
  %146 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %145, i32 0, i32 8
  %147 = load ptr, ptr %146, align 8, !tbaa !11
  %148 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %147, i32 0, i32 12
  %149 = load ptr, ptr %148, align 8, !tbaa !19
  %150 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %149, i32 0, i32 12
  %151 = getelementptr inbounds %struct._priorityqueueENTRY, ptr %150, i32 0, i32 0
  store i64 %144, ptr %151, align 8, !tbaa !33
  %152 = load ptr, ptr %5, align 8, !tbaa !9
  %153 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %152, i32 0, i32 8
  %154 = load ptr, ptr %153, align 8, !tbaa !11
  %155 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %154, i32 0, i32 12
  %156 = load ptr, ptr %155, align 8, !tbaa !19
  %157 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %156, i32 0, i32 2
  %158 = load i32, ptr %157, align 8, !tbaa !34
  %159 = zext i32 %158 to i64
  %160 = load ptr, ptr %5, align 8, !tbaa !9
  %161 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %160, i32 0, i32 8
  %162 = load ptr, ptr %161, align 8, !tbaa !11
  %163 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %162, i32 0, i32 12
  %164 = load ptr, ptr %163, align 8, !tbaa !19
  %165 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %164, i32 0, i32 12
  %166 = getelementptr inbounds %struct._priorityqueueENTRY, ptr %165, i32 0, i32 1
  store i64 %159, ptr %166, align 8, !tbaa !35
  %167 = load ptr, ptr %5, align 8, !tbaa !9
  %168 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %167, i32 0, i32 8
  %169 = load ptr, ptr %168, align 8, !tbaa !11
  %170 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %169, i32 0, i32 18
  %171 = load ptr, ptr %5, align 8, !tbaa !9
  %172 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %171, i32 0, i32 8
  %173 = load ptr, ptr %172, align 8, !tbaa !11
  %174 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %173, i32 0, i32 12
  %175 = load ptr, ptr %174, align 8, !tbaa !19
  %176 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %175, i32 0, i32 12
  call void @PRIORITYQUEUE_ENQUEUE(ptr noundef %170, ptr noundef %176)
  br label %177

177:                                              ; preds = %137, %128
  %178 = load ptr, ptr %4, align 8, !tbaa !9
  store i32 1, ptr %178, align 4, !tbaa !18
  call void @EXIT_CORE()
  store i32 0, ptr %6, align 4
  br label %179

179:                                              ; preds = %177, %93, %49, %31, %23, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %180 = load i32, ptr %6, align 4
  switch i32 %180, label %182 [
    i32 0, label %181
    i32 1, label %181
  ]

181:                                              ; preds = %179, %179
  ret void

182:                                              ; preds = %179
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 136}
!12 = !{!"_MODULE_INFORMATION_TYPE", !10, i64 0, !13, i64 8, !14, i64 32, !14, i64 36, !14, i64 40, !15, i64 48, !14, i64 120, !10, i64 128, !10, i64 136, !16, i64 144, !6, i64 256, !6, i64 264, !6, i64 272, !17, i64 280}
!13 = !{!"_heapRECORD", !10, i64 0, !14, i64 8, !14, i64 12, !14, i64 16}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_CONTEXT_TYPE", !14, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !14, i64 32, !7, i64 36, !10, i64 40, !10, i64 48, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68}
!16 = !{!"_HEALTHMONITORINGCALLBACK_INFORMATION_TYPE", !7, i64 0, !10, i64 8, !14, i64 16, !15, i64 24, !7, i64 96, !7, i64 97, !7, i64 98, !7, i64 99, !14, i64 100, !14, i64 104}
!17 = !{!"_priorityqueueRECORD", !10, i64 0, !14, i64 8, !7, i64 12, !7, i64 13}
!18 = !{!14, !14, i64 0}
!19 = !{!20, !10, i64 160}
!20 = !{!"_PARTITION_INFORMATION_TYPE", !7, i64 0, !10, i64 8, !10, i64 16, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !7, i64 40, !13, i64 48, !15, i64 72, !14, i64 144, !10, i64 152, !10, i64 160, !21, i64 168, !16, i64 272, !14, i64 384, !22, i64 392, !17, i64 432, !17, i64 448, !17, i64 464, !14, i64 480, !14, i64 484, !10, i64 488, !14, i64 496, !10, i64 504, !14, i64 512, !10, i64 520, !14, i64 528, !10, i64 536, !14, i64 544, !10, i64 552, !14, i64 560, !10, i64 568, !14, i64 576, !10, i64 584}
!21 = !{!"_ERRORHANDLER_INFORMATION_TYPE", !7, i64 0, !10, i64 8, !14, i64 16, !15, i64 24, !7, i64 96, !7, i64 97, !7, i64 98, !7, i64 99, !14, i64 100}
!22 = !{!"_priorityqueueENTRY", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!23 = !{!20, !14, i64 28}
!24 = !{!20, !7, i64 267}
!25 = !{!26, !10, i64 0}
!26 = !{!"_PROCESS_INFORMATION_TYPE", !10, i64 0, !10, i64 8, !14, i64 16, !14, i64 20, !14, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !15, i64 72, !22, i64 144, !22, i64 184, !22, i64 224, !22, i64 264, !7, i64 304, !7, i64 305, !10, i64 312, !14, i64 320, !10, i64 328, !10, i64 336}
!27 = !{!28, !6, i64 24}
!28 = !{!"_PROCESS_ATTRIBUTE_TYPE", !10, i64 0, !10, i64 8, !14, i64 16, !14, i64 20, !6, i64 24, !6, i64 32, !14, i64 40}
!29 = !{!12, !6, i64 256}
!30 = !{!12, !6, i64 264}
!31 = !{!26, !6, i64 40}
!32 = !{!26, !6, i64 48}
!33 = !{!26, !6, i64 184}
!34 = !{!26, !14, i64 16}
!35 = !{!26, !6, i64 192}


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

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

declare void @ENTER_CORE() local_unnamed_addr #0

declare i32 @PORT_GETCORE() local_unnamed_addr #0

declare void @EXIT_CORE() local_unnamed_addr #0

declare void @PRIORITYQUEUE_REMOVE(ptr noundef) local_unnamed_addr #0

declare void @PRIORITYQUEUE_ENQUEUE(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @REPLENISH(i64 noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #1 {
  tail call void @ENTER_CORE() #2
  %3 = tail call i32 @PORT_GETCORE() #2
  %4 = zext i32 %3 to i64
  %5 = getelementptr inbounds [2 x %struct._MODULE_INFORMATION_TYPE], ptr @CORE_MODULE_INFORMATION, i64 0, i64 %4
  %6 = getelementptr inbounds i8, ptr %5, i64 136
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %61, label %9

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %7, i64 160
  %11 = load ptr, ptr %10, align 8, !tbaa !16
  %12 = icmp eq ptr %11, null
  br i1 %12, label %61, label %13

13:                                               ; preds = %9
  %.not = icmp eq i64 %0, -1
  %or.cond = icmp slt i64 %0, -1
  br i1 %or.cond, label %61, label %14

14:                                               ; preds = %13
  %15 = getelementptr inbounds i8, ptr %7, i64 28
  %16 = load i32, ptr %15, align 4, !tbaa !20
  %.not37 = icmp eq i32 %16, 4
  br i1 %.not37, label %17, label %61

17:                                               ; preds = %14
  %18 = getelementptr inbounds i8, ptr %7, i64 267
  %19 = load i8, ptr %18, align 1, !tbaa !21
  %.not38 = icmp eq i8 %19, 0
  br i1 %.not38, label %20, label %61

20:                                               ; preds = %17
  %21 = load ptr, ptr %11, align 8, !tbaa !22
  %22 = getelementptr inbounds i8, ptr %21, i64 24
  %23 = load i64, ptr %22, align 8, !tbaa !24
  %.not39 = icmp eq i64 %23, 0
  br i1 %.not39, label %37, label %24

24:                                               ; preds = %20
  br i1 %.not, label %61, label %25

25:                                               ; preds = %24
  %26 = getelementptr inbounds i8, ptr %5, i64 256
  %27 = load i64, ptr %26, align 8, !tbaa !26
  %28 = getelementptr inbounds i8, ptr %5, i64 264
  %29 = load i64, ptr %28, align 8, !tbaa !27
  %30 = add i64 %27, %0
  %31 = add i64 %30, %29
  %32 = getelementptr inbounds i8, ptr %11, i64 40
  %33 = load i64, ptr %32, align 8, !tbaa !28
  %34 = add nsw i64 %33, %23
  %35 = icmp sgt i64 %31, %34
  br i1 %35, label %61, label %.thread

.thread:                                          ; preds = %25
  %36 = getelementptr inbounds i8, ptr %11, i64 184
  tail call void @PRIORITYQUEUE_REMOVE(ptr noundef nonnull %36) #2
  br label %43

37:                                               ; preds = %20
  %38 = getelementptr inbounds i8, ptr %11, i64 184
  tail call void @PRIORITYQUEUE_REMOVE(ptr noundef nonnull %38) #2
  br i1 %.not, label %.thread41, label %43

.thread41:                                        ; preds = %37
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 160
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = getelementptr inbounds i8, ptr %41, i64 48
  store i64 -1, ptr %42, align 8, !tbaa !29
  br label %61

43:                                               ; preds = %37, %.thread
  %44 = getelementptr inbounds i8, ptr %5, i64 256
  %45 = load i64, ptr %44, align 8, !tbaa !26
  %46 = getelementptr inbounds i8, ptr %5, i64 264
  %47 = load i64, ptr %46, align 8, !tbaa !27
  %48 = add i64 %45, %0
  %49 = add i64 %48, %47
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %50, i64 160
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = getelementptr inbounds i8, ptr %52, i64 48
  store i64 %49, ptr %53, align 8, !tbaa !29
  %.not40 = icmp eq i64 %49, -1
  br i1 %.not40, label %61, label %54

54:                                               ; preds = %43
  %55 = getelementptr inbounds i8, ptr %52, i64 184
  store i64 %49, ptr %55, align 8, !tbaa !30
  %56 = getelementptr inbounds i8, ptr %52, i64 16
  %57 = load i32, ptr %56, align 8, !tbaa !31
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %52, i64 192
  store i64 %58, ptr %59, align 8, !tbaa !32
  %60 = getelementptr inbounds i8, ptr %50, i64 448
  tail call void @PRIORITYQUEUE_ENQUEUE(ptr noundef nonnull %60, ptr noundef nonnull %55) #2
  br label %61

61:                                               ; preds = %43, %54, %.thread41, %24, %25, %14, %17, %13, %9, %2
  %.sink = phi i32 [ 6, %2 ], [ 6, %9 ], [ 4, %13 ], [ 2, %17 ], [ 2, %14 ], [ 6, %25 ], [ 6, %24 ], [ 1, %.thread41 ], [ 1, %54 ], [ 1, %43 ]
  store i32 %.sink, ptr %1, align 4, !tbaa !33
  tail call void @EXIT_CORE() #2
  ret void
}

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 = { 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 = !{!17, !7, i64 160}
!17 = !{!"_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, !18, i64 168, !13, i64 272, !11, i64 384, !19, 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}
!18 = !{!"_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}
!19 = !{!"_priorityqueueENTRY", !14, i64 0, !14, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!20 = !{!17, !11, i64 28}
!21 = !{!17, !8, i64 267}
!22 = !{!23, !7, i64 0}
!23 = !{!"_PROCESS_INFORMATION_TYPE", !7, i64 0, !7, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !14, i64 56, !14, i64 64, !12, i64 72, !19, i64 144, !19, i64 184, !19, i64 224, !19, i64 264, !8, i64 304, !8, i64 305, !7, i64 312, !11, i64 320, !7, i64 328, !7, i64 336}
!24 = !{!25, !14, i64 24}
!25 = !{!"_PROCESS_ATTRIBUTE_TYPE", !7, i64 0, !7, i64 8, !11, i64 16, !11, i64 20, !14, i64 24, !14, i64 32, !11, i64 40}
!26 = !{!6, !14, i64 256}
!27 = !{!6, !14, i64 264}
!28 = !{!23, !14, i64 40}
!29 = !{!23, !14, i64 48}
!30 = !{!23, !14, i64 184}
!31 = !{!23, !11, i64 16}
!32 = !{!23, !14, i64 192}
!33 = !{!11, !11, i64 0}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass