; 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_upload = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [52 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

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

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

; 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) #6

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

; 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

; Function Attrs: nounwind uwtable
define dso_local void @engine_upload(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3) #8 {
  %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_upload, i32 noundef 402, ptr noundef @.str.4, i64 noundef %36) #10
  unreachable

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

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_upload, i32 noundef 411, ptr noundef @.str.5, i64 noundef %56) #10
  unreachable

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

58:                                               ; preds = %38
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = call zeroext i1 @part_has(ptr noundef %59, i32 noundef 8)
  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 %114

64:                                               ; preds = %58
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = call zeroext i1 @part_has(ptr noundef %65, i32 noundef 1)
  br i1 %66, label %75, 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)
  %70 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %71 = getelementptr inbounds %struct.Runtime, ptr %70, i32 0, i32 1
  %72 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %73 = getelementptr inbounds %struct.Runtime, ptr %72, i32 0, i32 0
  %74 = load i64, ptr %6, align 8, !tbaa !9
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef %71, ptr noundef %73, ptr noundef @.str, ptr noundef @__func__.engine_upload, i32 noundef 426, ptr noundef @.str.6, i64 noundef %74) #10
  unreachable

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

93:                                               ; preds = %75
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  call void @part_upload(ptr noundef %94)
  br label %95

95:                                               ; preds = %93, %75
  %96 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %97 = getelementptr inbounds %struct.Runtime, ptr %96, i32 0, i32 0
  %98 = call zeroext i1 @exception_mgr_leave(ptr noundef %97, ptr noundef %12)
  br i1 %98, label %99, label %104

99:                                               ; preds = %95
  %100 = load ptr, ptr %5, align 8, !tbaa !5
  %101 = load ptr, ptr %9, align 8, !tbaa !5
  call void @engine_unlock(ptr noundef %100, ptr noundef %101, i32 noundef 0)
  %102 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %103 = getelementptr inbounds %struct.Runtime, ptr %102, i32 0, i32 0
  call void @exception_mgr_throw(ptr noundef %103) #10
  unreachable

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

114:                                              ; preds = %104, %61, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  br label %115

115:                                              ; preds = %114, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #9
  %116 = load i32, ptr %10, align 4
  switch i32 %116, label %118 [
    i32 0, label %117
    i32 1, label %117
  ]

117:                                              ; preds = %115, %115
  ret void

118:                                              ; preds = %115
  unreachable
}

declare void @part_upload(ptr noundef) #5

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 = { "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 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_upload = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [52 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

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

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

; 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 #5

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

; 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

; Function Attrs: nounwind uwtable
define dso_local void @engine_upload(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3) local_unnamed_addr #7 {
  %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 %39, 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_upload, i32 noundef 402, ptr noundef nonnull @.str.4, 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
  %.not28 = icmp eq ptr %14, null
  br i1 %.not28, 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 %39, 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_upload, i32 noundef 411, ptr noundef nonnull @.str.5, i64 noundef %1) #9
  unreachable

19:                                               ; preds = %11
  %20 = call zeroext i1 @part_has(ptr noundef nonnull %12, i32 noundef 8)
  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 %39

22:                                               ; preds = %19
  %23 = call zeroext i1 @part_has(ptr noundef nonnull %12, i32 noundef 1)
  %24 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  br i1 %23, label %27, label %25

25:                                               ; preds = %22
  call void @engine_unlock(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 0) #8
  %26 = getelementptr inbounds i8, ptr %24, i64 8
  call void (ptr, ptr, ptr, ptr, i32, ptr, ...) @error_throw_as(ptr noundef nonnull %26, ptr noundef nonnull %24, ptr noundef nonnull @.str, ptr noundef nonnull @__func__.engine_upload, i32 noundef 426, ptr noundef nonnull @.str.6, i64 noundef %1) #9
  unreachable

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

34:                                               ; preds = %27
  call void @part_upload(ptr noundef nonnull %12) #8
  br label %35

35:                                               ; preds = %34, %27
  %36 = call zeroext i1 @exception_mgr_leave(ptr noundef nonnull %24, ptr noundef nonnull %5)
  br i1 %36, label %37, label %38

37:                                               ; preds = %35
  call void @engine_unlock(ptr noundef %0, ptr noundef nonnull %6, i32 noundef 0) #8
  call void @exception_mgr_throw(ptr noundef nonnull %24) #9
  unreachable

38:                                               ; preds = %35
  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 8)
  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 %39

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

declare void @part_upload(ptr noundef) local_unnamed_addr #4

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 = { "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 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 #6 = { 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 #7 = { 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