; 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.Ref = type { ptr, %struct.Lockage, %struct.Slice }
%struct.Lockage = type { [2 x %struct.Lock], ptr, ptr }
%struct.Lock = type { i64, i32, i32 }
%struct.Slice = type { i64, i64, %struct.RbtreeNode }
%struct.RbtreeNode = type { ptr, ptr, ptr, i8 }
%struct.Part = type { %struct.Id, i32, i64, i64, i8, ptr, %struct.Memtable, %struct.Memtable, %struct.File, %struct.Index, %struct.Buf, ptr, ptr, ptr, %struct.List }
%struct.Id = type { i64, i64 }
%struct.Memtable = type { ptr, %struct.Rbtree, i32, i32, i32, i64, i64, i64, %struct.List, i32, %struct.Heap }
%struct.Rbtree = type { ptr }
%struct.Heap = type { ptr, ptr, i32, ptr }
%struct.File = type { i32, i64, %struct.Str, %struct.List }
%struct.Str = type { ptr, ptr, i8 }
%struct.Index = type <{ i32, i32, i32, i32, %struct.Id, i32, i32, i64, i64, i64, i64, i32, i64, i64, i64, i32, i64, i8, i8, [4 x i32] }>
%struct.Buf = type { ptr, ptr, ptr }
%struct.List = type { ptr, ptr }
%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.Pipeline = type { %struct.List, i32, ptr }
%struct.StorageMgr = type { %struct.List, i32, ptr }

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [77 x i8], align 1
@__func__.engine_download = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1

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

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @error_throw_as(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

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

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

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

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

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

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

28:                                               ; preds = %4
  %29 = load i8, ptr %7, align 1, !tbaa !11, !range !13, !noundef !14
  %30 = trunc i8 %29 to i1
  br i1 %30, label %37, label %31

31:                                               ; preds = %28
  %32 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %33 = getelementptr inbounds %struct.Runtime, ptr %32, i32 0, i32 1
  %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 = load i64, ptr %6, align 8, !tbaa !9
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %33, ptr noundef %35, ptr noundef @.str, ptr noundef @__func__.engine_download, i32 noundef 333, ptr noundef @.str.2, i64 noundef %36) #10
  unreachable

37:                                               ; preds = %28
  store i32 1, ptr %10, align 4
  br label %110

38:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Ref, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !15
  store ptr %41, ptr %11, align 8, !tbaa !5
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Part, ptr %42, i32 0, i32 11
  %44 = load ptr, ptr %43, align 8, !tbaa !20
  %45 = icmp ne ptr %44, null
  br i1 %45, label %58, label %46

46:                                               ; preds = %38
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  call void @engine_unlock(ptr noundef %47, ptr noundef %48, i32 noundef 0)
  %49 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %50 = trunc i8 %49 to i1
  br i1 %50, label %57, label %51

51:                                               ; preds = %46
  %52 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %53 = getelementptr inbounds %struct.Runtime, ptr %52, i32 0, i32 1
  %54 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %55 = getelementptr inbounds %struct.Runtime, ptr %54, i32 0, i32 0
  %56 = load i64, ptr %6, align 8, !tbaa !9
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %53, ptr noundef %55, ptr noundef @.str, ptr noundef @__func__.engine_download, i32 noundef 342, ptr noundef @.str.3, i64 noundef %56) #10
  unreachable

57:                                               ; preds = %46
  store i32 1, ptr %10, align 4
  br label %109

58:                                               ; preds = %38
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = call zeroext i1 @part_has(ptr noundef %59, i32 noundef 1)
  br i1 %60, label %61, label %64

61:                                               ; preds = %58
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  call void @engine_unlock(ptr noundef %62, ptr noundef %63, i32 noundef 0)
  store i32 1, ptr %10, align 4
  br label %109

64:                                               ; preds = %58
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = call zeroext i1 @part_has(ptr noundef %65, i32 noundef 8)
  br i1 %66, label %70, label %67

67:                                               ; preds = %64
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  call void @engine_unlock(ptr noundef %68, ptr noundef %69, i32 noundef 0)
  store i32 1, ptr %10, align 4
  br label %109

70:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 224, ptr %12) #9
  %71 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %72 = getelementptr inbounds %struct.Runtime, ptr %71, i32 0, i32 0
  %73 = getelementptr inbounds %struct.ExceptionMgr, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !32
  %75 = getelementptr inbounds %struct.Exception, ptr %12, i32 0, i32 0
  store ptr %74, ptr %75, align 8, !tbaa !36
  %76 = getelementptr inbounds %struct.Exception, ptr %12, i32 0, i32 1
  store i8 0, ptr %76, align 8, !tbaa !38
  %77 = getelementptr inbounds %struct.Exception, ptr %12, i32 0, i32 2
  store ptr null, ptr %77, align 8, !tbaa !39
  %78 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %79 = getelementptr inbounds %struct.Runtime, ptr %78, i32 0, i32 0
  %80 = getelementptr inbounds %struct.ExceptionMgr, ptr %79, i32 0, i32 0
  store ptr %12, ptr %80, align 8, !tbaa !32
  %81 = getelementptr inbounds %struct.Exception, ptr %12, i32 0, i32 3
  %82 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], ptr %81, i64 0, i64 0
  %83 = call i32 @_setjmp(ptr noundef %82) #11
  %84 = icmp eq i32 %83, 0
  %85 = zext i1 %84 to i32
  store i32 %85, ptr %13, align 4, !tbaa !40
  %86 = load i32, ptr %13, align 4, !tbaa !40
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %90

88:                                               ; preds = %70
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  call void @part_download(ptr noundef %89)
  br label %90

90:                                               ; preds = %88, %70
  %91 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %92 = getelementptr inbounds %struct.Runtime, ptr %91, i32 0, i32 0
  %93 = call zeroext i1 @exception_mgr_leave(ptr noundef %92, ptr noundef %12)
  br i1 %93, label %94, label %99

94:                                               ; preds = %90
  %95 = load ptr, ptr %5, align 8, !tbaa !5
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  call void @engine_unlock(ptr noundef %95, ptr noundef %96, i32 noundef 0)
  %97 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %98 = getelementptr inbounds %struct.Runtime, ptr %97, i32 0, i32 0
  call void @exception_mgr_throw(ptr noundef %98) #10
  unreachable

99:                                               ; preds = %90
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.Engine, ptr %100, i32 0, i32 0
  call void @mutex_lock(ptr noundef %101)
  %102 = load ptr, ptr %9, align 8, !tbaa !5
  call void @ref_lock(ptr noundef %102, i32 noundef 1)
  %103 = load ptr, ptr %11, align 8, !tbaa !5
  call void @part_set(ptr noundef %103, i32 noundef 1)
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  call void @ref_unlock(ptr noundef %104, i32 noundef 1)
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.Engine, ptr %105, i32 0, i32 0
  call void @mutex_unlock(ptr noundef %106)
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = load ptr, ptr %9, align 8, !tbaa !5
  call void @engine_unlock(ptr noundef %107, ptr noundef %108, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 224, ptr %12) #9
  store i32 0, ptr %10, align 4
  br label %109

109:                                              ; preds = %99, %67, %61, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  br label %110

110:                                              ; preds = %109, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  %111 = load i32, ptr %10, align 4
  switch i32 %111, label %113 [
    i32 0, label %112
    i32 1, label %112
  ]

112:                                              ; preds = %110, %110
  ret void

113:                                              ; preds = %110
  unreachable
}

declare ptr @engine_lock(ptr noundef, i64 noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext) #6

declare void @engine_unlock(ptr noundef, ptr noundef, i32 noundef) #6

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

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

declare void @part_download(ptr noundef) #6

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

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @exception_mgr_throw(ptr noundef) #1

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

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

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

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

!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 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !6, i64 0}
!16 = !{!"Ref", !6, i64 0, !17, i64 8, !18, i64 56}
!17 = !{!"Lockage", !7, i64 0, !6, i64 32, !6, i64 40}
!18 = !{!"Slice", !10, i64 0, !10, i64 8, !19, i64 16}
!19 = !{!"RbtreeNode", !6, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}
!20 = !{!21, !6, i64 496}
!21 = !{!"Part", !22, i64 0, !23, i64 16, !10, i64 24, !10, i64 32, !12, i64 40, !6, i64 48, !24, i64 56, !24, i64 168, !28, i64 280, !30, i64 336, !31, i64 472, !6, i64 496, !6, i64 504, !6, i64 512, !26, i64 520}
!22 = !{!"Id", !10, i64 0, !10, i64 8}
!23 = !{!"int", !7, i64 0}
!24 = !{!"Memtable", !6, i64 0, !25, i64 8, !23, i64 16, !23, i64 20, !23, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !26, i64 56, !23, i64 72, !27, i64 80}
!25 = !{!"Rbtree", !6, i64 0}
!26 = !{!"List", !6, i64 0, !6, i64 8}
!27 = !{!"Heap", !6, i64 0, !6, i64 8, !23, i64 16, !6, i64 24}
!28 = !{!"File", !23, i64 0, !10, i64 8, !29, i64 16, !26, i64 40}
!29 = !{!"Str", !6, i64 0, !6, i64 8, !12, i64 16}
!30 = !{!"Index", !23, i64 0, !23, i64 4, !23, i64 8, !23, i64 12, !22, i64 16, !23, i64 32, !23, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !23, i64 72, !10, i64 76, !10, i64 84, !10, i64 92, !23, i64 100, !10, i64 104, !7, i64 112, !7, i64 113, !7, i64 114}
!31 = !{!"Buf", !6, i64 0, !6, i64 8, !6, i64 16}
!32 = !{!33, !6, i64 0}
!33 = !{!"Runtime", !34, i64 0, !35, i64 8, !6, i64 312}
!34 = !{!"ExceptionMgr", !6, i64 0}
!35 = !{!"Error", !7, i64 0, !23, i64 256, !6, i64 264, !6, i64 272, !23, i64 280, !6, i64 288, !6, i64 296}
!36 = !{!37, !6, i64 0}
!37 = !{!"Exception", !6, i64 0, !12, i64 8, !6, i64 16, !7, i64 24}
!38 = !{!37, !12, i64 8}
!39 = !{!37, !6, i64 16}
!40 = !{!23, !23, i64 0}


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

@mn_runtime = external thread_local global %struct.Runtime, align 8
@.str = external hidden unnamed_addr constant [77 x i8], align 1
@__func__.engine_download = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @error_throw_as(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @engine_download(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3) local_unnamed_addr #4 {
  %5 = alloca %struct.Exception, align 8
  %6 = call ptr @engine_lock(ptr noundef %0, i64 noundef %1, i32 noundef 0, i1 noundef zeroext false, i1 noundef zeroext false) #8
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %11, !prof !5

7:                                                ; preds = %4
  br i1 %2, label %38, label %8

8:                                                ; preds = %7
  %9 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef nonnull %10, ptr noundef nonnull %9, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.engine_download, i32 noundef 333, ptr noundef nonnull @.str.2, i64 noundef %1) #9
  unreachable

11:                                               ; preds = %4
  %12 = load ptr, ptr %6, align 8, !tbaa !6
  %13 = getelementptr inbounds i8, ptr %12, i64 496
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %.not27 = icmp eq ptr %14, null
  br i1 %.not27, label %15, label %19

15:                                               ; preds = %11
  call void @engine_unlock(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 0) #8
  br i1 %3, label %38, label %16

16:                                               ; preds = %15
  %17 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef nonnull %18, ptr noundef nonnull %17, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.engine_download, i32 noundef 342, ptr noundef nonnull @.str.3, i64 noundef %1) #9
  unreachable

19:                                               ; preds = %11
  %20 = call zeroext i1 @part_has(ptr noundef nonnull %12, i32 noundef 1)
  br i1 %20, label %21, label %22

21:                                               ; preds = %19
  call void @engine_unlock(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 0) #8
  br label %38

22:                                               ; preds = %19
  %23 = call zeroext i1 @part_has(ptr noundef nonnull %12, i32 noundef 8)
  br i1 %23, label %25, label %24

24:                                               ; preds = %22
  call void @engine_unlock(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 0) #8
  br label %38

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 224, ptr nonnull %5) #8
  %26 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %27 = load ptr, ptr %26, align 8, !tbaa !28
  store ptr %27, ptr %5, align 8, !tbaa !32
  %28 = getelementptr inbounds i8, ptr %5, i64 8
  store i8 0, ptr %28, align 8, !tbaa !34
  %29 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr null, ptr %29, align 8, !tbaa !35
  store ptr %5, ptr %26, align 8, !tbaa !28
  %30 = getelementptr inbounds i8, ptr %5, i64 24
  %31 = call i32 @_setjmp(ptr noundef nonnull %30) #10
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %25
  call void @part_download(ptr noundef nonnull %12) #8
  br label %34

34:                                               ; preds = %33, %25
  %35 = call zeroext i1 @exception_mgr_leave(ptr noundef nonnull %26, ptr noundef nonnull %5)
  br i1 %35, label %36, label %37

36:                                               ; preds = %34
  call void @engine_unlock(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 0) #8
  call void @exception_mgr_throw(ptr noundef nonnull %26) #9
  unreachable

37:                                               ; preds = %34
  call void @mutex_lock(ptr noundef %0)
  call void @ref_lock(ptr noundef nonnull %6, i32 noundef 1)
  call void @part_set(ptr noundef nonnull %12, i32 noundef 1)
  call void @ref_unlock(ptr noundef nonnull %6, i32 noundef 1)
  call void @mutex_unlock(ptr noundef %0)
  call void @engine_unlock(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 0) #8
  call void @llvm.lifetime.end.p0(i64 224, ptr nonnull %5) #8
  br label %38

38:                                               ; preds = %21, %24, %37, %15, %7
  ret void
}

declare ptr @engine_lock(ptr noundef, i64 noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext) local_unnamed_addr #5

declare void @engine_unlock(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #5

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

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

declare void @part_download(ptr noundef) local_unnamed_addr #5

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

; Function Attrs: inlinehint noreturn nounwind uwtable
declare hidden void @exception_mgr_throw(ptr noundef) local_unnamed_addr #0

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

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

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

attributes #0 = { inlinehint noreturn nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = { 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 #7 = { 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 #8 = { nounwind }
attributes #9 = { noreturn }
attributes #10 = { nounwind returns_twice }

!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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !8, i64 0}
!7 = !{!"Ref", !8, i64 0, !11, i64 8, !12, i64 56}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"Lockage", !9, i64 0, !8, i64 32, !8, i64 40}
!12 = !{!"Slice", !13, i64 0, !13, i64 8, !14, i64 16}
!13 = !{!"long", !9, i64 0}
!14 = !{!"RbtreeNode", !8, i64 0, !8, i64 8, !8, i64 16, !9, i64 24}
!15 = !{!16, !8, i64 496}
!16 = !{!"Part", !17, i64 0, !18, i64 16, !13, i64 24, !13, i64 32, !19, i64 40, !8, i64 48, !20, i64 56, !20, i64 168, !24, i64 280, !26, i64 336, !27, i64 472, !8, i64 496, !8, i64 504, !8, i64 512, !22, i64 520}
!17 = !{!"Id", !13, i64 0, !13, i64 8}
!18 = !{!"int", !9, i64 0}
!19 = !{!"_Bool", !9, i64 0}
!20 = !{!"Memtable", !8, i64 0, !21, i64 8, !18, i64 16, !18, i64 20, !18, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !22, i64 56, !18, i64 72, !23, i64 80}
!21 = !{!"Rbtree", !8, i64 0}
!22 = !{!"List", !8, i64 0, !8, i64 8}
!23 = !{!"Heap", !8, i64 0, !8, i64 8, !18, i64 16, !8, i64 24}
!24 = !{!"File", !18, i64 0, !13, i64 8, !25, i64 16, !22, i64 40}
!25 = !{!"Str", !8, i64 0, !8, i64 8, !19, i64 16}
!26 = !{!"Index", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !17, i64 16, !18, i64 32, !18, i64 36, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !18, i64 72, !13, i64 76, !13, i64 84, !13, i64 92, !18, i64 100, !13, i64 104, !9, i64 112, !9, i64 113, !9, i64 114}
!27 = !{!"Buf", !8, i64 0, !8, i64 8, !8, i64 16}
!28 = !{!29, !8, i64 0}
!29 = !{!"Runtime", !30, i64 0, !31, i64 8, !8, i64 312}
!30 = !{!"ExceptionMgr", !8, i64 0}
!31 = !{!"Error", !9, i64 0, !18, i64 256, !8, i64 264, !8, i64 272, !18, i64 280, !8, i64 288, !8, i64 296}
!32 = !{!33, !8, i64 0}
!33 = !{!"Exception", !8, i64 0, !19, i64 8, !8, i64 16, !9, i64 24}
!34 = !{!33, !19, i64 8}
!35 = !{!33, !8, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LowerExpectIntrinsicPass,SROAPass,SimplifyCFGPass