; LLVM IR from pmwkaa/monotone :: monotone/engine/engine (engine)

; 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.Runtime = type { %struct.ExceptionMgr, %struct.Error, ptr }
%struct.ExceptionMgr = type { ptr }
%struct.Error = type { [256 x i8], i32, ptr, ptr, i32, ptr, ptr }
%struct.Guard = type { ptr, ptr, ptr }
%struct.Exception = type { ptr, i8, ptr, [1 x %struct.__jmp_buf_tag] }
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }
%struct.Engine = type { %struct.Mutex, %struct.CondVar, %struct.Mapping, %struct.Pipeline, %struct.StorageMgr, ptr, ptr, ptr }
%struct.Mutex = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.CondVar = type { %union.pthread_cond_t }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct.Mapping = type { %struct.Rbtree, i32 }
%struct.Rbtree = type { ptr }
%struct.Pipeline = type { %struct.List, i32, ptr }
%struct.List = type { ptr, ptr }
%struct.StorageMgr = type { %struct.List, i32, ptr }
%struct.Slice = type { i64, i64, %struct.RbtreeNode }
%struct.RbtreeNode = type { ptr, ptr, ptr, i8 }
%struct.Ref = type { ptr, %struct.Lockage, %struct.Slice }
%struct.Lockage = type { [2 x %struct.Lock], ptr, ptr }
%struct.Lock = type { i64, i32, i32 }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__.engine_lock = external hidden unnamed_addr constant [61 x i8], align 1

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden ptr @ref_of(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: inlinehint nounwind uwtable
declare hidden ptr @mapping_max(ptr noundef) #2

; Function Attrs: hot nounwind uwtable
define dso_local ptr @engine_lock(ptr noundef %0, i64 noundef %1, i32 noundef %2, i1 noundef zeroext %3, i1 noundef zeroext %4) #3 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca %struct.Guard, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca %struct.Guard, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !11
  %26 = zext i1 %3 to i8
  store i8 %26, ptr %10, align 1, !tbaa !13
  %27 = zext i1 %4 to i8
  store i8 %27, ptr %11, align 1, !tbaa !13
  call void @control_lock_shared()
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #9
  %28 = getelementptr inbounds %struct.Guard, ptr %12, i32 0, i32 0
  store ptr @control_unlock_guard, ptr %28, align 8, !tbaa !15
  %29 = getelementptr inbounds %struct.Guard, ptr %12, i32 0, i32 1
  store ptr null, ptr %29, align 8, !tbaa !17
  %30 = getelementptr inbounds %struct.Guard, ptr %12, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #9
  %31 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %32 = getelementptr inbounds %struct.Runtime, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %struct.ExceptionMgr, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  store ptr %34, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #9
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Exception, ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %36, align 8, !tbaa !22
  store ptr %37, ptr %14, align 8, !tbaa !5
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.Exception, ptr %38, i32 0, i32 2
  store ptr %12, ptr %39, align 8, !tbaa !22
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %40, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #9
  %41 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %41, ptr %30, align 8, !tbaa !24
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Engine, ptr %42, i32 0, i32 0
  call void @mutex_lock(ptr noundef %43)
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #9
  %44 = getelementptr inbounds %struct.Guard, ptr %16, i32 0, i32 0
  store ptr @mutex_unlock, ptr %44, align 8, !tbaa !15
  %45 = getelementptr inbounds %struct.Guard, ptr %16, i32 0, i32 1
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Engine, ptr %46, i32 0, i32 0
  store ptr %47, ptr %45, align 8, !tbaa !17
  %48 = getelementptr inbounds %struct.Guard, ptr %16, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #9
  %49 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %50 = getelementptr inbounds %struct.Runtime, ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %struct.ExceptionMgr, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  store ptr %52, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #9
  %53 = load ptr, ptr %17, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.Exception, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !22
  store ptr %55, ptr %18, align 8, !tbaa !5
  %56 = load ptr, ptr %17, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Exception, ptr %56, i32 0, i32 2
  store ptr %16, ptr %57, align 8, !tbaa !22
  %58 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %58, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #9
  %59 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %59, ptr %48, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #9
  %60 = load i8, ptr %10, align 1, !tbaa !13, !range !25, !noundef !26
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %71

62:                                               ; preds = %5
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.Engine, ptr %63, i32 0, i32 2
  %65 = load i64, ptr %8, align 8, !tbaa !9
  %66 = call ptr @mapping_gte(ptr noundef %64, i64 noundef %65) #10
  store ptr %66, ptr %20, align 8, !tbaa !5
  %67 = load ptr, ptr %20, align 8, !tbaa !5
  %68 = icmp ne ptr %67, null
  br i1 %68, label %70, label %69

69:                                               ; preds = %62
  store ptr null, ptr %6, align 8
  store i32 1, ptr %21, align 4
  br label %153

70:                                               ; preds = %62
  br label %143

71:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #9
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.Engine, ptr %72, i32 0, i32 2
  %74 = call ptr @mapping_max(ptr noundef %73)
  store ptr %74, ptr %22, align 8, !tbaa !5
  %75 = load ptr, ptr %22, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %81

77:                                               ; preds = %71
  %78 = load ptr, ptr %22, align 8, !tbaa !5
  %79 = load i64, ptr %8, align 8, !tbaa !9
  %80 = call zeroext i1 @slice_in(ptr noundef %78, i64 noundef %79)
  br label %81

81:                                               ; preds = %77, %71
  %82 = phi i1 [ false, %71 ], [ %80, %77 ]
  %83 = xor i1 %82, true
  %84 = xor i1 %83, true
  %85 = zext i1 %84 to i32
  %86 = sext i32 %85 to i64
  %87 = call i64 @llvm.expect.i64(i64 %86, i64 1)
  %88 = icmp ne i64 %87, 0
  br i1 %88, label %89, label %91

89:                                               ; preds = %81
  %90 = load ptr, ptr %22, align 8, !tbaa !5
  store ptr %90, ptr %20, align 8, !tbaa !5
  br label %96

91:                                               ; preds = %81
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.Engine, ptr %92, i32 0, i32 2
  %94 = load i64, ptr %8, align 8, !tbaa !9
  %95 = call ptr @mapping_match(ptr noundef %93, i64 noundef %94) #10
  store ptr %95, ptr %20, align 8, !tbaa !5
  br label %96

96:                                               ; preds = %91, %89
  %97 = load ptr, ptr %20, align 8, !tbaa !5
  %98 = icmp ne ptr %97, null
  br i1 %98, label %139, label %99

99:                                               ; preds = %96
  %100 = load i8, ptr %11, align 1, !tbaa !13, !range !25, !noundef !26
  %101 = trunc i8 %100 to i1
  br i1 %101, label %103, label %102

102:                                              ; preds = %99
  store ptr null, ptr %6, align 8
  store i32 1, ptr %21, align 4
  br label %140

103:                                              ; preds = %99
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #9
  %104 = load i64, ptr %8, align 8, !tbaa !9
  %105 = call i64 @config_interval_of(i64 noundef %104)
  store i64 %105, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #9
  %106 = load i64, ptr %23, align 8, !tbaa !9
  %107 = call i64 @config_interval()
  %108 = add i64 %106, %107
  %109 = sub i64 %108, 1
  store i64 %109, ptr %24, align 8, !tbaa !9
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = load i64, ptr %23, align 8, !tbaa !9
  %112 = load i64, ptr %24, align 8, !tbaa !9
  call void @engine_fill_nolock(ptr noundef %110, i64 noundef %111, i64 noundef %112)
  %113 = load ptr, ptr %7, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.Engine, ptr %113, i32 0, i32 2
  %115 = load i64, ptr %8, align 8, !tbaa !9
  %116 = call ptr @mapping_match(ptr noundef %114, i64 noundef %115) #10
  store ptr %116, ptr %20, align 8, !tbaa !5
  %117 = load ptr, ptr %20, align 8, !tbaa !5
  %118 = icmp ne ptr %117, null
  br i1 %118, label %119, label %120

119:                                              ; preds = %103
  br label %121

120:                                              ; preds = %103
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 147, ptr noundef @__PRETTY_FUNCTION__.engine_lock) #11
  unreachable

121:                                              ; preds = %119
  %122 = load ptr, ptr %22, align 8, !tbaa !5
  %123 = icmp ne ptr %122, null
  br i1 %123, label %124, label %138

124:                                              ; preds = %121
  %125 = load ptr, ptr %22, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.Slice, ptr %125, i32 0, i32 0
  %127 = load i64, ptr %126, align 8, !tbaa !27
  %128 = load i64, ptr %23, align 8, !tbaa !9
  %129 = icmp ult i64 %127, %128
  br i1 %129, label %130, label %138

130:                                              ; preds = %124
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.Engine, ptr %131, i32 0, i32 6
  %133 = load ptr, ptr %132, align 8, !tbaa !30
  %134 = load ptr, ptr %22, align 8, !tbaa !5
  %135 = call ptr @ref_of(ptr noundef %134)
  %136 = getelementptr inbounds %struct.Ref, ptr %135, i32 0, i32 0
  %137 = load ptr, ptr %136, align 8, !tbaa !39
  call void @service_refresh(ptr noundef %133, ptr noundef %137)
  br label %138

138:                                              ; preds = %130, %124, %121
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #9
  br label %139

139:                                              ; preds = %138, %96
  store i32 0, ptr %21, align 4
  br label %140

140:                                              ; preds = %139, %102
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #9
  %141 = load i32, ptr %21, align 4
  switch i32 %141, label %153 [
    i32 0, label %142
  ]

142:                                              ; preds = %140
  br label %143

143:                                              ; preds = %142, %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #9
  %144 = load ptr, ptr %20, align 8, !tbaa !5
  %145 = call ptr @ref_of(ptr noundef %144)
  store ptr %145, ptr %25, align 8, !tbaa !5
  %146 = load ptr, ptr %25, align 8, !tbaa !5
  %147 = load i32, ptr %9, align 4, !tbaa !11
  call void @ref_lock(ptr noundef %146, i32 noundef %147)
  %148 = call ptr @unguard()
  %149 = call ptr @unguard()
  %150 = load ptr, ptr %7, align 8, !tbaa !5
  %151 = getelementptr inbounds %struct.Engine, ptr %150, i32 0, i32 0
  call void @mutex_unlock(ptr noundef %151)
  %152 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %152, ptr %6, align 8
  store i32 1, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #9
  br label %153

153:                                              ; preds = %143, %140, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #9
  call void @guard_runner(ptr noundef %16)
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #9
  call void @guard_runner(ptr noundef %12)
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #9
  %154 = load ptr, ptr %6, align 8
  ret ptr %154
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @control_lock_shared() #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @control_unlock_guard(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #4

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @guard_runner(ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mutex_lock(ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mutex_unlock(ptr noundef) #2

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden ptr @mapping_gte(ptr noundef, i64 noundef) #5

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @slice_in(ptr noundef, i64 noundef) #1

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

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden ptr @mapping_match(ptr noundef, i64 noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @config_interval_of(i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @config_interval() #2

declare void @engine_fill_nolock(ptr noundef, i64 noundef, i64 noundef) #7

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #8

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @service_refresh(ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @ref_lock(ptr noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden ptr @unguard() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline 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 = { inlinehint 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 = { hot 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { hot inlinehint 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 #6 = { nocallback nofree nosync nounwind willreturn memory(none) }
attributes #7 = { "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 #8 = { noreturn nounwind "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 #9 = { nounwind }
attributes #10 = { hot }
attributes #11 = { noreturn 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"Guard", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!16, !6, i64 8}
!18 = !{!19, !6, i64 0}
!19 = !{!"Runtime", !20, i64 0, !21, i64 8, !6, i64 312}
!20 = !{!"ExceptionMgr", !6, i64 0}
!21 = !{!"Error", !7, i64 0, !12, i64 256, !6, i64 264, !6, i64 272, !12, i64 280, !6, i64 288, !6, i64 296}
!22 = !{!23, !6, i64 16}
!23 = !{!"Exception", !6, i64 0, !14, i64 8, !6, i64 16, !7, i64 24}
!24 = !{!16, !6, i64 16}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!28, !10, i64 0}
!28 = !{!"Slice", !10, i64 0, !10, i64 8, !29, i64 16}
!29 = !{!"RbtreeNode", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}
!30 = !{!31, !6, i64 176}
!31 = !{!"Engine", !32, i64 0, !33, i64 40, !34, i64 88, !36, i64 104, !38, i64 136, !6, i64 168, !6, i64 176, !6, i64 184}
!32 = !{!"Mutex", !7, i64 0}
!33 = !{!"CondVar", !7, i64 0}
!34 = !{!"Mapping", !35, i64 0, !12, i64 8}
!35 = !{!"Rbtree", !6, i64 0}
!36 = !{!"Pipeline", !37, i64 0, !12, i64 16, !6, i64 24}
!37 = !{!"List", !6, i64 0, !6, i64 8}
!38 = !{!"StorageMgr", !37, i64 0, !12, i64 16, !6, i64 24}
!39 = !{!40, !6, i64 0}
!40 = !{!"Ref", !6, i64 0, !41, i64 8, !28, i64 56}
!41 = !{!"Lockage", !7, i64 0, !6, i64 32, !6, 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"

%struct.Runtime = type { %struct.ExceptionMgr, %struct.Error, ptr }
%struct.ExceptionMgr = type { ptr }
%struct.Error = type { [256 x i8], i32, ptr, ptr, i32, ptr, ptr }
%struct.Guard = type { ptr, ptr, ptr }

@mn_runtime = external thread_local local_unnamed_addr global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__.engine_lock = external hidden unnamed_addr constant [61 x i8], align 1

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden ptr @ref_of(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mapping_max(ptr noundef) local_unnamed_addr #2

; Function Attrs: hot nounwind uwtable
define dso_local noundef ptr @engine_lock(ptr noundef %0, i64 noundef %1, i32 noundef %2, i1 noundef zeroext %3, i1 noundef zeroext %4) local_unnamed_addr #3 {
  %6 = alloca %struct.Guard, align 8
  %7 = alloca %struct.Guard, align 8
  tail call void @control_lock_shared()
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #8
  store ptr @control_unlock_guard, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr null, ptr %8, align 8, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %6, i64 16
  %10 = tail call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  store ptr %6, ptr %12, align 8, !tbaa !16
  store ptr %13, ptr %9, align 8, !tbaa !19
  call void @mutex_lock(ptr noundef %0)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #8
  store ptr @mutex_unlock, ptr %7, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %0, ptr %14, align 8, !tbaa !10
  %15 = getelementptr inbounds i8, ptr %7, i64 16
  %16 = load ptr, ptr %10, align 8, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  store ptr %7, ptr %17, align 8, !tbaa !16
  store ptr %18, ptr %15, align 8, !tbaa !19
  %19 = getelementptr inbounds i8, ptr %0, i64 88
  br i1 %3, label %20, label %22

20:                                               ; preds = %5
  %21 = call ptr @mapping_gte(ptr noundef nonnull %19, i64 noundef %1) #9
  %.not50 = icmp eq ptr %21, null
  br i1 %.not50, label %48, label %.thread58

22:                                               ; preds = %5
  %23 = call ptr @mapping_max(ptr noundef nonnull %19)
  %.not = icmp eq ptr %23, null
  br i1 %.not, label %26, label %24, !prof !20

24:                                               ; preds = %22
  %25 = call zeroext i1 @slice_in(ptr noundef nonnull %23, i64 noundef %1)
  br i1 %25, label %.thread58, label %26, !prof !21

26:                                               ; preds = %24, %22
  %27 = call ptr @mapping_match(ptr noundef nonnull %19, i64 noundef %1) #9
  %.not48 = icmp eq ptr %27, null
  %brmerge.not = and i1 %.not48, %4
  br i1 %brmerge.not, label %28, label %44

28:                                               ; preds = %26
  %29 = call i64 @config_interval_of(i64 noundef %1)
  %30 = call i64 @config_interval()
  %31 = add i64 %29, -1
  %32 = add i64 %31, %30
  call void @engine_fill_nolock(ptr noundef %0, i64 noundef %29, i64 noundef %32) #8
  %33 = call ptr @mapping_match(ptr noundef nonnull %19, i64 noundef %1) #9
  %.not49 = icmp eq ptr %33, null
  br i1 %.not49, label %34, label %35

34:                                               ; preds = %28
  call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 147, ptr noundef nonnull @__PRETTY_FUNCTION__.engine_lock) #10
  unreachable

35:                                               ; preds = %28
  br i1 %.not, label %.thread58, label %36

36:                                               ; preds = %35
  %37 = load i64, ptr %23, align 8, !tbaa !22
  %38 = icmp ult i64 %37, %29
  br i1 %38, label %39, label %.thread58

39:                                               ; preds = %36
  %40 = getelementptr inbounds i8, ptr %0, i64 176
  %41 = load ptr, ptr %40, align 8, !tbaa !26
  %42 = call ptr @ref_of(ptr noundef nonnull %23)
  %43 = load ptr, ptr %42, align 8, !tbaa !35
  call void @service_refresh(ptr noundef %41, ptr noundef %43)
  br label %.thread58

44:                                               ; preds = %26
  br i1 %.not48, label %48, label %.thread58

.thread58:                                        ; preds = %24, %39, %36, %35, %44, %20
  %.3 = phi ptr [ %21, %20 ], [ %27, %44 ], [ %33, %35 ], [ %33, %36 ], [ %33, %39 ], [ %23, %24 ]
  %45 = call ptr @ref_of(ptr noundef nonnull %.3)
  call void @ref_lock(ptr noundef %45, i32 noundef %2)
  %46 = call ptr @unguard()
  %47 = call ptr @unguard()
  call void @mutex_unlock(ptr noundef %0)
  br label %48

48:                                               ; preds = %20, %44, %.thread58
  %.1 = phi ptr [ %45, %.thread58 ], [ null, %44 ], [ null, %20 ]
  call void @guard_runner(ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #8
  call void @guard_runner(ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #8
  ret ptr %.1
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @control_lock_shared() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @control_unlock_guard(ptr noundef) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #4

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @guard_runner(ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mutex_lock(ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @mutex_unlock(ptr noundef) #2

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden ptr @mapping_gte(ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @slice_in(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden ptr @mapping_match(ptr noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @config_interval_of(i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @config_interval() local_unnamed_addr #2

declare void @engine_fill_nolock(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @service_refresh(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @ref_lock(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden ptr @unguard() local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { alwaysinline 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 = { inlinehint 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 = { hot 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 #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { hot inlinehint 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 #6 = { "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 #7 = { noreturn nounwind "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 #8 = { nounwind }
attributes #9 = { hot }
attributes #10 = { noreturn 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 0}
!6 = !{!"Guard", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !7, i64 0}
!12 = !{!"Runtime", !13, i64 0, !14, i64 8, !7, i64 312}
!13 = !{!"ExceptionMgr", !7, i64 0}
!14 = !{!"Error", !8, i64 0, !15, i64 256, !7, i64 264, !7, i64 272, !15, i64 280, !7, i64 288, !7, i64 296}
!15 = !{!"int", !8, i64 0}
!16 = !{!17, !7, i64 16}
!17 = !{!"Exception", !7, i64 0, !18, i64 8, !7, i64 16, !8, i64 24}
!18 = !{!"_Bool", !8, i64 0}
!19 = !{!6, !7, i64 16}
!20 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!21 = !{!"branch_weights", !"expected", i32 2000, i32 1}
!22 = !{!23, !24, i64 0}
!23 = !{!"Slice", !24, i64 0, !24, i64 8, !25, i64 16}
!24 = !{!"long", !8, i64 0}
!25 = !{!"RbtreeNode", !7, i64 0, !7, i64 8, !7, i64 16, !8, i64 24}
!26 = !{!27, !7, i64 176}
!27 = !{!"Engine", !28, i64 0, !29, i64 40, !30, i64 88, !32, i64 104, !34, i64 136, !7, i64 168, !7, i64 176, !7, i64 184}
!28 = !{!"Mutex", !8, i64 0}
!29 = !{!"CondVar", !8, i64 0}
!30 = !{!"Mapping", !31, i64 0, !15, i64 8}
!31 = !{!"Rbtree", !7, i64 0}
!32 = !{!"Pipeline", !33, i64 0, !15, i64 16, !7, i64 24}
!33 = !{!"List", !7, i64 0, !7, i64 8}
!34 = !{!"StorageMgr", !33, i64 0, !15, i64 16, !7, i64 24}
!35 = !{!36, !7, i64 0}
!36 = !{!"Ref", !7, i64 0, !37, i64 8, !23, i64 56}
!37 = !{!"Lockage", !8, i64 0, !7, i64 32, !7, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LowerExpectIntrinsicPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass