; LLVM IR from pmwkaa/monotone :: monotone/main/api (monotone)

; 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.Guard = type { ptr, ptr, ptr }
%struct.monotone_cursor = type { i32, %struct.EngineCursor, ptr }
%struct.EngineCursor = type { ptr, %struct.PartCursor, ptr }
%struct.PartCursor = type { ptr, %struct.PartIterator, %struct.MemtableIterator, %struct.MemtableIterator, %struct.MergeIterator }
%struct.PartIterator = type { %struct.Iterator, %struct.RegionIterator, %struct.IndexIterator, ptr, ptr, %struct.Reader }
%struct.Iterator = type { ptr, ptr, ptr, ptr }
%struct.RegionIterator = type { %struct.Iterator, ptr, i32, ptr, ptr }
%struct.IndexIterator = type { ptr, ptr, ptr, i32 }
%struct.Reader = type { ptr, ptr, ptr, %struct.Buf, %struct.Buf, %struct.Buf }
%struct.Buf = type { ptr, ptr, ptr }
%struct.MemtableIterator = type { %struct.Iterator, ptr, ptr, i32, ptr, %struct.List }
%struct.List = type { ptr, ptr }
%struct.MergeIterator = type { %struct.Iterator, ptr, %struct.Buf, i32, ptr }
%struct.monotone = type { i32, %struct.Main }
%struct.Main = type { %struct.Rwlock, %struct.File, %struct.Engine, %struct.Wal, %struct.Service, %struct.WorkerMgr, %struct.CloudMgr, %struct.MemoryMgr, %struct.CompressionMgr, %struct.EncryptionMgr, %struct.Random, %struct.Comparator, %struct.Logger, %struct.Context, %struct.Control, %struct.Config, %struct.Global }
%struct.Rwlock = type { %union.pthread_rwlock_t }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%struct.File = type { i32, i64, %struct.Str, %struct.List }
%struct.Str = type { ptr, ptr, i8 }
%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.StorageMgr = type { %struct.List, i32, ptr }
%struct.Wal = type { %struct.Mutex, %struct.WalId, ptr }
%struct.WalId = type { %struct.Spinlock, i32, %struct.Buf }
%struct.Spinlock = type { i32 }
%struct.Service = type { %struct.Mutex, %struct.CondVar, %struct.List, i32, i32, i8 }
%struct.WorkerMgr = type { i32, ptr }
%struct.CloudMgr = type { %struct.List, i32 }
%struct.MemoryMgr = type { %struct.Mutex, %struct.CondVar, i32, ptr, i32, i32, i64, i8, i8, i64, i64 }
%struct.CompressionMgr = type { %struct.Cache, %struct.Cache }
%struct.Cache = type { %struct.Spinlock, %struct.List, i32 }
%struct.EncryptionMgr = type { %struct.Cache }
%struct.Random = type { %struct.Spinlock, [2 x i64] }
%struct.Comparator = type { i32 }
%struct.Logger = type { i8, i8, i32 }
%struct.Context = type { ptr, ptr, ptr }
%struct.Control = type { 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 }
%union.anon = type { %struct.Str }
%struct.Global = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

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

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

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

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

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

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

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

29:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %136

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

55:                                               ; preds = %30
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = icmp eq ptr %56, null
  br i1 %57, label %58, label %64

58:                                               ; preds = %55
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.monotone_cursor, ptr %59, i32 0, i32 1
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.monotone, ptr %61, i32 0, i32 1
  %63 = getelementptr inbounds %struct.Main, ptr %62, i32 0, i32 2
  call void @engine_cursor_open(ptr noundef %60, ptr noundef %63, ptr noundef null) #11
  br label %88

64:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = call ptr @event_malloc(ptr noundef %65)
  store ptr %66, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #9
  %67 = getelementptr inbounds %struct.Guard, ptr %13, i32 0, i32 0
  store ptr @event_free, ptr %67, align 8, !tbaa !34
  %68 = getelementptr inbounds %struct.Guard, ptr %13, i32 0, i32 1
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %69, ptr %68, align 8, !tbaa !36
  %70 = getelementptr inbounds %struct.Guard, ptr %13, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #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 !24
  store ptr %74, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #9
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.Exception, ptr %75, i32 0, i32 2
  %77 = load ptr, ptr %76, align 8, !tbaa !32
  store ptr %77, ptr %15, align 8, !tbaa !5
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.Exception, ptr %78, i32 0, i32 2
  store ptr %13, ptr %79, align 8, !tbaa !32
  %80 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %80, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #9
  %81 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %81, ptr %70, align 8, !tbaa !37
  %82 = load ptr, ptr %8, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.monotone_cursor, ptr %82, i32 0, i32 1
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.monotone, ptr %84, i32 0, i32 1
  %86 = getelementptr inbounds %struct.Main, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  call void @engine_cursor_open(ptr noundef %83, ptr noundef %86, ptr noundef %87) #11
  call void @guard_runner(ptr noundef %13)
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  br label %88

88:                                               ; preds = %64, %58
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.monotone_cursor, ptr %89, i32 0, i32 1
  call void @engine_cursor_skip_deletes(ptr noundef %90) #11
  br label %91

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

95:                                               ; preds = %91
  br label %96

96:                                               ; preds = %95, %91
  %97 = getelementptr inbounds %struct.Exception, ptr %10, i32 0, i32 1
  %98 = load i8, ptr %97, align 8, !tbaa !31, !range !38, !noundef !39
  %99 = trunc i8 %98 to i1
  %100 = xor i1 %99, true
  %101 = xor i1 %100, true
  %102 = zext i1 %101 to i32
  %103 = sext i32 %102 to i64
  %104 = call i64 @llvm.expect.i64(i64 %103, i64 0)
  %105 = icmp ne i64 %104, 0
  br i1 %105, label %106, label %134

106:                                              ; preds = %96
  %107 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %108 = getelementptr inbounds %struct.Runtime, ptr %107, i32 0, i32 0
  %109 = getelementptr inbounds %struct.ExceptionMgr, ptr %108, i32 0, i32 0
  %110 = load ptr, ptr %109, align 8, !tbaa !24
  %111 = getelementptr inbounds %struct.Exception, ptr %10, i32 0, i32 0
  store ptr %110, ptr %111, align 8, !tbaa !28
  %112 = getelementptr inbounds %struct.Exception, ptr %10, i32 0, i32 1
  store i8 0, ptr %112, align 8, !tbaa !31
  %113 = getelementptr inbounds %struct.Exception, ptr %10, i32 0, i32 2
  store ptr null, ptr %113, align 8, !tbaa !32
  %114 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %115 = getelementptr inbounds %struct.Runtime, ptr %114, i32 0, i32 0
  %116 = getelementptr inbounds %struct.ExceptionMgr, ptr %115, i32 0, i32 0
  store ptr %10, ptr %116, align 8, !tbaa !24
  %117 = getelementptr inbounds %struct.Exception, ptr %10, i32 0, i32 3
  %118 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], ptr %117, i64 0, i64 0
  %119 = call i32 @_setjmp(ptr noundef %118) #12
  %120 = icmp eq i32 %119, 0
  %121 = zext i1 %120 to i32
  store i32 %121, ptr %17, align 4, !tbaa !33
  %122 = load i32, ptr %17, align 4, !tbaa !33
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %128

124:                                              ; preds = %106
  %125 = load ptr, ptr %8, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.monotone_cursor, ptr %125, i32 0, i32 1
  call void @engine_cursor_close(ptr noundef %126) #11
  %127 = load ptr, ptr %8, align 8, !tbaa !5
  call void @mn_free(ptr noundef %127)
  store ptr null, ptr %8, align 8, !tbaa !5
  br label %128

128:                                              ; preds = %124, %106
  %129 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %130 = getelementptr inbounds %struct.Runtime, ptr %129, i32 0, i32 0
  %131 = call zeroext i1 @exception_mgr_leave(ptr noundef %130, ptr noundef %10)
  br i1 %131, label %132, label %133

132:                                              ; preds = %128
  br label %133

133:                                              ; preds = %132, %128
  br label %134

134:                                              ; preds = %133, %96
  %135 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %135, ptr %4, align 8
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 224, ptr %10) #9
  br label %136

136:                                              ; preds = %134, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #9
  %137 = load ptr, ptr %4, align 8
  ret ptr %137
}

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

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

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

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 willreturn memory(none) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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 #8 = { 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 #9 = { nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { hot }
attributes #12 = { 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, !11, i64 0}
!10 = !{!"monotone_cursor", !11, i64 0, !12, i64 8, !6, i64 512}
!11 = !{!"int", !7, i64 0}
!12 = !{!"EngineCursor", !6, i64 0, !13, i64 8, !6, i64 496}
!13 = !{!"PartCursor", !6, i64 0, !14, i64 8, !20, i64 248, !20, i64 328, !22, i64 408}
!14 = !{!"PartIterator", !15, i64 0, !16, i64 32, !17, i64 96, !6, i64 128, !6, i64 136, !18, i64 144}
!15 = !{!"Iterator", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!"RegionIterator", !15, i64 0, !6, i64 32, !11, i64 40, !6, i64 48, !6, i64 56}
!17 = !{!"IndexIterator", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!18 = !{!"Reader", !6, i64 0, !6, i64 8, !6, i64 16, !19, i64 24, !19, i64 48, !19, i64 72}
!19 = !{!"Buf", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"MemtableIterator", !15, i64 0, !6, i64 32, !6, i64 40, !11, i64 48, !6, i64 56, !21, i64 64}
!21 = !{!"List", !6, i64 0, !6, i64 8}
!22 = !{!"MergeIterator", !15, i64 0, !6, i64 32, !19, i64 40, !11, i64 64, !6, i64 72}
!23 = !{!10, !6, i64 512}
!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, !11, i64 256, !6, i64 264, !6, i64 272, !11, i64 280, !6, i64 288, !6, i64 296}
!28 = !{!29, !6, i64 0}
!29 = !{!"Exception", !6, i64 0, !30, i64 8, !6, i64 16, !7, i64 24}
!30 = !{!"_Bool", !7, i64 0}
!31 = !{!29, !30, i64 8}
!32 = !{!29, !6, i64 16}
!33 = !{!11, !11, i64 0}
!34 = !{!35, !6, i64 0}
!35 = !{!"Guard", !6, i64 0, !6, i64 8, !6, i64 16}
!36 = !{!35, !6, i64 8}
!37 = !{!35, !6, i64 16}
!38 = !{i8 0, i8 2}
!39 = !{}


; 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.Guard = type { ptr, ptr, ptr }

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

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden void @engine_cursor_close(ptr noundef) local_unnamed_addr #6

; Function Attrs: hot nounwind uwtable
define dso_local noundef ptr @monotone_cursor(ptr noundef %0, ptr nocapture noundef readnone %1, ptr noundef %2) local_unnamed_addr #7 {
  %4 = alloca %struct.Exception, align 8
  %5 = alloca %struct.Guard, align 8
  call void @monotone_enter(ptr noundef %0)
  %6 = call noalias dereferenceable_or_null(520) ptr @malloc(i64 noundef 520) #8
  %7 = icmp eq ptr %6, null
  br i1 %7, label %43, label %8, !prof !5

8:                                                ; preds = %3
  store i32 339455746, ptr %6, align 8, !tbaa !6
  %9 = getelementptr inbounds i8, ptr %6, i64 512
  store ptr %0, ptr %9, align 8, !tbaa !23
  %10 = getelementptr inbounds i8, ptr %6, i64 8
  call void @engine_cursor_init(ptr noundef nonnull %10) #9
  call void @llvm.lifetime.start.p0(i64 224, ptr nonnull %4) #10
  %11 = call align 8 ptr @llvm.threadlocal.address.p0(ptr align 8 @mn_runtime)
  %12 = load ptr, ptr %11, align 8, !tbaa !24
  store ptr %12, ptr %4, align 8, !tbaa !28
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  store i8 0, ptr %13, align 8, !tbaa !31
  %14 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr null, ptr %14, align 8, !tbaa !32
  store ptr %4, ptr %11, align 8, !tbaa !24
  %15 = getelementptr inbounds i8, ptr %4, i64 24
  %16 = call i32 @_setjmp(ptr noundef nonnull %15) #11
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %31

18:                                               ; preds = %8
  %19 = icmp eq ptr %2, null
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = getelementptr inbounds i8, ptr %0, i64 120
  call void @engine_cursor_open(ptr noundef nonnull %10, ptr noundef nonnull %21, ptr noundef null) #9
  br label %30

22:                                               ; preds = %18
  %23 = call ptr @event_malloc(ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #10
  store ptr @event_free, ptr %5, align 8, !tbaa !33
  %24 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %23, ptr %24, align 8, !tbaa !35
  %25 = getelementptr inbounds i8, ptr %5, i64 16
  %26 = load ptr, ptr %11, align 8, !tbaa !24
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  %28 = load ptr, ptr %27, align 8, !tbaa !32
  store ptr %5, ptr %27, align 8, !tbaa !32
  store ptr %28, ptr %25, align 8, !tbaa !36
  %29 = getelementptr inbounds i8, ptr %0, i64 120
  call void @engine_cursor_open(ptr noundef nonnull %10, ptr noundef nonnull %29, ptr noundef %23) #9
  call void @guard_runner(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #10
  br label %30

30:                                               ; preds = %22, %20
  call void @engine_cursor_skip_deletes(ptr noundef nonnull %10) #9
  br label %31

31:                                               ; preds = %30, %8
  %32 = call zeroext i1 @exception_mgr_leave(ptr noundef nonnull %11, ptr noundef nonnull %4)
  %33 = load i8, ptr %13, align 8, !tbaa !31, !range !37, !noundef !38
  %34 = trunc nuw i8 %33 to i1
  br i1 %34, label %35, label %42, !prof !5

35:                                               ; preds = %31
  %36 = load ptr, ptr %11, align 8, !tbaa !24
  store ptr %36, ptr %4, align 8, !tbaa !28
  store i8 0, ptr %13, align 8, !tbaa !31
  store ptr null, ptr %14, align 8, !tbaa !32
  store ptr %4, ptr %11, align 8, !tbaa !24
  %37 = call i32 @_setjmp(ptr noundef nonnull %15) #11
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %40

39:                                               ; preds = %35
  call void @engine_cursor_close(ptr noundef nonnull %10) #9
  call void @mn_free(ptr noundef nonnull %6)
  br label %40

40:                                               ; preds = %39, %35
  %.025 = phi ptr [ null, %39 ], [ %6, %35 ]
  %41 = call zeroext i1 @exception_mgr_leave(ptr noundef nonnull %11, ptr noundef nonnull %4)
  br label %42

42:                                               ; preds = %40, %31
  %.1 = phi ptr [ %.025, %40 ], [ %6, %31 ]
  call void @llvm.lifetime.end.p0(i64 224, ptr nonnull %4) #10
  br label %43

43:                                               ; preds = %3, %42
  %.0 = phi ptr [ %.1, %42 ], [ null, %3 ]
  ret ptr %.0
}

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden void @engine_cursor_init(ptr noundef) local_unnamed_addr #6

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden void @engine_cursor_open(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #6

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

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

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

; Function Attrs: hot inlinehint nounwind uwtable
declare hidden void @engine_cursor_skip_deletes(ptr noundef) local_unnamed_addr #6

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { 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 #6 = { 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 #7 = { 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 #8 = { nounwind allocsize(0) }
attributes #9 = { hot }
attributes #10 = { nounwind }
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 = !{!"branch_weights", !"expected", i32 1, i32 2000}
!6 = !{!7, !8, i64 0}
!7 = !{!"monotone_cursor", !8, i64 0, !11, i64 8, !12, i64 512}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"EngineCursor", !12, i64 0, !13, i64 8, !12, i64 496}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"PartCursor", !12, i64 0, !14, i64 8, !20, i64 248, !20, i64 328, !22, i64 408}
!14 = !{!"PartIterator", !15, i64 0, !16, i64 32, !17, i64 96, !12, i64 128, !12, i64 136, !18, i64 144}
!15 = !{!"Iterator", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!16 = !{!"RegionIterator", !15, i64 0, !12, i64 32, !8, i64 40, !12, i64 48, !12, i64 56}
!17 = !{!"IndexIterator", !12, i64 0, !12, i64 8, !12, i64 16, !8, i64 24}
!18 = !{!"Reader", !12, i64 0, !12, i64 8, !12, i64 16, !19, i64 24, !19, i64 48, !19, i64 72}
!19 = !{!"Buf", !12, i64 0, !12, i64 8, !12, i64 16}
!20 = !{!"MemtableIterator", !15, i64 0, !12, i64 32, !12, i64 40, !8, i64 48, !12, i64 56, !21, i64 64}
!21 = !{!"List", !12, i64 0, !12, i64 8}
!22 = !{!"MergeIterator", !15, i64 0, !12, i64 32, !19, i64 40, !8, i64 64, !12, i64 72}
!23 = !{!7, !12, i64 512}
!24 = !{!25, !12, i64 0}
!25 = !{!"Runtime", !26, i64 0, !27, i64 8, !12, i64 312}
!26 = !{!"ExceptionMgr", !12, i64 0}
!27 = !{!"Error", !9, i64 0, !8, i64 256, !12, i64 264, !12, i64 272, !8, i64 280, !12, i64 288, !12, i64 296}
!28 = !{!29, !12, i64 0}
!29 = !{!"Exception", !12, i64 0, !30, i64 8, !12, i64 16, !9, i64 24}
!30 = !{!"_Bool", !9, i64 0}
!31 = !{!29, !30, i64 8}
!32 = !{!29, !12, i64 16}
!33 = !{!34, !12, i64 0}
!34 = !{!"Guard", !12, i64 0, !12, i64 8, !12, i64 16}
!35 = !{!34, !12, i64 8}
!36 = !{!34, !12, i64 16}
!37 = !{i8 0, i8 2}
!38 = !{}


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