; 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.UnpackedRecord = type { ptr, ptr, i16, i8, i8, i8, i8, i8 }
%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.BtreePayload = type { ptr, i64, ptr, ptr, i16, i32, i32 }
%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 }
%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 }

; 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 ptr @sqlite3Malloc(i64 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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) #3

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3BtreeMovetoUnpacked(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3BtreeInsert(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca %struct.UnpackedRecord, align 8
  %21 = alloca %struct.CellInfo, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %22 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %22, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.BtCursor, ptr %23, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  store ptr %25, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %26 = load ptr, ptr %15, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Btree, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  store ptr %28, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  store ptr null, ptr %18, align 8, !tbaa !5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.BtCursor, ptr %29, i32 0, i32 12
  %31 = load i8, ptr %30, align 2, !tbaa !19
  %32 = zext i8 %31 to i32
  %33 = icmp eq i32 %32, 4
  br i1 %33, label %34, label %38

34:                                               ; preds = %4
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.BtCursor, ptr %35, i32 0, i32 9
  %37 = load i32, ptr %36, align 8, !tbaa !20
  store i32 %37, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %394

38:                                               ; preds = %4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.BtCursor, ptr %39, i32 0, i32 10
  %41 = load i8, ptr %40, align 4, !tbaa !21
  %42 = zext i8 %41 to i32
  %43 = and i32 %42, 32
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %57

45:                                               ; preds = %38
  %46 = load ptr, ptr %16, align 8, !tbaa !5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.BtCursor, ptr %47, i32 0, i32 7
  %49 = load i32, ptr %48, align 8, !tbaa !22
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = call i32 @saveAllCursors(ptr noundef %46, i32 noundef %49, ptr noundef %50)
  store i32 %51, ptr %10, align 4, !tbaa !9
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %45
  %55 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %55, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %394

56:                                               ; preds = %45
  br label %57

57:                                               ; preds = %56, %38
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.BtCursor, ptr %58, i32 0, i32 16
  %60 = load ptr, ptr %59, align 8, !tbaa !23
  %61 = icmp eq ptr %60, null
  br i1 %61, label %62, label %102

62:                                               ; preds = %57
  %63 = load ptr, ptr %15, align 8, !tbaa !5
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.BtreePayload, ptr %64, i32 0, i32 1
  %66 = load i64, ptr %65, align 8, !tbaa !24
  call void @invalidateIncrblobCursors(ptr noundef %63, i64 noundef %66, i32 noundef 0)
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.BtCursor, ptr %67, i32 0, i32 10
  %69 = load i8, ptr %68, align 4, !tbaa !21
  %70 = zext i8 %69 to i32
  %71 = and i32 %70, 2
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %83

73:                                               ; preds = %62
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.BtreePayload, ptr %74, i32 0, i32 1
  %76 = load i64, ptr %75, align 8, !tbaa !24
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.BtCursor, ptr %77, i32 0, i32 4
  %79 = getelementptr inbounds %struct.CellInfo, ptr %78, i32 0, i32 0
  %80 = load i64, ptr %79, align 8, !tbaa !26
  %81 = icmp eq i64 %76, %80
  br i1 %81, label %82, label %83

82:                                               ; preds = %73
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %101

83:                                               ; preds = %73, %62
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %100

86:                                               ; preds = %83
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.BtreePayload, ptr %88, i32 0, i32 1
  %90 = load i64, ptr %89, align 8, !tbaa !24
  %91 = load i32, ptr %8, align 4, !tbaa !9
  %92 = icmp ne i32 %91, 0
  %93 = zext i1 %92 to i32
  %94 = call i32 @sqlite3BtreeMovetoUnpacked(ptr noundef %87, ptr noundef null, i64 noundef %90, i32 noundef %93, ptr noundef %11)
  store i32 %94, ptr %10, align 4, !tbaa !9
  %95 = load i32, ptr %10, align 4, !tbaa !9
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %99

97:                                               ; preds = %86
  %98 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %98, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %394

99:                                               ; preds = %86
  br label %100

100:                                              ; preds = %99, %83
  br label %101

101:                                              ; preds = %100, %82
  br label %156

102:                                              ; preds = %57
  %103 = load i32, ptr %11, align 4, !tbaa !9
  %104 = icmp eq i32 %103, 0
  br i1 %104, label %105, label %155

105:                                              ; preds = %102
  %106 = load i32, ptr %8, align 4, !tbaa !9
  %107 = and i32 %106, 2
  %108 = icmp eq i32 %107, 0
  br i1 %108, label %109, label %155

109:                                              ; preds = %105
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.BtreePayload, ptr %110, i32 0, i32 4
  %112 = load i16, ptr %111, align 8, !tbaa !27
  %113 = icmp ne i16 %112, 0
  br i1 %113, label %114, label %137

114:                                              ; preds = %109
  call void @llvm.lifetime.start.p0(i64 24, ptr %20) #4
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.BtCursor, ptr %115, i32 0, i32 16
  %117 = load ptr, ptr %116, align 8, !tbaa !23
  %118 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 0
  store ptr %117, ptr %118, align 8, !tbaa !28
  %119 = load ptr, ptr %7, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.BtreePayload, ptr %119, i32 0, i32 3
  %121 = load ptr, ptr %120, align 8, !tbaa !30
  %122 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 1
  store ptr %121, ptr %122, align 8, !tbaa !31
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.BtreePayload, ptr %123, i32 0, i32 4
  %125 = load i16, ptr %124, align 8, !tbaa !27
  %126 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 2
  store i16 %125, ptr %126, align 8, !tbaa !32
  %127 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 3
  store i8 0, ptr %127, align 2, !tbaa !33
  %128 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 4
  store i8 0, ptr %128, align 1, !tbaa !34
  %129 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 5
  store i8 0, ptr %129, align 4, !tbaa !35
  %130 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 6
  store i8 0, ptr %130, align 1, !tbaa !36
  %131 = getelementptr inbounds %struct.UnpackedRecord, ptr %20, i32 0, i32 7
  store i8 0, ptr %131, align 2, !tbaa !37
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = load i32, ptr %8, align 4, !tbaa !9
  %134 = icmp ne i32 %133, 0
  %135 = zext i1 %134 to i32
  %136 = call i32 @sqlite3BtreeMovetoUnpacked(ptr noundef %132, ptr noundef %20, i64 noundef 0, i32 noundef %135, ptr noundef %11)
  store i32 %136, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %20) #4
  br label %149

137:                                              ; preds = %109
  %138 = load ptr, ptr %6, align 8, !tbaa !5
  %139 = load ptr, ptr %7, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.BtreePayload, ptr %139, i32 0, i32 0
  %141 = load ptr, ptr %140, align 8, !tbaa !38
  %142 = load ptr, ptr %7, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.BtreePayload, ptr %142, i32 0, i32 1
  %144 = load i64, ptr %143, align 8, !tbaa !24
  %145 = load i32, ptr %8, align 4, !tbaa !9
  %146 = icmp ne i32 %145, 0
  %147 = zext i1 %146 to i32
  %148 = call i32 @btreeMoveto(ptr noundef %138, ptr noundef %141, i64 noundef %144, i32 noundef %147, ptr noundef %11)
  store i32 %148, ptr %10, align 4, !tbaa !9
  br label %149

149:                                              ; preds = %137, %114
  %150 = load i32, ptr %10, align 4, !tbaa !9
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %154

152:                                              ; preds = %149
  %153 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %153, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %394

154:                                              ; preds = %149
  br label %155

155:                                              ; preds = %154, %105, %102
  br label %156

156:                                              ; preds = %155, %101
  %157 = load ptr, ptr %6, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.BtCursor, ptr %157, i32 0, i32 19
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  %160 = getelementptr inbounds %struct.BtCursor, ptr %159, i32 0, i32 14
  %161 = load i8, ptr %160, align 8, !tbaa !39
  %162 = sext i8 %161 to i64
  %163 = getelementptr inbounds [20 x ptr], ptr %158, i64 0, i64 %162
  %164 = load ptr, ptr %163, align 8, !tbaa !5
  store ptr %164, ptr %14, align 8, !tbaa !5
  %165 = load ptr, ptr %16, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.BtShared, ptr %165, i32 0, i32 27
  %167 = load ptr, ptr %166, align 8, !tbaa !40
  store ptr %167, ptr %18, align 8, !tbaa !5
  %168 = load ptr, ptr %14, align 8, !tbaa !5
  %169 = load ptr, ptr %18, align 8, !tbaa !5
  %170 = load ptr, ptr %7, align 8, !tbaa !5
  %171 = call i32 @fillInCell(ptr noundef %168, ptr noundef %169, ptr noundef %170, ptr noundef %12)
  store i32 %171, ptr %10, align 4, !tbaa !9
  %172 = load i32, ptr %10, align 4, !tbaa !9
  %173 = icmp ne i32 %172, 0
  br i1 %173, label %174, label %175

174:                                              ; preds = %156
  br label %392

175:                                              ; preds = %156
  %176 = load ptr, ptr %6, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.BtCursor, ptr %176, i32 0, i32 18
  %178 = load ptr, ptr %6, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.BtCursor, ptr %178, i32 0, i32 14
  %180 = load i8, ptr %179, align 8, !tbaa !39
  %181 = sext i8 %180 to i64
  %182 = getelementptr inbounds [20 x i16], ptr %177, i64 0, i64 %181
  %183 = load i16, ptr %182, align 2, !tbaa !42
  %184 = zext i16 %183 to i32
  store i32 %184, ptr %13, align 4, !tbaa !9
  %185 = load i32, ptr %11, align 4, !tbaa !9
  %186 = icmp eq i32 %185, 0
  br i1 %186, label %187, label %292

187:                                              ; preds = %175
  call void @llvm.lifetime.start.p0(i64 24, ptr %21) #4
  %188 = load ptr, ptr %14, align 8, !tbaa !5
  %189 = getelementptr inbounds %struct.MemPage, ptr %188, i32 0, i32 23
  %190 = load ptr, ptr %189, align 8, !tbaa !43
  %191 = call i32 @sqlite3PagerWrite(ptr noundef %190)
  store i32 %191, ptr %10, align 4, !tbaa !9
  %192 = load i32, ptr %10, align 4, !tbaa !9
  %193 = icmp ne i32 %192, 0
  br i1 %193, label %194, label %195

194:                                              ; preds = %187
  store i32 2, ptr %19, align 4
  br label %289

195:                                              ; preds = %187
  %196 = load ptr, ptr %14, align 8, !tbaa !5
  %197 = getelementptr inbounds %struct.MemPage, ptr %196, i32 0, i32 19
  %198 = load ptr, ptr %197, align 8, !tbaa !45
  %199 = load ptr, ptr %14, align 8, !tbaa !5
  %200 = getelementptr inbounds %struct.MemPage, ptr %199, i32 0, i32 15
  %201 = load i16, ptr %200, align 8, !tbaa !46
  %202 = zext i16 %201 to i32
  %203 = load ptr, ptr %14, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.MemPage, ptr %203, i32 0, i32 21
  %205 = load ptr, ptr %204, align 8, !tbaa !47
  %206 = load i32, ptr %13, align 4, !tbaa !9
  %207 = mul nsw i32 2, %206
  %208 = sext i32 %207 to i64
  %209 = getelementptr inbounds i8, ptr %205, i64 %208
  %210 = getelementptr inbounds i8, ptr %209, i64 0
  %211 = load i8, ptr %210, align 1, !tbaa !48
  %212 = zext i8 %211 to i32
  %213 = shl i32 %212, 8
  %214 = load ptr, ptr %14, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.MemPage, ptr %214, i32 0, i32 21
  %216 = load ptr, ptr %215, align 8, !tbaa !47
  %217 = load i32, ptr %13, align 4, !tbaa !9
  %218 = mul nsw i32 2, %217
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds i8, ptr %216, i64 %219
  %221 = getelementptr inbounds i8, ptr %220, i64 1
  %222 = load i8, ptr %221, align 1, !tbaa !48
  %223 = zext i8 %222 to i32
  %224 = or i32 %213, %223
  %225 = and i32 %202, %224
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds i8, ptr %198, i64 %226
  store ptr %227, ptr %17, align 8, !tbaa !5
  %228 = load ptr, ptr %14, align 8, !tbaa !5
  %229 = getelementptr inbounds %struct.MemPage, ptr %228, i32 0, i32 5
  %230 = load i8, ptr %229, align 8, !tbaa !49
  %231 = icmp ne i8 %230, 0
  br i1 %231, label %235, label %232

232:                                              ; preds = %195
  %233 = load ptr, ptr %18, align 8, !tbaa !5
  %234 = load ptr, ptr %17, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %233, ptr align 1 %234, i64 4, i1 false)
  br label %235

235:                                              ; preds = %232, %195
  %236 = load ptr, ptr %14, align 8, !tbaa !5
  %237 = load ptr, ptr %17, align 8, !tbaa !5
  %238 = call i32 @clearCell(ptr noundef %236, ptr noundef %237, ptr noundef %21)
  store i32 %238, ptr %10, align 4, !tbaa !9
  %239 = getelementptr inbounds %struct.CellInfo, ptr %21, i32 0, i32 4
  %240 = load i16, ptr %239, align 2, !tbaa !50
  %241 = zext i16 %240 to i32
  %242 = load i32, ptr %12, align 4, !tbaa !9
  %243 = icmp eq i32 %241, %242
  br i1 %243, label %244, label %279

244:                                              ; preds = %235
  %245 = getelementptr inbounds %struct.CellInfo, ptr %21, i32 0, i32 3
  %246 = load i16, ptr %245, align 4, !tbaa !51
  %247 = zext i16 %246 to i32
  %248 = getelementptr inbounds %struct.CellInfo, ptr %21, i32 0, i32 2
  %249 = load i32, ptr %248, align 8, !tbaa !52
  %250 = icmp eq i32 %247, %249
  br i1 %250, label %251, label %279

251:                                              ; preds = %244
  %252 = load ptr, ptr %16, align 8, !tbaa !5
  %253 = getelementptr inbounds %struct.BtShared, ptr %252, i32 0, i32 5
  %254 = load i8, ptr %253, align 1, !tbaa !53
  %255 = icmp ne i8 %254, 0
  br i1 %255, label %256, label %263

256:                                              ; preds = %251
  %257 = load i32, ptr %12, align 4, !tbaa !9
  %258 = load ptr, ptr %14, align 8, !tbaa !5
  %259 = getelementptr inbounds %struct.MemPage, ptr %258, i32 0, i32 11
  %260 = load i16, ptr %259, align 8, !tbaa !54
  %261 = zext i16 %260 to i32
  %262 = icmp slt i32 %257, %261
  br i1 %262, label %263, label %279

263:                                              ; preds = %256, %251
  %264 = load ptr, ptr %17, align 8, !tbaa !5
  %265 = load i32, ptr %12, align 4, !tbaa !9
  %266 = sext i32 %265 to i64
  %267 = getelementptr inbounds i8, ptr %264, i64 %266
  %268 = load ptr, ptr %14, align 8, !tbaa !5
  %269 = getelementptr inbounds %struct.MemPage, ptr %268, i32 0, i32 20
  %270 = load ptr, ptr %269, align 8, !tbaa !55
  %271 = icmp ugt ptr %267, %270
  br i1 %271, label %272, label %274

272:                                              ; preds = %263
  %273 = call i32 @sqlite3CorruptError(i32 noundef 8188)
  store i32 %273, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %289

274:                                              ; preds = %263
  %275 = load ptr, ptr %17, align 8, !tbaa !5
  %276 = load ptr, ptr %18, align 8, !tbaa !5
  %277 = load i32, ptr %12, align 4, !tbaa !9
  %278 = sext i32 %277 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %275, ptr align 1 %276, i64 %278, i1 false)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %289

279:                                              ; preds = %256, %244, %235
  %280 = load ptr, ptr %14, align 8, !tbaa !5
  %281 = load i32, ptr %13, align 4, !tbaa !9
  %282 = getelementptr inbounds %struct.CellInfo, ptr %21, i32 0, i32 4
  %283 = load i16, ptr %282, align 2, !tbaa !50
  %284 = zext i16 %283 to i32
  call void @dropCell(ptr noundef %280, i32 noundef %281, i32 noundef %284, ptr noundef %10)
  %285 = load i32, ptr %10, align 4, !tbaa !9
  %286 = icmp ne i32 %285, 0
  br i1 %286, label %287, label %288

287:                                              ; preds = %279
  store i32 2, ptr %19, align 4
  br label %289

288:                                              ; preds = %279
  store i32 0, ptr %19, align 4
  br label %289

289:                                              ; preds = %288, %287, %274, %272, %194
  call void @llvm.lifetime.end.p0(i64 24, ptr %21) #4
  %290 = load i32, ptr %19, align 4
  switch i32 %290, label %394 [
    i32 0, label %291
    i32 2, label %392
  ]

291:                                              ; preds = %289
  br label %314

292:                                              ; preds = %175
  %293 = load i32, ptr %11, align 4, !tbaa !9
  %294 = icmp slt i32 %293, 0
  br i1 %294, label %295, label %312

295:                                              ; preds = %292
  %296 = load ptr, ptr %14, align 8, !tbaa !5
  %297 = getelementptr inbounds %struct.MemPage, ptr %296, i32 0, i32 14
  %298 = load i16, ptr %297, align 2, !tbaa !56
  %299 = zext i16 %298 to i32
  %300 = icmp sgt i32 %299, 0
  br i1 %300, label %301, label %312

301:                                              ; preds = %295
  %302 = load ptr, ptr %6, align 8, !tbaa !5
  %303 = getelementptr inbounds %struct.BtCursor, ptr %302, i32 0, i32 18
  %304 = load ptr, ptr %6, align 8, !tbaa !5
  %305 = getelementptr inbounds %struct.BtCursor, ptr %304, i32 0, i32 14
  %306 = load i8, ptr %305, align 8, !tbaa !39
  %307 = sext i8 %306 to i64
  %308 = getelementptr inbounds [20 x i16], ptr %303, i64 0, i64 %307
  %309 = load i16, ptr %308, align 2, !tbaa !42
  %310 = add i16 %309, 1
  store i16 %310, ptr %308, align 2, !tbaa !42
  %311 = zext i16 %310 to i32
  store i32 %311, ptr %13, align 4, !tbaa !9
  br label %313

312:                                              ; preds = %295, %292
  br label %313

313:                                              ; preds = %312, %301
  br label %314

314:                                              ; preds = %313, %291
  %315 = load ptr, ptr %14, align 8, !tbaa !5
  %316 = load i32, ptr %13, align 4, !tbaa !9
  %317 = load ptr, ptr %18, align 8, !tbaa !5
  %318 = load i32, ptr %12, align 4, !tbaa !9
  call void @insertCell(ptr noundef %315, i32 noundef %316, ptr noundef %317, i32 noundef %318, ptr noundef null, i32 noundef 0, ptr noundef %10)
  %319 = load ptr, ptr %6, align 8, !tbaa !5
  %320 = getelementptr inbounds %struct.BtCursor, ptr %319, i32 0, i32 4
  %321 = getelementptr inbounds %struct.CellInfo, ptr %320, i32 0, i32 4
  store i16 0, ptr %321, align 2, !tbaa !57
  %322 = load ptr, ptr %14, align 8, !tbaa !5
  %323 = getelementptr inbounds %struct.MemPage, ptr %322, i32 0, i32 9
  %324 = load i8, ptr %323, align 4, !tbaa !58
  %325 = icmp ne i8 %324, 0
  br i1 %325, label %326, label %391

326:                                              ; preds = %314
  %327 = load ptr, ptr %6, align 8, !tbaa !5
  %328 = getelementptr inbounds %struct.BtCursor, ptr %327, i32 0, i32 10
  %329 = load i8, ptr %328, align 4, !tbaa !21
  %330 = zext i8 %329 to i32
  %331 = and i32 %330, -3
  %332 = trunc i32 %331 to i8
  store i8 %332, ptr %328, align 4, !tbaa !21
  %333 = load ptr, ptr %6, align 8, !tbaa !5
  %334 = call i32 @balance(ptr noundef %333)
  store i32 %334, ptr %10, align 4, !tbaa !9
  %335 = load ptr, ptr %6, align 8, !tbaa !5
  %336 = getelementptr inbounds %struct.BtCursor, ptr %335, i32 0, i32 19
  %337 = load ptr, ptr %6, align 8, !tbaa !5
  %338 = getelementptr inbounds %struct.BtCursor, ptr %337, i32 0, i32 14
  %339 = load i8, ptr %338, align 8, !tbaa !39
  %340 = sext i8 %339 to i64
  %341 = getelementptr inbounds [20 x ptr], ptr %336, i64 0, i64 %340
  %342 = load ptr, ptr %341, align 8, !tbaa !5
  %343 = getelementptr inbounds %struct.MemPage, ptr %342, i32 0, i32 9
  store i8 0, ptr %343, align 4, !tbaa !58
  %344 = load ptr, ptr %6, align 8, !tbaa !5
  %345 = getelementptr inbounds %struct.BtCursor, ptr %344, i32 0, i32 12
  store i8 0, ptr %345, align 2, !tbaa !19
  %346 = load i32, ptr %8, align 4, !tbaa !9
  %347 = and i32 %346, 2
  %348 = icmp ne i32 %347, 0
  br i1 %348, label %349, label %390

349:                                              ; preds = %326
  %350 = load i32, ptr %10, align 4, !tbaa !9
  %351 = icmp eq i32 %350, 0
  br i1 %351, label %352, label %390

352:                                              ; preds = %349
  %353 = load ptr, ptr %6, align 8, !tbaa !5
  %354 = call i32 @moveToRoot(ptr noundef %353)
  store i32 %354, ptr %10, align 4, !tbaa !9
  %355 = load ptr, ptr %6, align 8, !tbaa !5
  %356 = getelementptr inbounds %struct.BtCursor, ptr %355, i32 0, i32 16
  %357 = load ptr, ptr %356, align 8, !tbaa !23
  %358 = icmp ne ptr %357, null
  br i1 %358, label %359, label %382

359:                                              ; preds = %352
  %360 = load ptr, ptr %7, align 8, !tbaa !5
  %361 = getelementptr inbounds %struct.BtreePayload, ptr %360, i32 0, i32 1
  %362 = load i64, ptr %361, align 8, !tbaa !24
  %363 = call ptr @sqlite3Malloc(i64 noundef %362)
  %364 = load ptr, ptr %6, align 8, !tbaa !5
  %365 = getelementptr inbounds %struct.BtCursor, ptr %364, i32 0, i32 6
  store ptr %363, ptr %365, align 8, !tbaa !59
  %366 = load ptr, ptr %6, align 8, !tbaa !5
  %367 = getelementptr inbounds %struct.BtCursor, ptr %366, i32 0, i32 6
  %368 = load ptr, ptr %367, align 8, !tbaa !59
  %369 = icmp eq ptr %368, null
  br i1 %369, label %370, label %371

370:                                              ; preds = %359
  store i32 7, ptr %10, align 4, !tbaa !9
  br label %381

371:                                              ; preds = %359
  %372 = load ptr, ptr %6, align 8, !tbaa !5
  %373 = getelementptr inbounds %struct.BtCursor, ptr %372, i32 0, i32 6
  %374 = load ptr, ptr %373, align 8, !tbaa !59
  %375 = load ptr, ptr %7, align 8, !tbaa !5
  %376 = getelementptr inbounds %struct.BtreePayload, ptr %375, i32 0, i32 0
  %377 = load ptr, ptr %376, align 8, !tbaa !38
  %378 = load ptr, ptr %7, align 8, !tbaa !5
  %379 = getelementptr inbounds %struct.BtreePayload, ptr %378, i32 0, i32 1
  %380 = load i64, ptr %379, align 8, !tbaa !24
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %374, ptr align 1 %377, i64 %380, i1 false)
  br label %381

381:                                              ; preds = %371, %370
  br label %382

382:                                              ; preds = %381, %352
  %383 = load ptr, ptr %6, align 8, !tbaa !5
  %384 = getelementptr inbounds %struct.BtCursor, ptr %383, i32 0, i32 12
  store i8 3, ptr %384, align 2, !tbaa !19
  %385 = load ptr, ptr %7, align 8, !tbaa !5
  %386 = getelementptr inbounds %struct.BtreePayload, ptr %385, i32 0, i32 1
  %387 = load i64, ptr %386, align 8, !tbaa !24
  %388 = load ptr, ptr %6, align 8, !tbaa !5
  %389 = getelementptr inbounds %struct.BtCursor, ptr %388, i32 0, i32 5
  store i64 %387, ptr %389, align 8, !tbaa !60
  br label %390

390:                                              ; preds = %382, %349, %326
  br label %391

391:                                              ; preds = %390, %314
  br label %392

392:                                              ; preds = %391, %289, %174
  %393 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %393, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %394

394:                                              ; preds = %392, %289, %152, %97, %54, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %395 = load i32, ptr %5, align 4
  ret i32 %395
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @btreeMoveto(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) #3

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

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

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

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"BtCursor", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !14, i64 56, !6, i64 64, !10, i64 72, !10, i64 76, !10, 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}
!13 = !{!"CellInfo", !14, i64 0, !6, i64 8, !10, i64 16, !15, i64 20, !15, i64 22}
!14 = !{!"long long", !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, !10, i64 20, !10, i64 24, !10, i64 28, !6, i64 32, !6, i64 40, !18, i64 48}
!18 = !{!"BtLock", !6, i64 0, !10, i64 8, !7, i64 12, !6, i64 16}
!19 = !{!12, !7, i64 86}
!20 = !{!12, !10, i64 80}
!21 = !{!12, !7, i64 84}
!22 = !{!12, !10, i64 72}
!23 = !{!12, !6, i64 96}
!24 = !{!25, !14, i64 8}
!25 = !{!"BtreePayload", !6, i64 0, !14, i64 8, !6, i64 16, !6, i64 24, !15, i64 32, !10, i64 36, !10, i64 40}
!26 = !{!12, !14, i64 32}
!27 = !{!25, !15, i64 32}
!28 = !{!29, !6, i64 0}
!29 = !{!"UnpackedRecord", !6, i64 0, !6, i64 8, !15, i64 16, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22}
!30 = !{!25, !6, i64 24}
!31 = !{!29, !6, i64 8}
!32 = !{!29, !15, i64 16}
!33 = !{!29, !7, i64 18}
!34 = !{!29, !7, i64 19}
!35 = !{!29, !7, i64 20}
!36 = !{!29, !7, i64 21}
!37 = !{!29, !7, i64 22}
!38 = !{!25, !6, i64 0}
!39 = !{!12, !7, i64 88}
!40 = !{!41, !6, i64 128}
!41 = !{!"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, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!42 = !{!15, !15, i64 0}
!43 = !{!44, !6, i64 112}
!44 = !{!"MemPage", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !10, 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}
!45 = !{!44, !6, i64 80}
!46 = !{!44, !15, i64 24}
!47 = !{!44, !6, i64 96}
!48 = !{!7, !7, i64 0}
!49 = !{!44, !7, i64 8}
!50 = !{!13, !15, i64 22}
!51 = !{!13, !15, i64 20}
!52 = !{!13, !10, i64 16}
!53 = !{!41, !7, i64 33}
!54 = !{!44, !15, i64 16}
!55 = !{!44, !6, i64 88}
!56 = !{!44, !15, i64 22}
!57 = !{!12, !15, i64 54}
!58 = !{!44, !7, i64 12}
!59 = !{!12, !6, i64 64}
!60 = !{!12, !14, i64 56}


; 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.UnpackedRecord = type { ptr, ptr, i16, i8, i8, i8, i8, i8 }
%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 ptr @sqlite3Malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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 #3

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3BtreeMovetoUnpacked(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3BtreeInsert(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #3 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.UnpackedRecord, align 8
  %9 = alloca %struct.CellInfo, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  store i32 %3, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  %10 = load ptr, ptr %0, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 86
  %14 = load i8, ptr %13, align 2, !tbaa !18
  %15 = icmp eq i8 %14, 4
  br i1 %15, label %16, label %19

16:                                               ; preds = %4
  %17 = getelementptr inbounds i8, ptr %0, i64 80
  %18 = load i32, ptr %17, align 8, !tbaa !19
  br label %196

19:                                               ; preds = %4
  %20 = getelementptr inbounds i8, ptr %0, i64 84
  %21 = load i8, ptr %20, align 4, !tbaa !20
  %22 = and i8 %21, 32
  %.not = icmp eq i8 %22, 0
  br i1 %.not, label %27, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %0, i64 72
  %25 = load i32, ptr %24, align 8, !tbaa !21
  %26 = tail call i32 @saveAllCursors(ptr noundef %12, i32 noundef %25, ptr noundef nonnull %0)
  %.not92 = icmp eq i32 %26, 0
  br i1 %.not92, label %27, label %196

27:                                               ; preds = %23, %19
  %28 = getelementptr inbounds i8, ptr %0, i64 96
  %29 = load ptr, ptr %28, align 8, !tbaa !22
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %49

31:                                               ; preds = %27
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  %33 = load i64, ptr %32, align 8, !tbaa !23
  tail call void @invalidateIncrblobCursors(ptr noundef nonnull %10, i64 noundef %33, i32 noundef 0)
  %34 = load i8, ptr %20, align 4, !tbaa !20
  %35 = and i8 %34, 2
  %.not95 = icmp eq i8 %35, 0
  br i1 %.not95, label %42, label %36

36:                                               ; preds = %31
  %37 = load i64, ptr %32, align 8, !tbaa !23
  %38 = getelementptr inbounds i8, ptr %0, i64 32
  %39 = load i64, ptr %38, align 8, !tbaa !25
  %40 = icmp eq i64 %37, %39
  br i1 %40, label %41, label %42

41:                                               ; preds = %36
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %72

42:                                               ; preds = %36, %31
  %43 = icmp eq i32 %3, 0
  br i1 %43, label %44, label %72

44:                                               ; preds = %42
  %45 = load i64, ptr %32, align 8, !tbaa !23
  %46 = icmp ne i32 %2, 0
  %47 = zext i1 %46 to i32
  %48 = call i32 @sqlite3BtreeMovetoUnpacked(ptr noundef nonnull %0, ptr noundef null, i64 noundef %45, i32 noundef %47, ptr noundef nonnull %6)
  %.not96 = icmp eq i32 %48, 0
  br i1 %.not96, label %72, label %196

49:                                               ; preds = %27
  %50 = and i32 %2, 2
  %51 = or i32 %50, %3
  %or.cond106 = icmp eq i32 %51, 0
  br i1 %or.cond106, label %52, label %72

52:                                               ; preds = %49
  %53 = getelementptr inbounds i8, ptr %1, i64 32
  %54 = load i16, ptr %53, align 8, !tbaa !26
  %.not93 = icmp eq i16 %54, 0
  br i1 %.not93, label %64, label %55

55:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #5
  store ptr %29, ptr %8, align 8, !tbaa !27
  %56 = getelementptr inbounds i8, ptr %1, i64 24
  %57 = load ptr, ptr %56, align 8, !tbaa !29
  %58 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %57, ptr %58, align 8, !tbaa !30
  %59 = getelementptr inbounds i8, ptr %8, i64 16
  store i16 %54, ptr %59, align 8, !tbaa !31
  %60 = getelementptr inbounds i8, ptr %8, i64 18
  %61 = icmp ne i32 %2, 0
  %62 = zext i1 %61 to i32
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(5) %60, i8 0, i64 5, i1 false)
  %63 = call i32 @sqlite3BtreeMovetoUnpacked(ptr noundef nonnull %0, ptr noundef nonnull %8, i64 noundef 0, i32 noundef %62, ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  br label %71

64:                                               ; preds = %52
  %65 = load ptr, ptr %1, align 8, !tbaa !32
  %66 = getelementptr inbounds i8, ptr %1, i64 8
  %67 = load i64, ptr %66, align 8, !tbaa !23
  %68 = icmp ne i32 %2, 0
  %69 = zext i1 %68 to i32
  %70 = call i32 @btreeMoveto(ptr noundef nonnull %0, ptr noundef %65, i64 noundef %67, i32 noundef %69, ptr noundef nonnull %6)
  br label %71

71:                                               ; preds = %64, %55
  %.sink = phi i32 [ %70, %64 ], [ %63, %55 ]
  %.not94 = icmp eq i32 %.sink, 0
  br i1 %.not94, label %72, label %196

72:                                               ; preds = %49, %71, %41, %44, %42
  %73 = getelementptr inbounds i8, ptr %0, i64 152
  %74 = getelementptr inbounds i8, ptr %0, i64 88
  %75 = load i8, ptr %74, align 8, !tbaa !33
  %76 = sext i8 %75 to i64
  %77 = getelementptr inbounds [20 x ptr], ptr %73, i64 0, i64 %76
  %78 = load ptr, ptr %77, align 8, !tbaa !34
  %79 = getelementptr inbounds i8, ptr %12, i64 128
  %80 = load ptr, ptr %79, align 8, !tbaa !35
  %81 = call i32 @fillInCell(ptr noundef %78, ptr noundef %80, ptr noundef %1, ptr noundef nonnull %7)
  store i32 %81, ptr %5, align 4, !tbaa !5
  %.not97 = icmp eq i32 %81, 0
  br i1 %.not97, label %82, label %194

82:                                               ; preds = %72
  %83 = getelementptr inbounds i8, ptr %0, i64 112
  %84 = load i8, ptr %74, align 8, !tbaa !33
  %85 = sext i8 %84 to i64
  %86 = getelementptr inbounds [20 x i16], ptr %83, i64 0, i64 %85
  %87 = load i16, ptr %86, align 2, !tbaa !37
  %88 = zext i16 %87 to i32
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = icmp eq i32 %89, 0
  br i1 %90, label %91, label %152

91:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  %92 = getelementptr inbounds i8, ptr %78, i64 112
  %93 = load ptr, ptr %92, align 8, !tbaa !38
  %94 = call i32 @sqlite3PagerWrite(ptr noundef %93) #5
  store i32 %94, ptr %5, align 4, !tbaa !5
  %.not99 = icmp eq i32 %94, 0
  br i1 %.not99, label %95, label %.thread110

95:                                               ; preds = %91
  %96 = getelementptr inbounds i8, ptr %78, i64 80
  %97 = load ptr, ptr %96, align 8, !tbaa !40
  %98 = getelementptr inbounds i8, ptr %78, i64 24
  %99 = load i16, ptr %98, align 8, !tbaa !41
  %100 = zext i16 %99 to i64
  %101 = getelementptr inbounds i8, ptr %78, i64 96
  %102 = load ptr, ptr %101, align 8, !tbaa !42
  %103 = shl nuw nsw i32 %88, 1
  %104 = zext nneg i32 %103 to i64
  %105 = getelementptr inbounds i8, ptr %102, i64 %104
  %106 = load i8, ptr %105, align 1, !tbaa !43
  %107 = zext i8 %106 to i64
  %108 = shl nuw nsw i64 %107, 8
  %109 = getelementptr inbounds i8, ptr %105, i64 1
  %110 = load i8, ptr %109, align 1, !tbaa !43
  %111 = zext i8 %110 to i64
  %112 = or disjoint i64 %108, %111
  %113 = and i64 %112, %100
  %114 = getelementptr inbounds i8, ptr %97, i64 %113
  %115 = getelementptr inbounds i8, ptr %78, i64 8
  %116 = load i8, ptr %115, align 8, !tbaa !44
  %.not100 = icmp eq i8 %116, 0
  br i1 %.not100, label %117, label %119

117:                                              ; preds = %95
  %118 = load i32, ptr %114, align 1
  store i32 %118, ptr %80, align 1
  br label %119

119:                                              ; preds = %117, %95
  %120 = call i32 @clearCell(ptr noundef nonnull %78, ptr noundef %114, ptr noundef nonnull %9)
  store i32 %120, ptr %5, align 4, !tbaa !5
  %121 = getelementptr inbounds i8, ptr %9, i64 22
  %122 = load i16, ptr %121, align 2, !tbaa !45
  %123 = zext i16 %122 to i32
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = icmp eq i32 %124, %123
  br i1 %125, label %126, label %149

126:                                              ; preds = %119
  %127 = getelementptr inbounds i8, ptr %9, i64 20
  %128 = load i16, ptr %127, align 4, !tbaa !46
  %129 = zext i16 %128 to i32
  %130 = getelementptr inbounds i8, ptr %9, i64 16
  %131 = load i32, ptr %130, align 8, !tbaa !47
  %132 = icmp eq i32 %131, %129
  br i1 %132, label %133, label %149

133:                                              ; preds = %126
  %134 = getelementptr inbounds i8, ptr %12, i64 33
  %135 = load i8, ptr %134, align 1, !tbaa !48
  %.not101 = icmp eq i8 %135, 0
  br i1 %.not101, label %140, label %136

136:                                              ; preds = %133
  %137 = getelementptr inbounds i8, ptr %78, i64 16
  %138 = load i16, ptr %137, align 8, !tbaa !49
  %139 = icmp ult i16 %122, %138
  br i1 %139, label %140, label %149

140:                                              ; preds = %136, %133
  %141 = zext i16 %122 to i64
  %142 = getelementptr inbounds i8, ptr %114, i64 %141
  %143 = getelementptr inbounds i8, ptr %78, i64 88
  %144 = load ptr, ptr %143, align 8, !tbaa !50
  %145 = icmp ugt ptr %142, %144
  br i1 %145, label %146, label %148

146:                                              ; preds = %140
  %147 = call i32 @sqlite3CorruptError(i32 noundef 8188) #5
  br label %.thread

148:                                              ; preds = %140
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %114, ptr align 1 %80, i64 %141, i1 false)
  br label %.thread

149:                                              ; preds = %136, %126, %119
  call void @dropCell(ptr noundef nonnull %78, i32 noundef %88, i32 noundef %123, ptr noundef nonnull %5)
  %150 = load i32, ptr %5, align 4, !tbaa !5
  %.not102 = icmp eq i32 %150, 0
  br i1 %.not102, label %151, label %.thread110

.thread:                                          ; preds = %146, %148
  %.084.ph = phi i32 [ 0, %148 ], [ %147, %146 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  br label %196

.thread110:                                       ; preds = %91, %149
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  br label %194

151:                                              ; preds = %149
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  br label %160

152:                                              ; preds = %82
  %153 = icmp slt i32 %89, 0
  br i1 %153, label %154, label %160

154:                                              ; preds = %152
  %155 = getelementptr inbounds i8, ptr %78, i64 22
  %156 = load i16, ptr %155, align 2, !tbaa !51
  %.not98 = icmp eq i16 %156, 0
  br i1 %.not98, label %160, label %157

157:                                              ; preds = %154
  %158 = add i16 %87, 1
  store i16 %158, ptr %86, align 2, !tbaa !37
  %159 = zext i16 %158 to i32
  br label %160

160:                                              ; preds = %151, %157, %154, %152
  %.085 = phi i32 [ %88, %151 ], [ %159, %157 ], [ %88, %154 ], [ %88, %152 ]
  %161 = load i32, ptr %7, align 4, !tbaa !5
  call void @insertCell(ptr noundef %78, i32 noundef %.085, ptr noundef %80, i32 noundef %161, ptr noundef null, i32 noundef 0, ptr noundef nonnull %5)
  %162 = getelementptr inbounds i8, ptr %0, i64 54
  store i16 0, ptr %162, align 2, !tbaa !52
  %163 = getelementptr inbounds i8, ptr %78, i64 12
  %164 = load i8, ptr %163, align 4, !tbaa !53
  %.not103 = icmp eq i8 %164, 0
  br i1 %.not103, label %194, label %165

165:                                              ; preds = %160
  %166 = load i8, ptr %20, align 4, !tbaa !20
  %167 = and i8 %166, -3
  store i8 %167, ptr %20, align 4, !tbaa !20
  %168 = call i32 @balance(ptr noundef nonnull %0)
  store i32 %168, ptr %5, align 4, !tbaa !5
  %169 = load i8, ptr %74, align 8, !tbaa !33
  %170 = sext i8 %169 to i64
  %171 = getelementptr inbounds [20 x ptr], ptr %73, i64 0, i64 %170
  %172 = load ptr, ptr %171, align 8, !tbaa !34
  %173 = getelementptr inbounds i8, ptr %172, i64 12
  store i8 0, ptr %173, align 4, !tbaa !53
  store i8 0, ptr %13, align 2, !tbaa !18
  %174 = and i32 %2, 2
  %175 = icmp ne i32 %174, 0
  %176 = icmp eq i32 %168, 0
  %or.cond = select i1 %175, i1 %176, i1 false
  br i1 %or.cond, label %177, label %194

177:                                              ; preds = %165
  %178 = call i32 @moveToRoot(ptr noundef nonnull %0)
  store i32 %178, ptr %5, align 4, !tbaa !5
  %179 = load ptr, ptr %28, align 8, !tbaa !22
  %.not104 = icmp eq ptr %179, null
  br i1 %.not104, label %190, label %180

180:                                              ; preds = %177
  %181 = getelementptr inbounds i8, ptr %1, i64 8
  %182 = load i64, ptr %181, align 8, !tbaa !23
  %183 = call ptr @sqlite3Malloc(i64 noundef %182) #5
  %184 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %183, ptr %184, align 8, !tbaa !54
  %185 = icmp eq ptr %183, null
  br i1 %185, label %186, label %187

186:                                              ; preds = %180
  store i32 7, ptr %5, align 4, !tbaa !5
  br label %190

187:                                              ; preds = %180
  %188 = load ptr, ptr %1, align 8, !tbaa !32
  %189 = load i64, ptr %181, align 8, !tbaa !23
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %183, ptr align 1 %188, i64 %189, i1 false)
  br label %190

190:                                              ; preds = %186, %187, %177
  store i8 3, ptr %13, align 2, !tbaa !18
  %191 = getelementptr inbounds i8, ptr %1, i64 8
  %192 = load i64, ptr %191, align 8, !tbaa !23
  %193 = getelementptr inbounds i8, ptr %0, i64 56
  store i64 %192, ptr %193, align 8, !tbaa !55
  br label %194

194:                                              ; preds = %.thread110, %160, %190, %165, %72
  %195 = load i32, ptr %5, align 4, !tbaa !5
  br label %196

196:                                              ; preds = %.thread, %71, %44, %23, %194, %16
  %.1 = phi i32 [ %18, %16 ], [ %195, %194 ], [ %26, %23 ], [ %48, %44 ], [ %.sink, %71 ], [ %.084.ph, %.thread ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret i32 %.1
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @btreeMoveto(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"BtCursor", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !13, i64 56, !11, i64 64, !6, i64 72, !6, i64 76, !6, i64 80, !7, i64 84, !7, i64 85, !7, i64 86, !7, i64 87, !7, i64 88, !7, i64 89, !11, i64 96, !11, i64 104, !7, i64 112, !7, i64 152}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"CellInfo", !13, i64 0, !11, i64 8, !6, i64 16, !14, i64 20, !14, i64 22}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !11, i64 8}
!16 = !{!"Btree", !11, i64 0, !11, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !6, i64 20, !6, i64 24, !6, i64 28, !11, i64 32, !11, i64 40, !17, i64 48}
!17 = !{!"BtLock", !11, i64 0, !6, i64 8, !7, i64 12, !11, i64 16}
!18 = !{!10, !7, i64 86}
!19 = !{!10, !6, i64 80}
!20 = !{!10, !7, i64 84}
!21 = !{!10, !6, i64 72}
!22 = !{!10, !11, i64 96}
!23 = !{!24, !13, i64 8}
!24 = !{!"BtreePayload", !11, i64 0, !13, i64 8, !11, i64 16, !11, i64 24, !14, i64 32, !6, i64 36, !6, i64 40}
!25 = !{!10, !13, i64 32}
!26 = !{!24, !14, i64 32}
!27 = !{!28, !11, i64 0}
!28 = !{!"UnpackedRecord", !11, i64 0, !11, i64 8, !14, i64 16, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22}
!29 = !{!24, !11, i64 24}
!30 = !{!28, !11, i64 8}
!31 = !{!28, !14, i64 16}
!32 = !{!24, !11, i64 0}
!33 = !{!10, !7, i64 88}
!34 = !{!11, !11, i64 0}
!35 = !{!36, !11, i64 128}
!36 = !{!"BtShared", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !7, i64 36, !7, i64 37, !14, i64 38, !14, i64 40, !14, i64 42, !14, i64 44, !14, i64 46, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !6, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128}
!37 = !{!14, !14, i64 0}
!38 = !{!39, !11, i64 112}
!39 = !{!"MemPage", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 4, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !14, i64 14, !14, i64 16, !14, i64 18, !14, i64 20, !14, i64 22, !14, i64 24, !7, i64 26, !7, i64 40, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128}
!40 = !{!39, !11, i64 80}
!41 = !{!39, !14, i64 24}
!42 = !{!39, !11, i64 96}
!43 = !{!7, !7, i64 0}
!44 = !{!39, !7, i64 8}
!45 = !{!12, !14, i64 22}
!46 = !{!12, !14, i64 20}
!47 = !{!12, !6, i64 16}
!48 = !{!36, !7, i64 33}
!49 = !{!39, !14, i64 16}
!50 = !{!39, !11, i64 88}
!51 = !{!39, !14, i64 22}
!52 = !{!10, !14, i64 54}
!53 = !{!39, !7, i64 12}
!54 = !{!10, !11, i64 64}
!55 = !{!10, !13, i64 56}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MemCpyOptPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass