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

; 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

declare void @PORT_YIELD() #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 @PERIODIC_WAIT(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @ENTER_CORE()
  %5 = call i32 @PORT_GETCORE()
  %6 = zext i32 %5 to i64
  %7 = getelementptr inbounds [2 x %struct._MODULE_INFORMATION_TYPE], ptr @CORE_MODULE_INFORMATION, i64 0, i64 %6
  store ptr %7, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %8, i32 0, i32 8
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %14

12:                                               ; preds = %1
  %13 = load ptr, ptr %2, align 8, !tbaa !5
  store i32 6, ptr %13, align 4, !tbaa !17
  call void @EXIT_CORE()
  store i32 1, ptr %4, align 4
  br label %215

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

21:                                               ; preds = %14
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  store i32 6, ptr %22, align 4, !tbaa !17
  call void @EXIT_CORE()
  store i32 1, ptr %4, align 4
  br label %215

23:                                               ; preds = %14
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %24, i32 0, i32 8
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %26, i32 0, i32 12
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !22
  %31 = getelementptr inbounds %struct._PROCESS_ATTRIBUTE_TYPE, ptr %30, i32 0, i32 4
  %32 = load i64, ptr %31, align 8, !tbaa !24
  %33 = icmp eq i64 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %23
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  store i32 6, ptr %35, align 4, !tbaa !17
  call void @EXIT_CORE()
  store i32 1, ptr %4, align 4
  br label %215

36:                                               ; preds = %23
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %37, i32 0, i32 8
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %39, i32 0, i32 6
  %41 = load i32, ptr %40, align 4, !tbaa !26
  %42 = icmp ugt i32 %41, 0
  br i1 %42, label %52, label %43

43:                                               ; preds = %36
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %44, i32 0, i32 8
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %46, i32 0, i32 13
  %48 = getelementptr inbounds %struct._ERRORHANDLER_INFORMATION_TYPE, ptr %47, i32 0, i32 7
  %49 = load i8, ptr %48, align 1, !tbaa !27
  %50 = zext i8 %49 to i32
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %54

52:                                               ; preds = %43, %36
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  store i32 6, ptr %53, align 4, !tbaa !17
  call void @EXIT_CORE()
  store i32 1, ptr %4, align 4
  br label %215

54:                                               ; preds = %43
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %55, i32 0, i32 8
  %57 = load ptr, ptr %56, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %57, i32 0, i32 12
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  %60 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %59, i32 0, i32 11
  call void @PRIORITYQUEUE_REMOVE(ptr noundef %60)
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %61, i32 0, i32 8
  %63 = load ptr, ptr %62, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %63, i32 0, i32 12
  %65 = load ptr, ptr %64, align 8, !tbaa !18
  %66 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %65, i32 0, i32 12
  call void @PRIORITYQUEUE_REMOVE(ptr noundef %66)
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %67, i32 0, i32 8
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %69, i32 0, i32 12
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %71, i32 0, i32 4
  store i32 4, ptr %72, align 8, !tbaa !28
  br label %73

73:                                               ; preds = %89, %54
  %74 = load ptr, ptr %3, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %74, i32 0, i32 8
  %76 = load ptr, ptr %75, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %76, i32 0, i32 12
  %78 = load ptr, ptr %77, align 8, !tbaa !18
  %79 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %78, i32 0, i32 6
  %80 = load i64, ptr %79, align 8, !tbaa !29
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %81, i32 0, i32 10
  %83 = load i64, ptr %82, align 8, !tbaa !30
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %84, i32 0, i32 11
  %86 = load i64, ptr %85, align 8, !tbaa !31
  %87 = add nsw i64 %83, %86
  %88 = icmp sle i64 %80, %87
  br i1 %88, label %89, label %113

89:                                               ; preds = %73
  %90 = load ptr, ptr %3, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %90, i32 0, i32 8
  %92 = load ptr, ptr %91, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %92, i32 0, i32 12
  %94 = load ptr, ptr %93, align 8, !tbaa !18
  %95 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %94, i32 0, i32 6
  %96 = load i64, ptr %95, align 8, !tbaa !29
  %97 = load ptr, ptr %3, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %97, i32 0, i32 8
  %99 = load ptr, ptr %98, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %99, i32 0, i32 12
  %101 = load ptr, ptr %100, align 8, !tbaa !18
  %102 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %101, i32 0, i32 0
  %103 = load ptr, ptr %102, align 8, !tbaa !22
  %104 = getelementptr inbounds %struct._PROCESS_ATTRIBUTE_TYPE, ptr %103, i32 0, i32 4
  %105 = load i64, ptr %104, align 8, !tbaa !24
  %106 = add nsw i64 %96, %105
  %107 = load ptr, ptr %3, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %107, i32 0, i32 8
  %109 = load ptr, ptr %108, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %109, i32 0, i32 12
  %111 = load ptr, ptr %110, align 8, !tbaa !18
  %112 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %111, i32 0, i32 6
  store i64 %106, ptr %112, align 8, !tbaa !29
  br label %73, !llvm.loop !32

113:                                              ; preds = %73
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %114, i32 0, i32 8
  %116 = load ptr, ptr %115, align 8, !tbaa !9
  %117 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %116, i32 0, i32 12
  %118 = load ptr, ptr %117, align 8, !tbaa !18
  %119 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %118, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !22
  %121 = getelementptr inbounds %struct._PROCESS_ATTRIBUTE_TYPE, ptr %120, i32 0, i32 5
  %122 = load i64, ptr %121, align 8, !tbaa !34
  %123 = icmp ne i64 %122, -1
  br i1 %123, label %124, label %148

124:                                              ; preds = %113
  %125 = load ptr, ptr %3, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %125, i32 0, i32 8
  %127 = load ptr, ptr %126, align 8, !tbaa !9
  %128 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %127, i32 0, i32 12
  %129 = load ptr, ptr %128, align 8, !tbaa !18
  %130 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %129, i32 0, i32 6
  %131 = load i64, ptr %130, align 8, !tbaa !29
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %132, i32 0, i32 8
  %134 = load ptr, ptr %133, align 8, !tbaa !9
  %135 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %134, i32 0, i32 12
  %136 = load ptr, ptr %135, align 8, !tbaa !18
  %137 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %136, i32 0, i32 0
  %138 = load ptr, ptr %137, align 8, !tbaa !22
  %139 = getelementptr inbounds %struct._PROCESS_ATTRIBUTE_TYPE, ptr %138, i32 0, i32 5
  %140 = load i64, ptr %139, align 8, !tbaa !34
  %141 = add nsw i64 %131, %140
  %142 = load ptr, ptr %3, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %142, i32 0, i32 8
  %144 = load ptr, ptr %143, align 8, !tbaa !9
  %145 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %144, i32 0, i32 12
  %146 = load ptr, ptr %145, align 8, !tbaa !18
  %147 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %146, i32 0, i32 7
  store i64 %141, ptr %147, align 8, !tbaa !35
  br label %155

148:                                              ; preds = %113
  %149 = load ptr, ptr %3, align 8, !tbaa !5
  %150 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %149, i32 0, i32 8
  %151 = load ptr, ptr %150, align 8, !tbaa !9
  %152 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %151, i32 0, i32 12
  %153 = load ptr, ptr %152, align 8, !tbaa !18
  %154 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %153, i32 0, i32 7
  store i64 -1, ptr %154, align 8, !tbaa !35
  br label %155

155:                                              ; preds = %148, %124
  %156 = load ptr, ptr %3, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %156, i32 0, i32 10
  %158 = load i64, ptr %157, align 8, !tbaa !30
  %159 = load ptr, ptr %3, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %159, i32 0, i32 11
  %161 = load i64, ptr %160, align 8, !tbaa !31
  %162 = add nsw i64 %158, %161
  %163 = load ptr, ptr %3, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %163, i32 0, i32 8
  %165 = load ptr, ptr %164, align 8, !tbaa !9
  %166 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %165, i32 0, i32 12
  %167 = load ptr, ptr %166, align 8, !tbaa !18
  %168 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %167, i32 0, i32 8
  store i64 %162, ptr %168, align 8, !tbaa !36
  %169 = load ptr, ptr %3, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %169, i32 0, i32 8
  %171 = load ptr, ptr %170, align 8, !tbaa !9
  %172 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %171, i32 0, i32 12
  %173 = load ptr, ptr %172, align 8, !tbaa !18
  %174 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %173, i32 0, i32 9
  store i64 -1, ptr %174, align 8, !tbaa !37
  %175 = load ptr, ptr %3, align 8, !tbaa !5
  %176 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %175, i32 0, i32 8
  %177 = load ptr, ptr %176, align 8, !tbaa !9
  %178 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %177, i32 0, i32 12
  %179 = load ptr, ptr %178, align 8, !tbaa !18
  %180 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %179, i32 0, i32 6
  %181 = load i64, ptr %180, align 8, !tbaa !29
  %182 = load ptr, ptr %3, align 8, !tbaa !5
  %183 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %182, i32 0, i32 8
  %184 = load ptr, ptr %183, align 8, !tbaa !9
  %185 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %184, i32 0, i32 12
  %186 = load ptr, ptr %185, align 8, !tbaa !18
  %187 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %186, i32 0, i32 13
  %188 = getelementptr inbounds %struct._priorityqueueENTRY, ptr %187, i32 0, i32 0
  store i64 %181, ptr %188, align 8, !tbaa !38
  %189 = load ptr, ptr %3, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %189, i32 0, i32 8
  %191 = load ptr, ptr %190, align 8, !tbaa !9
  %192 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %191, i32 0, i32 12
  %193 = load ptr, ptr %192, align 8, !tbaa !18
  %194 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %193, i32 0, i32 2
  %195 = load i32, ptr %194, align 8, !tbaa !39
  %196 = zext i32 %195 to i64
  %197 = load ptr, ptr %3, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %197, i32 0, i32 8
  %199 = load ptr, ptr %198, align 8, !tbaa !9
  %200 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %199, i32 0, i32 12
  %201 = load ptr, ptr %200, align 8, !tbaa !18
  %202 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %201, i32 0, i32 13
  %203 = getelementptr inbounds %struct._priorityqueueENTRY, ptr %202, i32 0, i32 1
  store i64 %196, ptr %203, align 8, !tbaa !40
  %204 = load ptr, ptr %3, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %204, i32 0, i32 8
  %206 = load ptr, ptr %205, align 8, !tbaa !9
  %207 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %206, i32 0, i32 19
  %208 = load ptr, ptr %3, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct._MODULE_INFORMATION_TYPE, ptr %208, i32 0, i32 8
  %210 = load ptr, ptr %209, align 8, !tbaa !9
  %211 = getelementptr inbounds %struct._PARTITION_INFORMATION_TYPE, ptr %210, i32 0, i32 12
  %212 = load ptr, ptr %211, align 8, !tbaa !18
  %213 = getelementptr inbounds %struct._PROCESS_INFORMATION_TYPE, ptr %212, i32 0, i32 13
  call void @PRIORITYQUEUE_ENQUEUE(ptr noundef %207, ptr noundef %213)
  call void @PORT_YIELD()
  %214 = load ptr, ptr %2, align 8, !tbaa !5
  store i32 1, ptr %214, align 4, !tbaa !17
  call void @EXIT_CORE()
  store i32 0, ptr %4, align 4
  br label %215

215:                                              ; preds = %155, %52, %34, %21, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %216 = load i32, ptr %4, align 4
  switch i32 %216, label %218 [
    i32 0, label %217
    i32 1, label %217
  ]

217:                                              ; preds = %215, %215
  ret void

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


; 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

declare void @PORT_YIELD() local_unnamed_addr #0

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

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

12:                                               ; preds = %8
  %13 = load ptr, ptr %10, align 8, !tbaa !20
  %14 = getelementptr inbounds i8, ptr %13, i64 24
  %15 = load i64, ptr %14, align 8, !tbaa !22
  %16 = icmp eq i64 %15, 0
  br i1 %16, label %64, label %17

17:                                               ; preds = %12
  %18 = getelementptr inbounds i8, ptr %6, i64 36
  %19 = load i32, ptr %18, align 4, !tbaa !24
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %20, label %64

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %6, i64 267
  %22 = load i8, ptr %21, align 1, !tbaa !25
  %.not37 = icmp eq i8 %22, 0
  br i1 %.not37, label %23, label %64

23:                                               ; preds = %20
  %24 = getelementptr inbounds i8, ptr %10, i64 144
  tail call void @PRIORITYQUEUE_REMOVE(ptr noundef nonnull %24) #3
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %25, i64 160
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %27, i64 184
  tail call void @PRIORITYQUEUE_REMOVE(ptr noundef nonnull %28) #3
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 160
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %31, i64 24
  store i32 4, ptr %32, align 8, !tbaa !26
  %33 = getelementptr inbounds i8, ptr %31, i64 40
  %34 = getelementptr inbounds i8, ptr %4, i64 256
  %35 = load i64, ptr %34, align 8, !tbaa !27
  %36 = getelementptr inbounds i8, ptr %4, i64 264
  %37 = load i64, ptr %36, align 8, !tbaa !28
  %38 = add i64 %37, %35
  %.promoted = load i64, ptr %33, align 8, !tbaa !29
  %.not3841 = icmp sgt i64 %.promoted, %38
  %.pre = load ptr, ptr %31, align 8, !tbaa !20
  br i1 %.not3841, label %51, label %.lr.ph

.lr.ph:                                           ; preds = %23
  %39 = getelementptr inbounds i8, ptr %.pre, i64 24
  %40 = load i64, ptr %39, align 8, !tbaa !22
  %41 = add i64 %38, 1
  %42 = add nsw i64 %.promoted, %40
  %smax = tail call i64 @llvm.smax.i64(i64 %41, i64 %42)
  %43 = icmp slt i64 %42, %41
  %umin = zext i1 %43 to i64
  %44 = add i64 %42, %umin
  %45 = sub i64 %smax, %44
  %umax = tail call i64 @llvm.umax.i64(i64 %40, i64 1)
  %46 = udiv i64 %45, %umax
  %47 = add i64 %46, %umin
  %48 = add i64 %47, 1
  %49 = mul i64 %40, %48
  %50 = add i64 %.promoted, %49
  store i64 %50, ptr %33, align 8, !tbaa !29
  br label %51

51:                                               ; preds = %.lr.ph, %23
  %.lcssa40 = phi i64 [ %50, %.lr.ph ], [ %.promoted, %23 ]
  %52 = getelementptr inbounds i8, ptr %.pre, i64 32
  %53 = load i64, ptr %52, align 8, !tbaa !30
  %.not39 = icmp eq i64 %53, -1
  %54 = add nsw i64 %53, %.lcssa40
  %spec.select = select i1 %.not39, i64 -1, i64 %54
  %55 = getelementptr inbounds i8, ptr %31, i64 48
  store i64 %spec.select, ptr %55, align 8
  %56 = getelementptr inbounds i8, ptr %31, i64 56
  store i64 %38, ptr %56, align 8, !tbaa !31
  %57 = getelementptr inbounds i8, ptr %31, i64 64
  store i64 -1, ptr %57, align 8, !tbaa !32
  %58 = getelementptr inbounds i8, ptr %31, i64 224
  store i64 %.lcssa40, ptr %58, align 8, !tbaa !33
  %59 = getelementptr inbounds i8, ptr %31, i64 16
  %60 = load i32, ptr %59, align 8, !tbaa !34
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %31, i64 232
  store i64 %61, ptr %62, align 8, !tbaa !35
  %63 = getelementptr inbounds i8, ptr %29, i64 464
  tail call void @PRIORITYQUEUE_ENQUEUE(ptr noundef nonnull %63, ptr noundef nonnull %58) #3
  tail call void @PORT_YIELD() #3
  br label %64

64:                                               ; preds = %17, %20, %12, %8, %1, %51
  %.sink = phi i32 [ 1, %51 ], [ 6, %1 ], [ 6, %8 ], [ 6, %12 ], [ 6, %20 ], [ 6, %17 ]
  store i32 %.sink, ptr %0, align 4, !tbaa !36
  tail call void @EXIT_CORE() #3
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umax.i64(i64, i64) #2

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 speculatable willreturn memory(none) }
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 = !{!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 = !{!21, !7, i64 0}
!21 = !{!"_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}
!22 = !{!23, !14, i64 24}
!23 = !{!"_PROCESS_ATTRIBUTE_TYPE", !7, i64 0, !7, i64 8, !11, i64 16, !11, i64 20, !14, i64 24, !14, i64 32, !11, i64 40}
!24 = !{!17, !11, i64 36}
!25 = !{!17, !8, i64 267}
!26 = !{!21, !11, i64 24}
!27 = !{!6, !14, i64 256}
!28 = !{!6, !14, i64 264}
!29 = !{!21, !14, i64 40}
!30 = !{!23, !14, i64 32}
!31 = !{!21, !14, i64 56}
!32 = !{!21, !14, i64 64}
!33 = !{!21, !14, i64 224}
!34 = !{!21, !11, i64 16}
!35 = !{!21, !14, i64 232}
!36 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass