; LLVM IR from ibr-ds/STANlite :: Enclave/sqlite (btree)

; 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.CellInfo = type { i64, ptr, i32, i16, i16 }
%struct.BtCursor = type { ptr, ptr, ptr, ptr, %struct.CellInfo, i64, ptr, i32, i32, i32, i8, i8, i8, i8, i8, i8, ptr, ptr, [20 x i16], [20 x ptr] }
%struct.Btree = type { ptr, ptr, i8, i8, i8, i8, i32, i32, i32, ptr, ptr, %struct.BtLock }
%struct.BtLock = type { ptr, i32, i8, ptr }
%struct.MemPage = type { i8, i8, i8, i8, i32, i8, i8, i8, i8, i8, i16, i16, i16, i16, i16, i16, [4 x i16], [4 x ptr], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.BtShared = type { ptr, ptr, ptr, ptr, i8, i8, i8, i8, i8, i8, i16, i16, i16, i16, i16, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr }

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

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

declare i32 @sqlite3PagerWrite(ptr noundef) #1

declare i32 @sqlite3CorruptError(i32 noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @moveToRoot(ptr noundef) #2

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @balance(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3BtreeDelete(ptr noundef %0, i8 noundef zeroext %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.CellInfo, align 8
  %14 = alloca i32, align 4
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.BtCursor, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !10
  store ptr %24, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Btree, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  store ptr %27, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  %28 = load i8, ptr %5, align 1, !tbaa !9
  %29 = zext i8 %28 to i32
  %30 = and i32 %29, 2
  %31 = trunc i32 %30 to i8
  store i8 %31, ptr %15, align 1, !tbaa !9
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.BtCursor, ptr %32, i32 0, i32 14
  %34 = load i8, ptr %33, align 8, !tbaa !20
  %35 = sext i8 %34 to i32
  store i32 %35, ptr %12, align 4, !tbaa !19
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.BtCursor, ptr %36, i32 0, i32 18
  %38 = load i32, ptr %12, align 4, !tbaa !19
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [20 x i16], ptr %37, i64 0, i64 %39
  %41 = load i16, ptr %40, align 2, !tbaa !21
  %42 = zext i16 %41 to i32
  store i32 %42, ptr %11, align 4, !tbaa !19
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.BtCursor, ptr %43, i32 0, i32 19
  %45 = load i32, ptr %12, align 4, !tbaa !19
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [20 x ptr], ptr %44, i64 0, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  store ptr %48, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.MemPage, ptr %49, i32 0, i32 19
  %51 = load ptr, ptr %50, align 8, !tbaa !22
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.MemPage, ptr %52, i32 0, i32 15
  %54 = load i16, ptr %53, align 8, !tbaa !24
  %55 = zext i16 %54 to i32
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.MemPage, ptr %56, i32 0, i32 21
  %58 = load ptr, ptr %57, align 8, !tbaa !25
  %59 = load i32, ptr %11, align 4, !tbaa !19
  %60 = mul nsw i32 2, %59
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds i8, ptr %58, i64 %61
  %63 = getelementptr inbounds i8, ptr %62, i64 0
  %64 = load i8, ptr %63, align 1, !tbaa !9
  %65 = zext i8 %64 to i32
  %66 = shl i32 %65, 8
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.MemPage, ptr %67, i32 0, i32 21
  %69 = load ptr, ptr %68, align 8, !tbaa !25
  %70 = load i32, ptr %11, align 4, !tbaa !19
  %71 = mul nsw i32 2, %70
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds i8, ptr %69, i64 %72
  %74 = getelementptr inbounds i8, ptr %73, i64 1
  %75 = load i8, ptr %74, align 1, !tbaa !9
  %76 = zext i8 %75 to i32
  %77 = or i32 %66, %76
  %78 = and i32 %55, %77
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds i8, ptr %51, i64 %79
  store ptr %80, ptr %10, align 8, !tbaa !5
  %81 = load i8, ptr %15, align 1, !tbaa !9
  %82 = icmp ne i8 %81, 0
  br i1 %82, label %83, label %115

83:                                               ; preds = %2
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.MemPage, ptr %84, i32 0, i32 5
  %86 = load i8, ptr %85, align 8, !tbaa !26
  %87 = icmp ne i8 %86, 0
  br i1 %87, label %88, label %105

88:                                               ; preds = %83
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.MemPage, ptr %89, i32 0, i32 13
  %91 = load i16, ptr %90, align 4, !tbaa !27
  %92 = zext i16 %91 to i32
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = call zeroext i16 @cellSizePtr(ptr noundef %93, ptr noundef %94)
  %96 = zext i16 %95 to i32
  %97 = add nsw i32 %92, %96
  %98 = add nsw i32 %97, 2
  %99 = load ptr, ptr %7, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.BtShared, ptr %99, i32 0, i32 16
  %101 = load i32, ptr %100, align 4, !tbaa !28
  %102 = mul i32 %101, 2
  %103 = udiv i32 %102, 3
  %104 = icmp sgt i32 %98, %103
  br i1 %104, label %105, label %113

105:                                              ; preds = %88, %83
  %106 = load ptr, ptr %4, align 8, !tbaa !5
  %107 = call i32 @saveCursorKey(ptr noundef %106)
  store i32 %107, ptr %8, align 4, !tbaa !19
  %108 = load i32, ptr %8, align 4, !tbaa !19
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %110, label %112

110:                                              ; preds = %105
  %111 = load i32, ptr %8, align 4, !tbaa !19
  store i32 %111, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %374

112:                                              ; preds = %105
  br label %114

113:                                              ; preds = %88
  store i32 1, ptr %14, align 4, !tbaa !19
  br label %114

114:                                              ; preds = %113, %112
  br label %115

115:                                              ; preds = %114, %2
  %116 = load ptr, ptr %9, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.MemPage, ptr %116, i32 0, i32 5
  %118 = load i8, ptr %117, align 8, !tbaa !26
  %119 = icmp ne i8 %118, 0
  br i1 %119, label %131, label %120

120:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 0, ptr %17, align 4, !tbaa !19
  %121 = load ptr, ptr %4, align 8, !tbaa !5
  %122 = call i32 @sqlite3BtreePrevious(ptr noundef %121, ptr noundef %17)
  store i32 %122, ptr %8, align 4, !tbaa !19
  %123 = load i32, ptr %8, align 4, !tbaa !19
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %125, label %127

125:                                              ; preds = %120
  %126 = load i32, ptr %8, align 4, !tbaa !19
  store i32 %126, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %128

127:                                              ; preds = %120
  store i32 0, ptr %16, align 4
  br label %128

128:                                              ; preds = %127, %125
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  %129 = load i32, ptr %16, align 4
  switch i32 %129, label %374 [
    i32 0, label %130
  ]

130:                                              ; preds = %128
  br label %131

131:                                              ; preds = %130, %115
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct.BtCursor, ptr %132, i32 0, i32 10
  %134 = load i8, ptr %133, align 4, !tbaa !30
  %135 = zext i8 %134 to i32
  %136 = and i32 %135, 32
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %150

138:                                              ; preds = %131
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = load ptr, ptr %4, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.BtCursor, ptr %140, i32 0, i32 7
  %142 = load i32, ptr %141, align 8, !tbaa !31
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = call i32 @saveAllCursors(ptr noundef %139, i32 noundef %142, ptr noundef %143)
  store i32 %144, ptr %8, align 4, !tbaa !19
  %145 = load i32, ptr %8, align 4, !tbaa !19
  %146 = icmp ne i32 %145, 0
  br i1 %146, label %147, label %149

147:                                              ; preds = %138
  %148 = load i32, ptr %8, align 4, !tbaa !19
  store i32 %148, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %374

149:                                              ; preds = %138
  br label %150

150:                                              ; preds = %149, %131
  %151 = load ptr, ptr %4, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.BtCursor, ptr %151, i32 0, i32 16
  %153 = load ptr, ptr %152, align 8, !tbaa !32
  %154 = icmp eq ptr %153, null
  br i1 %154, label %155, label %161

155:                                              ; preds = %150
  %156 = load ptr, ptr %6, align 8, !tbaa !5
  %157 = load ptr, ptr %4, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.BtCursor, ptr %157, i32 0, i32 4
  %159 = getelementptr inbounds %struct.CellInfo, ptr %158, i32 0, i32 0
  %160 = load i64, ptr %159, align 8, !tbaa !33
  call void @invalidateIncrblobCursors(ptr noundef %156, i64 noundef %160, i32 noundef 0)
  br label %161

161:                                              ; preds = %155, %150
  %162 = load ptr, ptr %9, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.MemPage, ptr %162, i32 0, i32 23
  %164 = load ptr, ptr %163, align 8, !tbaa !34
  %165 = call i32 @sqlite3PagerWrite(ptr noundef %164)
  store i32 %165, ptr %8, align 4, !tbaa !19
  %166 = load i32, ptr %8, align 4, !tbaa !19
  %167 = icmp ne i32 %166, 0
  br i1 %167, label %168, label %170

168:                                              ; preds = %161
  %169 = load i32, ptr %8, align 4, !tbaa !19
  store i32 %169, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %374

170:                                              ; preds = %161
  %171 = load ptr, ptr %9, align 8, !tbaa !5
  %172 = load ptr, ptr %10, align 8, !tbaa !5
  %173 = call i32 @clearCell(ptr noundef %171, ptr noundef %172, ptr noundef %13)
  store i32 %173, ptr %8, align 4, !tbaa !19
  %174 = load ptr, ptr %9, align 8, !tbaa !5
  %175 = load i32, ptr %11, align 4, !tbaa !19
  %176 = getelementptr inbounds %struct.CellInfo, ptr %13, i32 0, i32 4
  %177 = load i16, ptr %176, align 2, !tbaa !35
  %178 = zext i16 %177 to i32
  call void @dropCell(ptr noundef %174, i32 noundef %175, i32 noundef %178, ptr noundef %8)
  %179 = load i32, ptr %8, align 4, !tbaa !19
  %180 = icmp ne i32 %179, 0
  br i1 %180, label %181, label %183

181:                                              ; preds = %170
  %182 = load i32, ptr %8, align 4, !tbaa !19
  store i32 %182, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %374

183:                                              ; preds = %170
  %184 = load ptr, ptr %9, align 8, !tbaa !5
  %185 = getelementptr inbounds %struct.MemPage, ptr %184, i32 0, i32 5
  %186 = load i8, ptr %185, align 8, !tbaa !26
  %187 = icmp ne i8 %186, 0
  br i1 %187, label %296, label %188

188:                                              ; preds = %183
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %189 = load ptr, ptr %4, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.BtCursor, ptr %189, i32 0, i32 19
  %191 = load ptr, ptr %4, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.BtCursor, ptr %191, i32 0, i32 14
  %193 = load i8, ptr %192, align 8, !tbaa !20
  %194 = sext i8 %193 to i64
  %195 = getelementptr inbounds [20 x ptr], ptr %190, i64 0, i64 %194
  %196 = load ptr, ptr %195, align 8, !tbaa !5
  store ptr %196, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %197 = load ptr, ptr %4, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.BtCursor, ptr %197, i32 0, i32 19
  %199 = load i32, ptr %12, align 4, !tbaa !19
  %200 = add nsw i32 %199, 1
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [20 x ptr], ptr %198, i64 0, i64 %201
  %203 = load ptr, ptr %202, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.MemPage, ptr %203, i32 0, i32 4
  %205 = load i32, ptr %204, align 4, !tbaa !36
  store i32 %205, ptr %20, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  %206 = load ptr, ptr %18, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.MemPage, ptr %206, i32 0, i32 19
  %208 = load ptr, ptr %207, align 8, !tbaa !22
  %209 = load ptr, ptr %18, align 8, !tbaa !5
  %210 = getelementptr inbounds %struct.MemPage, ptr %209, i32 0, i32 15
  %211 = load i16, ptr %210, align 8, !tbaa !24
  %212 = zext i16 %211 to i32
  %213 = load ptr, ptr %18, align 8, !tbaa !5
  %214 = getelementptr inbounds %struct.MemPage, ptr %213, i32 0, i32 21
  %215 = load ptr, ptr %214, align 8, !tbaa !25
  %216 = load ptr, ptr %18, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct.MemPage, ptr %216, i32 0, i32 14
  %218 = load i16, ptr %217, align 2, !tbaa !37
  %219 = zext i16 %218 to i32
  %220 = sub nsw i32 %219, 1
  %221 = mul nsw i32 2, %220
  %222 = sext i32 %221 to i64
  %223 = getelementptr inbounds i8, ptr %215, i64 %222
  %224 = getelementptr inbounds i8, ptr %223, i64 0
  %225 = load i8, ptr %224, align 1, !tbaa !9
  %226 = zext i8 %225 to i32
  %227 = shl i32 %226, 8
  %228 = load ptr, ptr %18, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.MemPage, ptr %228, i32 0, i32 21
  %230 = load ptr, ptr %229, align 8, !tbaa !25
  %231 = load ptr, ptr %18, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.MemPage, ptr %231, i32 0, i32 14
  %233 = load i16, ptr %232, align 2, !tbaa !37
  %234 = zext i16 %233 to i32
  %235 = sub nsw i32 %234, 1
  %236 = mul nsw i32 2, %235
  %237 = sext i32 %236 to i64
  %238 = getelementptr inbounds i8, ptr %230, i64 %237
  %239 = getelementptr inbounds i8, ptr %238, i64 1
  %240 = load i8, ptr %239, align 1, !tbaa !9
  %241 = zext i8 %240 to i32
  %242 = or i32 %227, %241
  %243 = and i32 %212, %242
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds i8, ptr %208, i64 %244
  store ptr %245, ptr %10, align 8, !tbaa !5
  %246 = load ptr, ptr %10, align 8, !tbaa !5
  %247 = load ptr, ptr %18, align 8, !tbaa !5
  %248 = getelementptr inbounds %struct.MemPage, ptr %247, i32 0, i32 19
  %249 = load ptr, ptr %248, align 8, !tbaa !22
  %250 = getelementptr inbounds i8, ptr %249, i64 4
  %251 = icmp ult ptr %246, %250
  br i1 %251, label %252, label %254

252:                                              ; preds = %188
  %253 = call i32 @sqlite3CorruptError(i32 noundef 8370)
  store i32 %253, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %293

254:                                              ; preds = %188
  %255 = load ptr, ptr %18, align 8, !tbaa !5
  %256 = getelementptr inbounds %struct.MemPage, ptr %255, i32 0, i32 24
  %257 = load ptr, ptr %256, align 8, !tbaa !38
  %258 = load ptr, ptr %18, align 8, !tbaa !5
  %259 = load ptr, ptr %10, align 8, !tbaa !5
  %260 = call zeroext i16 %257(ptr noundef %258, ptr noundef %259)
  %261 = zext i16 %260 to i32
  store i32 %261, ptr %19, align 4, !tbaa !19
  %262 = load ptr, ptr %7, align 8, !tbaa !5
  %263 = getelementptr inbounds %struct.BtShared, ptr %262, i32 0, i32 27
  %264 = load ptr, ptr %263, align 8, !tbaa !39
  store ptr %264, ptr %21, align 8, !tbaa !5
  %265 = load ptr, ptr %18, align 8, !tbaa !5
  %266 = getelementptr inbounds %struct.MemPage, ptr %265, i32 0, i32 23
  %267 = load ptr, ptr %266, align 8, !tbaa !34
  %268 = call i32 @sqlite3PagerWrite(ptr noundef %267)
  store i32 %268, ptr %8, align 4, !tbaa !19
  %269 = load i32, ptr %8, align 4, !tbaa !19
  %270 = icmp eq i32 %269, 0
  br i1 %270, label %271, label %280

271:                                              ; preds = %254
  %272 = load ptr, ptr %9, align 8, !tbaa !5
  %273 = load i32, ptr %11, align 4, !tbaa !19
  %274 = load ptr, ptr %10, align 8, !tbaa !5
  %275 = getelementptr inbounds i8, ptr %274, i64 -4
  %276 = load i32, ptr %19, align 4, !tbaa !19
  %277 = add nsw i32 %276, 4
  %278 = load ptr, ptr %21, align 8, !tbaa !5
  %279 = load i32, ptr %20, align 4, !tbaa !19
  call void @insertCell(ptr noundef %272, i32 noundef %273, ptr noundef %275, i32 noundef %277, ptr noundef %278, i32 noundef %279, ptr noundef %8)
  br label %280

280:                                              ; preds = %271, %254
  %281 = load ptr, ptr %18, align 8, !tbaa !5
  %282 = load ptr, ptr %18, align 8, !tbaa !5
  %283 = getelementptr inbounds %struct.MemPage, ptr %282, i32 0, i32 14
  %284 = load i16, ptr %283, align 2, !tbaa !37
  %285 = zext i16 %284 to i32
  %286 = sub nsw i32 %285, 1
  %287 = load i32, ptr %19, align 4, !tbaa !19
  call void @dropCell(ptr noundef %281, i32 noundef %286, i32 noundef %287, ptr noundef %8)
  %288 = load i32, ptr %8, align 4, !tbaa !19
  %289 = icmp ne i32 %288, 0
  br i1 %289, label %290, label %292

290:                                              ; preds = %280
  %291 = load i32, ptr %8, align 4, !tbaa !19
  store i32 %291, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %293

292:                                              ; preds = %280
  store i32 0, ptr %16, align 4
  br label %293

293:                                              ; preds = %292, %290, %252
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  %294 = load i32, ptr %16, align 4
  switch i32 %294, label %374 [
    i32 0, label %295
  ]

295:                                              ; preds = %293
  br label %296

296:                                              ; preds = %295, %183
  %297 = load ptr, ptr %4, align 8, !tbaa !5
  %298 = call i32 @balance(ptr noundef %297)
  store i32 %298, ptr %8, align 4, !tbaa !19
  %299 = load i32, ptr %8, align 4, !tbaa !19
  %300 = icmp eq i32 %299, 0
  br i1 %300, label %301, label %329

301:                                              ; preds = %296
  %302 = load ptr, ptr %4, align 8, !tbaa !5
  %303 = getelementptr inbounds %struct.BtCursor, ptr %302, i32 0, i32 14
  %304 = load i8, ptr %303, align 8, !tbaa !20
  %305 = sext i8 %304 to i32
  %306 = load i32, ptr %12, align 4, !tbaa !19
  %307 = icmp sgt i32 %305, %306
  br i1 %307, label %308, label %329

308:                                              ; preds = %301
  br label %309

309:                                              ; preds = %316, %308
  %310 = load ptr, ptr %4, align 8, !tbaa !5
  %311 = getelementptr inbounds %struct.BtCursor, ptr %310, i32 0, i32 14
  %312 = load i8, ptr %311, align 8, !tbaa !20
  %313 = sext i8 %312 to i32
  %314 = load i32, ptr %12, align 4, !tbaa !19
  %315 = icmp sgt i32 %313, %314
  br i1 %315, label %316, label %326

316:                                              ; preds = %309
  %317 = load ptr, ptr %4, align 8, !tbaa !5
  %318 = getelementptr inbounds %struct.BtCursor, ptr %317, i32 0, i32 19
  %319 = load ptr, ptr %4, align 8, !tbaa !5
  %320 = getelementptr inbounds %struct.BtCursor, ptr %319, i32 0, i32 14
  %321 = load i8, ptr %320, align 8, !tbaa !20
  %322 = add i8 %321, -1
  store i8 %322, ptr %320, align 8, !tbaa !20
  %323 = sext i8 %321 to i64
  %324 = getelementptr inbounds [20 x ptr], ptr %318, i64 0, i64 %323
  %325 = load ptr, ptr %324, align 8, !tbaa !5
  call void @releasePage(ptr noundef %325)
  br label %309, !llvm.loop !40

326:                                              ; preds = %309
  %327 = load ptr, ptr %4, align 8, !tbaa !5
  %328 = call i32 @balance(ptr noundef %327)
  store i32 %328, ptr %8, align 4, !tbaa !19
  br label %329

329:                                              ; preds = %326, %301, %296
  %330 = load i32, ptr %8, align 4, !tbaa !19
  %331 = icmp eq i32 %330, 0
  br i1 %331, label %332, label %372

332:                                              ; preds = %329
  %333 = load i32, ptr %14, align 4, !tbaa !19
  %334 = icmp ne i32 %333, 0
  br i1 %334, label %335, label %362

335:                                              ; preds = %332
  %336 = load ptr, ptr %4, align 8, !tbaa !5
  %337 = getelementptr inbounds %struct.BtCursor, ptr %336, i32 0, i32 12
  store i8 2, ptr %337, align 2, !tbaa !42
  %338 = load i32, ptr %11, align 4, !tbaa !19
  %339 = load ptr, ptr %9, align 8, !tbaa !5
  %340 = getelementptr inbounds %struct.MemPage, ptr %339, i32 0, i32 14
  %341 = load i16, ptr %340, align 2, !tbaa !37
  %342 = zext i16 %341 to i32
  %343 = icmp sge i32 %338, %342
  br i1 %343, label %344, label %358

344:                                              ; preds = %335
  %345 = load ptr, ptr %4, align 8, !tbaa !5
  %346 = getelementptr inbounds %struct.BtCursor, ptr %345, i32 0, i32 9
  store i32 -1, ptr %346, align 8, !tbaa !43
  %347 = load ptr, ptr %9, align 8, !tbaa !5
  %348 = getelementptr inbounds %struct.MemPage, ptr %347, i32 0, i32 14
  %349 = load i16, ptr %348, align 2, !tbaa !37
  %350 = zext i16 %349 to i32
  %351 = sub nsw i32 %350, 1
  %352 = trunc i32 %351 to i16
  %353 = load ptr, ptr %4, align 8, !tbaa !5
  %354 = getelementptr inbounds %struct.BtCursor, ptr %353, i32 0, i32 18
  %355 = load i32, ptr %12, align 4, !tbaa !19
  %356 = sext i32 %355 to i64
  %357 = getelementptr inbounds [20 x i16], ptr %354, i64 0, i64 %356
  store i16 %352, ptr %357, align 2, !tbaa !21
  br label %361

358:                                              ; preds = %335
  %359 = load ptr, ptr %4, align 8, !tbaa !5
  %360 = getelementptr inbounds %struct.BtCursor, ptr %359, i32 0, i32 9
  store i32 1, ptr %360, align 8, !tbaa !43
  br label %361

361:                                              ; preds = %358, %344
  br label %371

362:                                              ; preds = %332
  %363 = load ptr, ptr %4, align 8, !tbaa !5
  %364 = call i32 @moveToRoot(ptr noundef %363)
  store i32 %364, ptr %8, align 4, !tbaa !19
  %365 = load i8, ptr %15, align 1, !tbaa !9
  %366 = icmp ne i8 %365, 0
  br i1 %366, label %367, label %370

367:                                              ; preds = %362
  %368 = load ptr, ptr %4, align 8, !tbaa !5
  %369 = getelementptr inbounds %struct.BtCursor, ptr %368, i32 0, i32 12
  store i8 3, ptr %369, align 2, !tbaa !42
  br label %370

370:                                              ; preds = %367, %362
  br label %371

371:                                              ; preds = %370, %361
  br label %372

372:                                              ; preds = %371, %329
  %373 = load i32, ptr %8, align 4, !tbaa !19
  store i32 %373, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %374

374:                                              ; preds = %372, %293, %181, %168, %147, %128, %110
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %375 = load i32, ptr %3, align 4
  ret i32 %375
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i16 @cellSizePtr(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @saveCursorKey(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"BtCursor", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32, !13, i64 56, !6, i64 64, !14, i64 72, !14, i64 76, !14, i64 80, !7, i64 84, !7, i64 85, !7, i64 86, !7, i64 87, !7, i64 88, !7, i64 89, !6, i64 96, !6, i64 104, !7, i64 112, !7, i64 152}
!12 = !{!"CellInfo", !13, i64 0, !6, i64 8, !14, i64 16, !15, i64 20, !15, i64 22}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !6, i64 8}
!17 = !{!"Btree", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !14, i64 20, !14, i64 24, !14, i64 28, !6, i64 32, !6, i64 40, !18, i64 48}
!18 = !{!"BtLock", !6, i64 0, !14, i64 8, !7, i64 12, !6, i64 16}
!19 = !{!14, !14, i64 0}
!20 = !{!11, !7, i64 88}
!21 = !{!15, !15, i64 0}
!22 = !{!23, !6, i64 80}
!23 = !{!"MemPage", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !14, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !15, i64 14, !15, i64 16, !15, i64 18, !15, i64 20, !15, i64 22, !15, i64 24, !7, i64 26, !7, i64 40, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!24 = !{!23, !15, i64 24}
!25 = !{!23, !6, i64 96}
!26 = !{!23, !7, i64 8}
!27 = !{!23, !15, i64 20}
!28 = !{!29, !14, i64 52}
!29 = !{!"BtShared", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !7, i64 36, !7, i64 37, !15, i64 38, !15, i64 40, !15, i64 42, !15, i64 44, !15, i64 46, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !14, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!30 = !{!11, !7, i64 84}
!31 = !{!11, !14, i64 72}
!32 = !{!11, !6, i64 96}
!33 = !{!11, !13, i64 32}
!34 = !{!23, !6, i64 112}
!35 = !{!12, !15, i64 22}
!36 = !{!23, !14, i64 4}
!37 = !{!23, !15, i64 22}
!38 = !{!23, !6, i64 120}
!39 = !{!29, !6, i64 128}
!40 = distinct !{!40, !41}
!41 = !{!"llvm.loop.mustprogress"}
!42 = !{!11, !7, i64 86}
!43 = !{!11, !14, i64 80}


; 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.CellInfo = type { i64, ptr, i32, i16, i16 }

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @sqlite3PagerWrite(ptr noundef) local_unnamed_addr #1

declare i32 @sqlite3CorruptError(i32 noundef) local_unnamed_addr #1

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

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

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

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3BtreeDelete(ptr noundef %0, i8 noundef zeroext %1) local_unnamed_addr #2 {
  %3 = alloca i32, align 4
  %4 = alloca %struct.CellInfo, align 8
  %5 = alloca i32, align 4
  %6 = load ptr, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #3
  %9 = and i8 %1, 2
  %10 = getelementptr inbounds i8, ptr %0, i64 88
  %11 = load i8, ptr %10, align 8, !tbaa !17
  %12 = sext i8 %11 to i64
  %13 = getelementptr inbounds i8, ptr %0, i64 112
  %14 = getelementptr inbounds [20 x i16], ptr %13, i64 0, i64 %12
  %15 = load i16, ptr %14, align 2, !tbaa !18
  %16 = zext i16 %15 to i32
  %17 = getelementptr inbounds i8, ptr %0, i64 152
  %18 = getelementptr inbounds [20 x ptr], ptr %17, i64 0, i64 %12
  %19 = load ptr, ptr %18, align 8, !tbaa !19
  %20 = getelementptr inbounds i8, ptr %19, i64 80
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  %22 = getelementptr inbounds i8, ptr %19, i64 24
  %23 = load i16, ptr %22, align 8, !tbaa !22
  %24 = zext i16 %23 to i64
  %25 = getelementptr inbounds i8, ptr %19, i64 96
  %26 = load ptr, ptr %25, align 8, !tbaa !23
  %27 = shl nuw nsw i32 %16, 1
  %28 = zext nneg i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %26, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !24
  %31 = zext i8 %30 to i64
  %32 = shl nuw nsw i64 %31, 8
  %33 = getelementptr inbounds i8, ptr %29, i64 1
  %34 = load i8, ptr %33, align 1, !tbaa !24
  %35 = zext i8 %34 to i64
  %36 = or disjoint i64 %32, %35
  %37 = and i64 %36, %24
  %38 = getelementptr inbounds i8, ptr %21, i64 %37
  %.not = icmp eq i8 %9, 0
  br i1 %.not, label %57, label %39

39:                                               ; preds = %2
  %40 = getelementptr inbounds i8, ptr %19, i64 8
  %41 = load i8, ptr %40, align 8, !tbaa !25
  %.not93 = icmp eq i8 %41, 0
  br i1 %.not93, label %55, label %42

42:                                               ; preds = %39
  %43 = getelementptr inbounds i8, ptr %19, i64 20
  %44 = load i16, ptr %43, align 4, !tbaa !26
  %45 = zext i16 %44 to i32
  %46 = tail call zeroext i16 @cellSizePtr(ptr noundef nonnull %19, ptr noundef %38)
  %47 = zext i16 %46 to i32
  %48 = add nuw nsw i32 %45, 2
  %49 = add nuw nsw i32 %48, %47
  %50 = getelementptr inbounds i8, ptr %8, i64 52
  %51 = load i32, ptr %50, align 4, !tbaa !27
  %52 = shl i32 %51, 1
  %53 = udiv i32 %52, 3
  %54 = icmp ugt i32 %49, %53
  br i1 %54, label %55, label %57

55:                                               ; preds = %42, %39
  %56 = tail call i32 @saveCursorKey(ptr noundef nonnull %0)
  store i32 %56, ptr %3, align 4, !tbaa !29
  %.not94 = icmp eq i32 %56, 0
  br i1 %.not94, label %57, label %.thread108

57:                                               ; preds = %42, %55, %2
  %.not103 = phi i1 [ true, %55 ], [ true, %2 ], [ false, %42 ]
  %58 = getelementptr inbounds i8, ptr %19, i64 8
  %59 = load i8, ptr %58, align 8, !tbaa !25
  %.not95 = icmp eq i8 %59, 0
  br i1 %.not95, label %60, label %62

60:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  store i32 0, ptr %5, align 4, !tbaa !29
  %61 = call i32 @sqlite3BtreePrevious(ptr noundef nonnull %0, ptr noundef nonnull %5)
  %.not96 = icmp eq i32 %61, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  br i1 %.not96, label %62, label %.thread108

62:                                               ; preds = %60, %57
  %63 = getelementptr inbounds i8, ptr %0, i64 84
  %64 = load i8, ptr %63, align 4, !tbaa !30
  %65 = and i8 %64, 32
  %.not97 = icmp eq i8 %65, 0
  br i1 %.not97, label %70, label %66

66:                                               ; preds = %62
  %67 = getelementptr inbounds i8, ptr %0, i64 72
  %68 = load i32, ptr %67, align 8, !tbaa !31
  %69 = call i32 @saveAllCursors(ptr noundef %8, i32 noundef %68, ptr noundef nonnull %0)
  %.not98 = icmp eq i32 %69, 0
  br i1 %.not98, label %70, label %.thread108

70:                                               ; preds = %66, %62
  %71 = getelementptr inbounds i8, ptr %0, i64 96
  %72 = load ptr, ptr %71, align 8, !tbaa !32
  %73 = icmp eq ptr %72, null
  br i1 %73, label %74, label %77

74:                                               ; preds = %70
  %75 = getelementptr inbounds i8, ptr %0, i64 32
  %76 = load i64, ptr %75, align 8, !tbaa !33
  call void @invalidateIncrblobCursors(ptr noundef nonnull %6, i64 noundef %76, i32 noundef 0)
  br label %77

77:                                               ; preds = %74, %70
  %78 = getelementptr inbounds i8, ptr %19, i64 112
  %79 = load ptr, ptr %78, align 8, !tbaa !34
  %80 = call i32 @sqlite3PagerWrite(ptr noundef %79) #3
  %.not99 = icmp eq i32 %80, 0
  br i1 %.not99, label %81, label %.thread108

81:                                               ; preds = %77
  %82 = call i32 @clearCell(ptr noundef nonnull %19, ptr noundef %38, ptr noundef nonnull %4)
  store i32 %82, ptr %3, align 4, !tbaa !29
  %83 = getelementptr inbounds i8, ptr %4, i64 22
  %84 = load i16, ptr %83, align 2, !tbaa !35
  %85 = zext i16 %84 to i32
  call void @dropCell(ptr noundef nonnull %19, i32 noundef %16, i32 noundef %85, ptr noundef nonnull %3)
  %86 = load i32, ptr %3, align 4, !tbaa !29
  %.not100 = icmp eq i32 %86, 0
  br i1 %.not100, label %87, label %.thread108

87:                                               ; preds = %81
  %88 = load i8, ptr %58, align 8, !tbaa !25
  %.not101 = icmp eq i8 %88, 0
  br i1 %.not101, label %89, label %142

89:                                               ; preds = %87
  %90 = load i8, ptr %10, align 8, !tbaa !17
  %91 = sext i8 %90 to i64
  %92 = getelementptr inbounds [20 x ptr], ptr %17, i64 0, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !19
  %94 = add nsw i64 %12, 1
  %95 = getelementptr inbounds [20 x ptr], ptr %17, i64 0, i64 %94
  %96 = load ptr, ptr %95, align 8, !tbaa !19
  %97 = getelementptr inbounds i8, ptr %96, i64 4
  %98 = load i32, ptr %97, align 4, !tbaa !36
  %99 = getelementptr inbounds i8, ptr %93, i64 80
  %100 = load ptr, ptr %99, align 8, !tbaa !20
  %101 = getelementptr inbounds i8, ptr %93, i64 24
  %102 = load i16, ptr %101, align 8, !tbaa !22
  %103 = zext i16 %102 to i64
  %104 = getelementptr inbounds i8, ptr %93, i64 96
  %105 = load ptr, ptr %104, align 8, !tbaa !23
  %106 = getelementptr inbounds i8, ptr %93, i64 22
  %107 = load i16, ptr %106, align 2, !tbaa !37
  %108 = zext i16 %107 to i64
  %109 = shl nuw nsw i64 %108, 1
  %110 = getelementptr i8, ptr %105, i64 %109
  %111 = getelementptr i8, ptr %110, i64 -2
  %112 = load i8, ptr %111, align 1, !tbaa !24
  %113 = zext i8 %112 to i64
  %114 = shl nuw nsw i64 %113, 8
  %115 = getelementptr i8, ptr %110, i64 -1
  %116 = load i8, ptr %115, align 1, !tbaa !24
  %117 = zext i8 %116 to i64
  %118 = or disjoint i64 %114, %117
  %119 = and i64 %118, %103
  %120 = getelementptr inbounds i8, ptr %100, i64 %119
  %121 = icmp ult i64 %119, 4
  br i1 %121, label %.thread, label %123

.thread:                                          ; preds = %89
  %122 = call i32 @sqlite3CorruptError(i32 noundef 8370) #3
  br label %.thread108

123:                                              ; preds = %89
  %124 = getelementptr inbounds i8, ptr %93, i64 120
  %125 = load ptr, ptr %124, align 8, !tbaa !38
  %126 = call zeroext i16 %125(ptr noundef nonnull %93, ptr noundef nonnull %120) #3
  %127 = zext i16 %126 to i32
  %128 = getelementptr inbounds i8, ptr %8, i64 128
  %129 = load ptr, ptr %128, align 8, !tbaa !39
  %130 = getelementptr inbounds i8, ptr %93, i64 112
  %131 = load ptr, ptr %130, align 8, !tbaa !34
  %132 = call i32 @sqlite3PagerWrite(ptr noundef %131) #3
  store i32 %132, ptr %3, align 4, !tbaa !29
  %133 = icmp eq i32 %132, 0
  br i1 %133, label %134, label %137

134:                                              ; preds = %123
  %135 = getelementptr inbounds i8, ptr %120, i64 -4
  %136 = add nuw nsw i32 %127, 4
  call void @insertCell(ptr noundef nonnull %19, i32 noundef %16, ptr noundef nonnull %135, i32 noundef %136, ptr noundef %129, i32 noundef %98, ptr noundef nonnull %3)
  br label %137

137:                                              ; preds = %123, %134
  %138 = load i16, ptr %106, align 2, !tbaa !37
  %139 = zext i16 %138 to i32
  %140 = add nsw i32 %139, -1
  call void @dropCell(ptr noundef nonnull %93, i32 noundef %140, i32 noundef %127, ptr noundef nonnull %3)
  %141 = load i32, ptr %3, align 4, !tbaa !29
  %.not102 = icmp eq i32 %141, 0
  br i1 %.not102, label %142, label %.thread108

142:                                              ; preds = %137, %87
  %143 = call i32 @balance(ptr noundef nonnull %0)
  store i32 %143, ptr %3, align 4, !tbaa !29
  %144 = icmp eq i32 %143, 0
  br i1 %144, label %145, label %.thread108

145:                                              ; preds = %142
  %146 = load i8, ptr %10, align 8, !tbaa !17
  %147 = icmp sgt i8 %146, %11
  br i1 %147, label %.lr.ph, label %.thread107

.lr.ph:                                           ; preds = %145, %.lr.ph
  %148 = phi i8 [ %153, %.lr.ph ], [ %146, %145 ]
  %149 = add nsw i8 %148, -1
  store i8 %149, ptr %10, align 8, !tbaa !17
  %150 = sext i8 %148 to i64
  %151 = getelementptr inbounds [20 x ptr], ptr %17, i64 0, i64 %150
  %152 = load ptr, ptr %151, align 8, !tbaa !19
  call void @releasePage(ptr noundef %152)
  %153 = load i8, ptr %10, align 8, !tbaa !17
  %154 = icmp sgt i8 %153, %11
  br i1 %154, label %.lr.ph, label %._crit_edge, !llvm.loop !40

._crit_edge:                                      ; preds = %.lr.ph
  %155 = call i32 @balance(ptr noundef nonnull %0)
  store i32 %155, ptr %3, align 4, !tbaa !29
  %156 = icmp eq i32 %155, 0
  br i1 %156, label %.thread107, label %.thread108

.thread107:                                       ; preds = %145, %._crit_edge
  br i1 %.not103, label %165, label %157

157:                                              ; preds = %.thread107
  %158 = getelementptr inbounds i8, ptr %0, i64 86
  store i8 2, ptr %158, align 2, !tbaa !42
  %159 = getelementptr inbounds i8, ptr %19, i64 22
  %160 = load i16, ptr %159, align 2, !tbaa !37
  %.not104 = icmp ult i16 %15, %160
  %161 = getelementptr inbounds i8, ptr %0, i64 80
  br i1 %.not104, label %164, label %162

162:                                              ; preds = %157
  store i32 -1, ptr %161, align 8, !tbaa !43
  %163 = add i16 %160, -1
  store i16 %163, ptr %14, align 2, !tbaa !18
  br label %.thread108

164:                                              ; preds = %157
  store i32 1, ptr %161, align 8, !tbaa !43
  br label %.thread108

165:                                              ; preds = %.thread107
  %166 = call i32 @moveToRoot(ptr noundef nonnull %0)
  br i1 %.not, label %.thread108, label %167

167:                                              ; preds = %165
  %168 = getelementptr inbounds i8, ptr %0, i64 86
  store i8 3, ptr %168, align 2, !tbaa !42
  br label %.thread108

.thread108:                                       ; preds = %._crit_edge, %165, %167, %162, %164, %142, %.thread, %81, %77, %66, %55, %137, %60
  %.3 = phi i32 [ %141, %137 ], [ %61, %60 ], [ %56, %55 ], [ %69, %66 ], [ %80, %77 ], [ %86, %81 ], [ %122, %.thread ], [ %143, %142 ], [ 0, %164 ], [ 0, %162 ], [ %166, %167 ], [ %166, %165 ], [ %155, %._crit_edge ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i32 %.3
}

; Function Attrs: nounwind uwtable
declare hidden zeroext i16 @cellSizePtr(ptr noundef, ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { 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 }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"BtCursor", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 56, !7, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !8, i64 84, !8, i64 85, !8, i64 86, !8, i64 87, !8, i64 88, !8, i64 89, !7, i64 96, !7, i64 104, !8, i64 112, !8, i64 152}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"CellInfo", !11, i64 0, !7, i64 8, !12, i64 16, !13, i64 20, !13, i64 22}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!15, !7, i64 8}
!15 = !{!"Btree", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 17, !8, i64 18, !8, i64 19, !12, i64 20, !12, i64 24, !12, i64 28, !7, i64 32, !7, i64 40, !16, i64 48}
!16 = !{!"BtLock", !7, i64 0, !12, i64 8, !8, i64 12, !7, i64 16}
!17 = !{!6, !8, i64 88}
!18 = !{!13, !13, i64 0}
!19 = !{!7, !7, i64 0}
!20 = !{!21, !7, i64 80}
!21 = !{!"MemPage", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !12, i64 4, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !8, i64 12, !13, i64 14, !13, i64 16, !13, i64 18, !13, i64 20, !13, i64 22, !13, i64 24, !8, i64 26, !8, i64 40, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128}
!22 = !{!21, !13, i64 24}
!23 = !{!21, !7, i64 96}
!24 = !{!8, !8, i64 0}
!25 = !{!21, !8, i64 8}
!26 = !{!21, !13, i64 20}
!27 = !{!28, !12, i64 52}
!28 = !{!"BtShared", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !8, i64 32, !8, i64 33, !8, i64 34, !8, i64 35, !8, i64 36, !8, i64 37, !13, i64 38, !13, i64 40, !13, i64 42, !13, i64 44, !13, i64 46, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !12, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128}
!29 = !{!12, !12, i64 0}
!30 = !{!6, !8, i64 84}
!31 = !{!6, !12, i64 72}
!32 = !{!6, !7, i64 96}
!33 = !{!6, !11, i64 32}
!34 = !{!21, !7, i64 112}
!35 = !{!10, !13, i64 22}
!36 = !{!21, !12, i64 4}
!37 = !{!21, !13, i64 22}
!38 = !{!21, !7, i64 120}
!39 = !{!28, !7, i64 128}
!40 = distinct !{!40, !41}
!41 = !{!"llvm.loop.mustprogress"}
!42 = !{!6, !8, i64 86}
!43 = !{!6, !12, i64 80}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass