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

; 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.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.ServiceReq = type { i64, %struct.List, i32, i32, [0 x %struct.Action] }
%struct.Action = type { i32 }
%struct.Context = type { ptr, ptr, ptr }
%struct.Global = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.Config = type { %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.Var, %struct.List, %struct.List, i32, i32, i32, i32 }
%struct.Var = type { i32, i32, %struct.Str, %struct.List, %struct.List, %union.anon }
%struct.Str = type { ptr, ptr, i8 }
%union.anon = type { %struct.Str }

@mn_runtime = external thread_local global %struct.Runtime, align 8

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @engine_drop(ptr noundef, i64 noundef, i1 noundef zeroext, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @engine_drop_file(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @engine_download(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) #2

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @exception_mgr_leave(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @engine_upload(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) #2

declare void @refresh_reset(ptr noundef) #5

declare void @refresh_run(ptr noundef, i64 noundef, ptr noundef, i1 noundef zeroext) #5

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

; Function Attrs: hot nounwind uwtable
declare dso_local void @engine_gc(ptr noundef) #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @var_int_of(ptr noundef) #7

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @engine_service(ptr noundef %0, ptr noundef %1, i32 noundef %2, i1 noundef zeroext %3) #2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca %struct.Exception, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  %17 = zext i1 %3 to i8
  store i8 %17, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #8
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Engine, ptr %18, i32 0, i32 6
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = load i8, ptr %9, align 1, !tbaa !11, !range !22, !noundef !23
  %23 = trunc i8 %22 to i1
  %24 = call zeroext i1 @service_next(ptr noundef %20, i32 noundef %21, i1 noundef zeroext %23, ptr noundef %10)
  %25 = zext i1 %24 to i8
  store i8 %25, ptr %11, align 1, !tbaa !11
  %26 = load i8, ptr %11, align 1, !tbaa !11, !range !22, !noundef !23
  %27 = trunc i8 %26 to i1
  br i1 %27, label %28, label %29

28:                                               ; preds = %4
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %144

29:                                               ; preds = %4
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %144

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 224, ptr %13) #8
  %34 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %35 = getelementptr inbounds %struct.Runtime, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.ExceptionMgr, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !24
  %38 = getelementptr inbounds %struct.Exception, ptr %13, i32 0, i32 0
  store ptr %37, ptr %38, align 8, !tbaa !28
  %39 = getelementptr inbounds %struct.Exception, ptr %13, i32 0, i32 1
  store i8 0, ptr %39, align 8, !tbaa !30
  %40 = getelementptr inbounds %struct.Exception, ptr %13, i32 0, i32 2
  store ptr null, ptr %40, align 8, !tbaa !31
  %41 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %42 = getelementptr inbounds %struct.Runtime, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.ExceptionMgr, ptr %42, i32 0, i32 0
  store ptr %13, ptr %43, align 8, !tbaa !24
  %44 = getelementptr inbounds %struct.Exception, ptr %13, i32 0, i32 3
  %45 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], ptr %44, i64 0, i64 0
  %46 = call i32 @_setjmp(ptr noundef %45) #9
  %47 = icmp eq i32 %46, 0
  %48 = zext i1 %47 to i32
  store i32 %48, ptr %14, align 4, !tbaa !9
  %49 = load i32, ptr %14, align 4, !tbaa !9
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %133

51:                                               ; preds = %33
  br label %52

52:                                               ; preds = %127, %51
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ServiceReq, ptr %53, i32 0, i32 2
  %55 = load i32, ptr %54, align 8, !tbaa !9
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ServiceReq, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = icmp slt i32 %55, %58
  br i1 %59, label %60, label %132

60:                                               ; preds = %52
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = load i32, ptr %8, align 4, !tbaa !9
  %63 = call zeroext i1 @service_filter(ptr noundef %61, i32 noundef %62)
  br i1 %63, label %69, label %64

64:                                               ; preds = %60
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Engine, ptr %65, i32 0, i32 6
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  call void @service_schedule(ptr noundef %67, ptr noundef %68)
  store ptr null, ptr %10, align 8, !tbaa !5
  br label %132

69:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.ServiceReq, ptr %70, i32 0, i32 4
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ServiceReq, ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 8, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [0 x %struct.Action], ptr %71, i64 0, i64 %75
  store ptr %76, ptr %15, align 8, !tbaa !5
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.Action, ptr %77, i32 0, i32 0
  %79 = load i32, ptr %78, align 4, !tbaa !32
  switch i32 %79, label %126 [
    i32 1, label %80
    i32 2, label %94
    i32 3, label %96
    i32 4, label %99
    i32 5, label %105
    i32 6, label %110
    i32 7, label %116
    i32 8, label %121
  ]

80:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %81 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %82 = getelementptr inbounds %struct.Runtime, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !34
  %84 = getelementptr inbounds %struct.Context, ptr %83, i32 0, i32 2
  %85 = load ptr, ptr %84, align 8, !tbaa !35
  %86 = getelementptr inbounds %struct.Global, ptr %85, i32 0, i32 0
  %87 = load ptr, ptr %86, align 8, !tbaa !37
  %88 = getelementptr inbounds %struct.Config, ptr %87, i32 0, i32 14
  %89 = call i64 @var_int_of(ptr noundef %88)
  store i64 %89, ptr %16, align 8, !tbaa !39
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.Engine, ptr %90, i32 0, i32 5
  %92 = load ptr, ptr %91, align 8, !tbaa !41
  %93 = load i64, ptr %16, align 8, !tbaa !39
  call void @wal_rotate(ptr noundef %92, i64 noundef %93)
  store i32 4, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  br label %127

94:                                               ; preds = %69
  %95 = load ptr, ptr %6, align 8, !tbaa !5
  call void @engine_gc(ptr noundef %95) #10
  br label %127

96:                                               ; preds = %69
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = load ptr, ptr %7, align 8, !tbaa !5
  call void @engine_rebalance(ptr noundef %97, ptr noundef %98)
  br label %127

99:                                               ; preds = %69
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = load ptr, ptr %10, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.ServiceReq, ptr %101, i32 0, i32 0
  %103 = load i64, ptr %102, align 8, !tbaa !39
  %104 = call zeroext i1 @engine_drop_file(ptr noundef %100, i64 noundef %103, i1 noundef zeroext true, i1 noundef zeroext true, i32 noundef 1)
  br label %127

105:                                              ; preds = %69
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = load ptr, ptr %10, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.ServiceReq, ptr %107, i32 0, i32 0
  %109 = load i64, ptr %108, align 8, !tbaa !39
  call void @engine_drop(ptr noundef %106, i64 noundef %109, i1 noundef zeroext true, i32 noundef 8)
  br label %127

110:                                              ; preds = %69
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  call void @refresh_reset(ptr noundef %111)
  %112 = load ptr, ptr %7, align 8, !tbaa !5
  %113 = load ptr, ptr %10, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.ServiceReq, ptr %113, i32 0, i32 0
  %115 = load i64, ptr %114, align 8, !tbaa !39
  call void @refresh_run(ptr noundef %112, i64 noundef %115, ptr noundef null, i1 noundef zeroext true)
  br label %127

116:                                              ; preds = %69
  %117 = load ptr, ptr %6, align 8, !tbaa !5
  %118 = load ptr, ptr %10, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.ServiceReq, ptr %118, i32 0, i32 0
  %120 = load i64, ptr %119, align 8, !tbaa !39
  call void @engine_download(ptr noundef %117, i64 noundef %120, i1 noundef zeroext true, i1 noundef zeroext true)
  br label %127

121:                                              ; preds = %69
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = load ptr, ptr %10, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.ServiceReq, ptr %123, i32 0, i32 0
  %125 = load i64, ptr %124, align 8, !tbaa !39
  call void @engine_upload(ptr noundef %122, i64 noundef %125, i1 noundef zeroext true, i1 noundef zeroext true)
  br label %127

126:                                              ; preds = %69
  br label %127

127:                                              ; preds = %126, %121, %116, %110, %105, %99, %96, %94, %80
  %128 = load ptr, ptr %10, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.ServiceReq, ptr %128, i32 0, i32 2
  %130 = load i32, ptr %129, align 8, !tbaa !9
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %129, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  br label %52, !llvm.loop !42

132:                                              ; preds = %64, %52
  br label %133

133:                                              ; preds = %132, %33
  %134 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %135 = getelementptr inbounds %struct.Runtime, ptr %134, i32 0, i32 0
  %136 = call zeroext i1 @exception_mgr_leave(ptr noundef %135, ptr noundef %13)
  br i1 %136, label %137, label %138

137:                                              ; preds = %133
  br label %138

138:                                              ; preds = %137, %133
  %139 = load ptr, ptr %10, align 8, !tbaa !5
  %140 = icmp ne ptr %139, null
  br i1 %140, label %141, label %143

141:                                              ; preds = %138
  %142 = load ptr, ptr %10, align 8, !tbaa !5
  call void @service_req_free(ptr noundef %142)
  br label %143

143:                                              ; preds = %141, %138
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 224, ptr %13) #8
  br label %144

144:                                              ; preds = %143, %32, %28
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  %145 = load i1, ptr %5, align 1
  ret i1 %145
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @service_next(ptr noundef, i32 noundef, i1 noundef zeroext, ptr noundef) #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @service_filter(ptr noundef, i32 noundef) #7

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

declare void @wal_rotate(ptr noundef, i64 noundef) #5

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 returns_twice "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 = { 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 #5 = { "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 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { nounwind returns_twice }
attributes #10 = { hot }

!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, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !6, i64 176}
!14 = !{!"Engine", !15, i64 0, !16, i64 40, !17, i64 88, !19, i64 104, !21, i64 136, !6, i64 168, !6, i64 176, !6, i64 184}
!15 = !{!"Mutex", !7, i64 0}
!16 = !{!"CondVar", !7, i64 0}
!17 = !{!"Mapping", !18, i64 0, !10, i64 8}
!18 = !{!"Rbtree", !6, i64 0}
!19 = !{!"Pipeline", !20, i64 0, !10, i64 16, !6, i64 24}
!20 = !{!"List", !6, i64 0, !6, i64 8}
!21 = !{!"StorageMgr", !20, i64 0, !10, i64 16, !6, i64 24}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!25, !6, i64 0}
!25 = !{!"Runtime", !26, i64 0, !27, i64 8, !6, i64 312}
!26 = !{!"ExceptionMgr", !6, i64 0}
!27 = !{!"Error", !7, i64 0, !10, i64 256, !6, i64 264, !6, i64 272, !10, i64 280, !6, i64 288, !6, i64 296}
!28 = !{!29, !6, i64 0}
!29 = !{!"Exception", !6, i64 0, !12, i64 8, !6, i64 16, !7, i64 24}
!30 = !{!29, !12, i64 8}
!31 = !{!29, !6, i64 16}
!32 = !{!33, !10, i64 0}
!33 = !{!"Action", !10, i64 0}
!34 = !{!25, !6, i64 312}
!35 = !{!36, !6, i64 16}
!36 = !{!"Context", !6, i64 0, !6, i64 8, !6, i64 16}
!37 = !{!38, !6, i64 0}
!38 = !{!"Global", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!39 = !{!40, !40, i64 0}
!40 = !{!"long", !7, i64 0}
!41 = !{!14, !6, i64 168}
!42 = distinct !{!42, !43}
!43 = !{!"llvm.loop.mustprogress"}


; 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.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.Action = type { i32 }

@mn_runtime = external thread_local global %struct.Runtime, align 8

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @engine_drop(ptr noundef, i64 noundef, i1 noundef zeroext, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @engine_drop_file(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @engine_download(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #2

; Function Attrs: nounwind returns_twice
declare i32 @_setjmp(ptr noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden zeroext i1 @exception_mgr_leave(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local void @engine_upload(ptr noundef, i64 noundef, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #2

declare void @refresh_reset(ptr noundef) local_unnamed_addr #5

declare void @refresh_run(ptr noundef, i64 noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #5

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

; Function Attrs: hot nounwind uwtable
declare dso_local void @engine_gc(ptr noundef) local_unnamed_addr #6

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @var_int_of(ptr noundef) local_unnamed_addr #7

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @engine_service(ptr noundef %0, ptr noundef %1, i32 noundef %2, i1 noundef zeroext %3) local_unnamed_addr #2 {
  %5 = alloca ptr, align 8
  %6 = alloca %struct.Exception, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  store ptr null, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 176
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = call zeroext i1 @service_next(ptr noundef %8, i32 noundef %2, i1 noundef zeroext %3, ptr noundef nonnull %5)
  %10 = load ptr, ptr %5, align 8
  %11 = icmp eq ptr %10, null
  %or.cond = select i1 %9, i1 true, i1 %11
  br i1 %or.cond, label %76, label %12

12:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 224, ptr nonnull %6) #8
  %13 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  store ptr %14, ptr %6, align 8, !tbaa !23
  %15 = getelementptr inbounds i8, ptr %6, i64 8
  store i8 0, ptr %15, align 8, !tbaa !26
  %16 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr null, ptr %16, align 8, !tbaa !27
  store ptr %6, ptr %13, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %6, i64 24
  %18 = call i32 @_setjmp(ptr noundef nonnull %17) #9
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %12
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load i32, ptr %21, align 8, !tbaa !28
  %23 = getelementptr inbounds i8, ptr %20, i64 28
  %24 = load i32, ptr %23, align 4, !tbaa !28
  %25 = icmp slt i32 %22, %24
  br i1 %25, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %26 = getelementptr inbounds i8, ptr %13, i64 312
  %27 = getelementptr inbounds i8, ptr %0, i64 168
  br label %28

28:                                               ; preds = %.lr.ph, %64
  %29 = phi ptr [ %20, %.lr.ph ], [ %65, %64 ]
  %30 = call zeroext i1 @service_filter(ptr noundef nonnull %29, i32 noundef %2)
  br i1 %30, label %34, label %31

31:                                               ; preds = %28
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  call void @service_schedule(ptr noundef %32, ptr noundef %33)
  store ptr null, ptr %5, align 8, !tbaa !5
  br label %.loopexit

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 32
  %37 = getelementptr inbounds i8, ptr %35, i64 24
  %38 = load i32, ptr %37, align 8, !tbaa !28
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [0 x %struct.Action], ptr %36, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !29
  switch i32 %41, label %64 [
    i32 1, label %42
    i32 2, label %50
    i32 3, label %51
    i32 4, label %52
    i32 5, label %55
    i32 6, label %57
    i32 7, label %60
    i32 8, label %62
  ]

42:                                               ; preds = %34
  %43 = load ptr, ptr %26, align 8, !tbaa !31
  %44 = getelementptr inbounds i8, ptr %43, i64 16
  %45 = load ptr, ptr %44, align 8, !tbaa !32
  %46 = load ptr, ptr %45, align 8, !tbaa !34
  %47 = getelementptr inbounds i8, ptr %46, i64 1232
  %48 = call i64 @var_int_of(ptr noundef nonnull %47)
  %49 = load ptr, ptr %27, align 8, !tbaa !36
  call void @wal_rotate(ptr noundef %49, i64 noundef %48) #8
  br label %64

50:                                               ; preds = %34
  call void @engine_gc(ptr noundef %0) #10
  br label %64

51:                                               ; preds = %34
  call void @engine_rebalance(ptr noundef %0, ptr noundef %1)
  br label %64

52:                                               ; preds = %34
  %53 = load i64, ptr %35, align 8, !tbaa !37
  %54 = call zeroext i1 @engine_drop_file(ptr noundef %0, i64 noundef %53, i1 noundef zeroext true, i1 noundef zeroext true, i32 noundef 1)
  br label %64

55:                                               ; preds = %34
  %56 = load i64, ptr %35, align 8, !tbaa !37
  call void @engine_drop(ptr noundef %0, i64 noundef %56, i1 noundef zeroext true, i32 noundef 8)
  br label %64

57:                                               ; preds = %34
  call void @refresh_reset(ptr noundef %1) #8
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = load i64, ptr %58, align 8, !tbaa !37
  call void @refresh_run(ptr noundef %1, i64 noundef %59, ptr noundef null, i1 noundef zeroext true) #8
  br label %64

60:                                               ; preds = %34
  %61 = load i64, ptr %35, align 8, !tbaa !37
  call void @engine_download(ptr noundef %0, i64 noundef %61, i1 noundef zeroext true, i1 noundef zeroext true)
  br label %64

62:                                               ; preds = %34
  %63 = load i64, ptr %35, align 8, !tbaa !37
  call void @engine_upload(ptr noundef %0, i64 noundef %63, i1 noundef zeroext true, i1 noundef zeroext true)
  br label %64

64:                                               ; preds = %34, %62, %60, %57, %55, %52, %51, %50, %42
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i64 24
  %67 = load i32, ptr %66, align 8, !tbaa !28
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %66, align 8, !tbaa !28
  %69 = getelementptr inbounds i8, ptr %65, i64 28
  %70 = load i32, ptr %69, align 4, !tbaa !28
  %71 = icmp slt i32 %68, %70
  br i1 %71, label %28, label %.loopexit, !llvm.loop !39

.loopexit:                                        ; preds = %64, %.preheader, %31, %12
  %72 = call zeroext i1 @exception_mgr_leave(ptr noundef nonnull %13, ptr noundef nonnull %6)
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %73, null
  br i1 %.not, label %75, label %74

74:                                               ; preds = %.loopexit
  call void @service_req_free(ptr noundef nonnull %73)
  br label %75

75:                                               ; preds = %74, %.loopexit
  call void @llvm.lifetime.end.p0(i64 224, ptr nonnull %6) #8
  br label %76

76:                                               ; preds = %4, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  ret i1 %9
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @service_next(ptr noundef, i32 noundef, i1 noundef zeroext, ptr noundef) local_unnamed_addr #7

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @service_filter(ptr noundef, i32 noundef) local_unnamed_addr #7

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

declare void @wal_rotate(ptr noundef, i64 noundef) local_unnamed_addr #5

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 returns_twice "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 = { 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 #5 = { "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 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { nounwind returns_twice }
attributes #10 = { hot }

!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 176}
!10 = !{!"Engine", !11, i64 0, !12, i64 40, !13, i64 88, !16, i64 104, !18, i64 136, !6, i64 168, !6, i64 176, !6, i64 184}
!11 = !{!"Mutex", !7, i64 0}
!12 = !{!"CondVar", !7, i64 0}
!13 = !{!"Mapping", !14, i64 0, !15, i64 8}
!14 = !{!"Rbtree", !6, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"Pipeline", !17, i64 0, !15, i64 16, !6, i64 24}
!17 = !{!"List", !6, i64 0, !6, i64 8}
!18 = !{!"StorageMgr", !17, i64 0, !15, i64 16, !6, i64 24}
!19 = !{!20, !6, i64 0}
!20 = !{!"Runtime", !21, i64 0, !22, i64 8, !6, i64 312}
!21 = !{!"ExceptionMgr", !6, i64 0}
!22 = !{!"Error", !7, i64 0, !15, i64 256, !6, i64 264, !6, i64 272, !15, i64 280, !6, i64 288, !6, i64 296}
!23 = !{!24, !6, i64 0}
!24 = !{!"Exception", !6, i64 0, !25, i64 8, !6, i64 16, !7, i64 24}
!25 = !{!"_Bool", !7, i64 0}
!26 = !{!24, !25, i64 8}
!27 = !{!24, !6, i64 16}
!28 = !{!15, !15, i64 0}
!29 = !{!30, !15, i64 0}
!30 = !{!"Action", !15, i64 0}
!31 = !{!20, !6, i64 312}
!32 = !{!33, !6, i64 16}
!33 = !{!"Context", !6, i64 0, !6, i64 8, !6, i64 16}
!34 = !{!35, !6, i64 0}
!35 = !{!"Global", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!36 = !{!10, !6, i64 168}
!37 = !{!38, !38, i64 0}
!38 = !{!"long", !7, i64 0}
!39 = distinct !{!39, !40}
!40 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass