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

; 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.Pager = type { ptr, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i64, i64, ptr, ptr, i32, i32, [16 x i8], i32, i64, ptr, i16, i16, i32, i32, i32, i32, i64, ptr, ptr, ptr, ptr, [3 x i32], ptr, ptr, ptr, ptr, ptr, ptr }
%struct.sqlite3_file = type { 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

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

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

declare i32 @sqlite3OsRead(ptr noundef, ptr noundef, i32 noundef, i64 noundef) #3

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @pagerSyncHotJournal(ptr noundef) #1

declare void @sqlite3OsClose(ptr noundef) #3

declare i32 @sqlite3CantopenError(i32 noundef) #3

declare i32 @sqlite3OsOpen(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3PagerSharedLock(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [16 x i8], align 16
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.Pager, ptr %13, i32 0, i32 60
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = icmp ne ptr %15, null
  br i1 %16, label %205, label %17

17:                                               ; preds = %1
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Pager, ptr %18, i32 0, i32 14
  %20 = load i8, ptr %19, align 1, !tbaa !15
  %21 = zext i8 %20 to i32
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %205

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = call i32 @pager_wait_on_lock(ptr noundef %24, i32 noundef 1)
  store i32 %25, ptr %4, align 4, !tbaa !9
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  store i32 2, ptr %12, align 4
  br label %202

29:                                               ; preds = %23
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Pager, ptr %30, i32 0, i32 15
  %32 = load i8, ptr %31, align 2, !tbaa !16
  %33 = zext i8 %32 to i32
  %34 = icmp sle i32 %33, 1
  br i1 %34, label %35, label %38

35:                                               ; preds = %29
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = call i32 @hasHotJournal(ptr noundef %36, ptr noundef %5)
  store i32 %37, ptr %4, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %35, %29
  %39 = load i32, ptr %4, align 4, !tbaa !9
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %38
  store i32 2, ptr %12, align 4
  br label %202

42:                                               ; preds = %38
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %142

45:                                               ; preds = %42
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Pager, ptr %46, i32 0, i32 12
  %48 = load i8, ptr %47, align 1, !tbaa !17
  %49 = icmp ne i8 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %45
  store i32 776, ptr %4, align 4, !tbaa !9
  store i32 2, ptr %12, align 4
  br label %202

51:                                               ; preds = %45
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = call i32 @pagerLockDb(ptr noundef %52, i32 noundef 4)
  store i32 %53, ptr %4, align 4, !tbaa !9
  %54 = load i32, ptr %4, align 4, !tbaa !9
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %57

56:                                               ; preds = %51
  store i32 2, ptr %12, align 4
  br label %202

57:                                               ; preds = %51
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.Pager, ptr %58, i32 0, i32 32
  %60 = load ptr, ptr %59, align 8, !tbaa !18
  %61 = getelementptr inbounds %struct.sqlite3_file, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !19
  %63 = icmp ne ptr %62, null
  br i1 %63, label %101, label %64

64:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Pager, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !21
  store ptr %67, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.Pager, ptr %69, i32 0, i32 52
  %71 = load ptr, ptr %70, align 8, !tbaa !22
  %72 = call i32 @sqlite3OsAccess(ptr noundef %68, ptr noundef %71, i32 noundef 0, ptr noundef %7)
  store i32 %72, ptr %4, align 4, !tbaa !9
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %100

75:                                               ; preds = %64
  %76 = load i32, ptr %7, align 4, !tbaa !9
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %100

78:                                               ; preds = %75
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 2050, ptr %9, align 4, !tbaa !9
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.Pager, ptr %80, i32 0, i32 52
  %82 = load ptr, ptr %81, align 8, !tbaa !22
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.Pager, ptr %83, i32 0, i32 32
  %85 = load ptr, ptr %84, align 8, !tbaa !18
  %86 = load i32, ptr %9, align 4, !tbaa !9
  %87 = call i32 @sqlite3OsOpen(ptr noundef %79, ptr noundef %82, ptr noundef %85, i32 noundef %86, ptr noundef %8)
  store i32 %87, ptr %4, align 4, !tbaa !9
  %88 = load i32, ptr %4, align 4, !tbaa !9
  %89 = icmp eq i32 %88, 0
  br i1 %89, label %90, label %99

90:                                               ; preds = %78
  %91 = load i32, ptr %8, align 4, !tbaa !9
  %92 = and i32 %91, 1
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %99

94:                                               ; preds = %90
  %95 = call i32 @sqlite3CantopenError(i32 noundef 5165)
  store i32 %95, ptr %4, align 4, !tbaa !9
  %96 = load ptr, ptr %3, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.Pager, ptr %96, i32 0, i32 32
  %98 = load ptr, ptr %97, align 8, !tbaa !18
  call void @sqlite3OsClose(ptr noundef %98)
  br label %99

99:                                               ; preds = %94, %90, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %100

100:                                              ; preds = %99, %75, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %101

101:                                              ; preds = %100, %57
  %102 = load ptr, ptr %3, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.Pager, ptr %102, i32 0, i32 32
  %104 = load ptr, ptr %103, align 8, !tbaa !18
  %105 = getelementptr inbounds %struct.sqlite3_file, ptr %104, i32 0, i32 0
  %106 = load ptr, ptr %105, align 8, !tbaa !19
  %107 = icmp ne ptr %106, null
  br i1 %107, label %108, label %125

108:                                              ; preds = %101
  %109 = load ptr, ptr %3, align 8, !tbaa !5
  %110 = call i32 @pagerSyncHotJournal(ptr noundef %109)
  store i32 %110, ptr %4, align 4, !tbaa !9
  %111 = load i32, ptr %4, align 4, !tbaa !9
  %112 = icmp eq i32 %111, 0
  br i1 %112, label %113, label %124

113:                                              ; preds = %108
  %114 = load ptr, ptr %3, align 8, !tbaa !5
  %115 = load ptr, ptr %3, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.Pager, ptr %115, i32 0, i32 10
  %117 = load i8, ptr %116, align 1, !tbaa !23
  %118 = icmp ne i8 %117, 0
  %119 = xor i1 %118, true
  %120 = zext i1 %119 to i32
  %121 = call i32 @pager_playback(ptr noundef %114, i32 noundef %120)
  store i32 %121, ptr %4, align 4, !tbaa !9
  %122 = load ptr, ptr %3, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.Pager, ptr %122, i32 0, i32 14
  store i8 0, ptr %123, align 1, !tbaa !15
  br label %124

124:                                              ; preds = %113, %108
  br label %134

125:                                              ; preds = %101
  %126 = load ptr, ptr %3, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.Pager, ptr %126, i32 0, i32 1
  %128 = load i8, ptr %127, align 8, !tbaa !24
  %129 = icmp ne i8 %128, 0
  br i1 %129, label %133, label %130

130:                                              ; preds = %125
  %131 = load ptr, ptr %3, align 8, !tbaa !5
  %132 = call i32 @pagerUnlockDb(ptr noundef %131, i32 noundef 1)
  br label %133

133:                                              ; preds = %130, %125
  br label %134

134:                                              ; preds = %133, %124
  %135 = load i32, ptr %4, align 4, !tbaa !9
  %136 = icmp ne i32 %135, 0
  br i1 %136, label %137, label %141

137:                                              ; preds = %134
  %138 = load ptr, ptr %3, align 8, !tbaa !5
  %139 = load i32, ptr %4, align 4, !tbaa !9
  %140 = call i32 @pager_error(ptr noundef %138, i32 noundef %139)
  store i32 2, ptr %12, align 4
  br label %202

141:                                              ; preds = %134
  br label %142

142:                                              ; preds = %141, %42
  %143 = load ptr, ptr %3, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.Pager, ptr %143, i32 0, i32 10
  %145 = load i8, ptr %144, align 1, !tbaa !23
  %146 = icmp ne i8 %145, 0
  br i1 %146, label %199, label %147

147:                                              ; preds = %142
  %148 = load ptr, ptr %3, align 8, !tbaa !5
  %149 = getelementptr inbounds %struct.Pager, ptr %148, i32 0, i32 21
  %150 = load i8, ptr %149, align 4, !tbaa !25
  %151 = zext i8 %150 to i32
  %152 = icmp ne i32 %151, 0
  br i1 %152, label %153, label %199

153:                                              ; preds = %147
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  %154 = load ptr, ptr %3, align 8, !tbaa !5
  %155 = call i32 @pagerPagecount(ptr noundef %154, ptr noundef %10)
  store i32 %155, ptr %4, align 4, !tbaa !9
  %156 = load i32, ptr %4, align 4, !tbaa !9
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %158, label %159

158:                                              ; preds = %153
  store i32 2, ptr %12, align 4
  br label %196

159:                                              ; preds = %153
  %160 = load i32, ptr %10, align 4, !tbaa !9
  %161 = icmp ugt i32 %160, 0
  br i1 %161, label %162, label %174

162:                                              ; preds = %159
  %163 = load ptr, ptr %3, align 8, !tbaa !5
  %164 = getelementptr inbounds %struct.Pager, ptr %163, i32 0, i32 31
  %165 = load ptr, ptr %164, align 8, !tbaa !26
  %166 = call i32 @sqlite3OsRead(ptr noundef %165, ptr noundef %11, i32 noundef 16, i64 noundef 24)
  store i32 %166, ptr %4, align 4, !tbaa !9
  %167 = load i32, ptr %4, align 4, !tbaa !9
  %168 = icmp ne i32 %167, 0
  br i1 %168, label %169, label %173

169:                                              ; preds = %162
  %170 = load i32, ptr %4, align 4, !tbaa !9
  %171 = icmp ne i32 %170, 522
  br i1 %171, label %172, label %173

172:                                              ; preds = %169
  store i32 2, ptr %12, align 4
  br label %196

173:                                              ; preds = %169, %162
  br label %176

174:                                              ; preds = %159
  %175 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %175, i8 0, i64 16, i1 false)
  br label %176

176:                                              ; preds = %174, %173
  %177 = load ptr, ptr %3, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.Pager, ptr %177, i32 0, i32 40
  %179 = getelementptr inbounds [16 x i8], ptr %178, i64 0, i64 0
  %180 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %181 = call i32 @memcmp(ptr noundef %179, ptr noundef %180, i64 noundef 16) #6
  %182 = icmp ne i32 %181, 0
  br i1 %182, label %183, label %195

183:                                              ; preds = %176
  %184 = load ptr, ptr %3, align 8, !tbaa !5
  call void @pager_reset(ptr noundef %184)
  %185 = load ptr, ptr %3, align 8, !tbaa !5
  %186 = getelementptr inbounds %struct.Pager, ptr %185, i32 0, i32 20
  %187 = load i8, ptr %186, align 1, !tbaa !27
  %188 = icmp ne i8 %187, 0
  br i1 %188, label %189, label %194

189:                                              ; preds = %183
  %190 = load ptr, ptr %3, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.Pager, ptr %190, i32 0, i32 31
  %192 = load ptr, ptr %191, align 8, !tbaa !26
  %193 = call i32 @sqlite3OsUnfetch(ptr noundef %192, i64 noundef 0, ptr noundef null)
  br label %194

194:                                              ; preds = %189, %183
  br label %195

195:                                              ; preds = %194, %176
  store i32 0, ptr %12, align 4
  br label %196

196:                                              ; preds = %195, %172, %158
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %197 = load i32, ptr %12, align 4
  switch i32 %197, label %202 [
    i32 0, label %198
  ]

198:                                              ; preds = %196
  br label %199

199:                                              ; preds = %198, %147, %142
  %200 = load ptr, ptr %3, align 8, !tbaa !5
  %201 = call i32 @pagerOpenWalIfPresent(ptr noundef %200)
  store i32 %201, ptr %4, align 4, !tbaa !9
  store i32 0, ptr %12, align 4
  br label %202

202:                                              ; preds = %199, %196, %137, %56, %50, %41, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  %203 = load i32, ptr %12, align 4
  switch i32 %203, label %246 [
    i32 0, label %204
    i32 2, label %234
  ]

204:                                              ; preds = %202
  br label %205

205:                                              ; preds = %204, %17, %1
  %206 = load ptr, ptr %3, align 8, !tbaa !5
  %207 = getelementptr inbounds %struct.Pager, ptr %206, i32 0, i32 60
  %208 = load ptr, ptr %207, align 8, !tbaa !11
  %209 = icmp ne ptr %208, null
  br i1 %209, label %210, label %213

210:                                              ; preds = %205
  %211 = load ptr, ptr %3, align 8, !tbaa !5
  %212 = call i32 @pagerBeginReadTransaction(ptr noundef %211)
  store i32 %212, ptr %4, align 4, !tbaa !9
  br label %213

213:                                              ; preds = %210, %205
  %214 = load ptr, ptr %3, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.Pager, ptr %214, i32 0, i32 10
  %216 = load i8, ptr %215, align 1, !tbaa !23
  %217 = zext i8 %216 to i32
  %218 = icmp eq i32 %217, 0
  br i1 %218, label %219, label %233

219:                                              ; preds = %213
  %220 = load ptr, ptr %3, align 8, !tbaa !5
  %221 = getelementptr inbounds %struct.Pager, ptr %220, i32 0, i32 14
  %222 = load i8, ptr %221, align 1, !tbaa !15
  %223 = zext i8 %222 to i32
  %224 = icmp eq i32 %223, 0
  br i1 %224, label %225, label %233

225:                                              ; preds = %219
  %226 = load i32, ptr %4, align 4, !tbaa !9
  %227 = icmp eq i32 %226, 0
  br i1 %227, label %228, label %233

228:                                              ; preds = %225
  %229 = load ptr, ptr %3, align 8, !tbaa !5
  %230 = load ptr, ptr %3, align 8, !tbaa !5
  %231 = getelementptr inbounds %struct.Pager, ptr %230, i32 0, i32 22
  %232 = call i32 @pagerPagecount(ptr noundef %229, ptr noundef %231)
  store i32 %232, ptr %4, align 4, !tbaa !9
  br label %233

233:                                              ; preds = %228, %225, %219, %213
  br label %234

234:                                              ; preds = %233, %202
  %235 = load i32, ptr %4, align 4, !tbaa !9
  %236 = icmp ne i32 %235, 0
  br i1 %236, label %237, label %239

237:                                              ; preds = %234
  %238 = load ptr, ptr %3, align 8, !tbaa !5
  call void @pager_unlock(ptr noundef %238)
  br label %244

239:                                              ; preds = %234
  %240 = load ptr, ptr %3, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.Pager, ptr %240, i32 0, i32 14
  store i8 1, ptr %241, align 1, !tbaa !15
  %242 = load ptr, ptr %3, align 8, !tbaa !5
  %243 = getelementptr inbounds %struct.Pager, ptr %242, i32 0, i32 21
  store i8 1, ptr %243, align 4, !tbaa !25
  br label %244

244:                                              ; preds = %239, %237
  %245 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %245, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %246

246:                                              ; preds = %244, %202
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %247 = load i32, ptr %2, align 4
  ret i32 %247
}

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

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

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

declare i32 @sqlite3OsAccess(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #4

declare i32 @sqlite3OsUnfetch(ptr noundef, i64 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @pagerOpenWalIfPresent(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @pagerBeginReadTransaction(ptr noundef) #1

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

!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 288}
!12 = !{!"Pager", !6, i64 0, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22, !7, i64 23, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !7, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !13, i64 96, !13, i64 104, !6, i64 112, !6, i64 120, !10, i64 128, !10, i64 132, !7, i64 136, !10, i64 152, !13, i64 160, !6, i64 168, !14, i64 176, !14, i64 178, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !13, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !7, i64 240, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !7, i64 21}
!16 = !{!12, !7, i64 22}
!17 = !{!12, !7, i64 19}
!18 = !{!12, !6, i64 80}
!19 = !{!20, !6, i64 0}
!20 = !{!"sqlite3_file", !6, i64 0}
!21 = !{!12, !6, i64 0}
!22 = !{!12, !6, i64 216}
!23 = !{!12, !7, i64 17}
!24 = !{!12, !7, i64 8}
!25 = !{!12, !7, i64 28}
!26 = !{!12, !6, i64 72}
!27 = !{!12, !7, i64 27}


; 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"

; 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

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

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

declare i32 @sqlite3OsRead(ptr noundef, ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #3

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

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

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

declare void @sqlite3OsClose(ptr noundef) local_unnamed_addr #3

declare i32 @sqlite3CantopenError(i32 noundef) local_unnamed_addr #3

declare i32 @sqlite3OsOpen(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3PagerSharedLock(ptr noundef %0) local_unnamed_addr #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca [16 x i8], align 16
  %7 = getelementptr inbounds i8, ptr %0, i64 288
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %.thread109

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 21
  %11 = load i8, ptr %10, align 1, !tbaa !13
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %13, label %.thread124

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 1, ptr %2, align 4, !tbaa !14
  %14 = tail call i32 @pager_wait_on_lock(ptr noundef nonnull %0, i32 noundef 1)
  %.not76 = icmp eq i32 %14, 0
  br i1 %.not76, label %15, label %.thread112

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %0, i64 22
  %17 = load i8, ptr %16, align 2, !tbaa !15
  %18 = icmp ult i8 %17, 2
  br i1 %18, label %19, label %.thread.thread

19:                                               ; preds = %15
  %20 = call i32 @hasHotJournal(ptr noundef nonnull %0, ptr noundef nonnull %2)
  %.not77 = icmp eq i32 %20, 0
  br i1 %.not77, label %.thread, label %.thread112

.thread:                                          ; preds = %19
  %.pre = load i32, ptr %2, align 4, !tbaa !14
  %.not78 = icmp eq i32 %.pre, 0
  br i1 %.not78, label %65, label %.thread.thread

.thread.thread:                                   ; preds = %15, %.thread
  %21 = getelementptr inbounds i8, ptr %0, i64 19
  %22 = load i8, ptr %21, align 1, !tbaa !16
  %.not79 = icmp eq i8 %22, 0
  br i1 %.not79, label %23, label %.thread112

23:                                               ; preds = %.thread.thread
  %24 = call i32 @pagerLockDb(ptr noundef nonnull %0, i32 noundef 4)
  %.not80 = icmp eq i32 %24, 0
  br i1 %.not80, label %25, label %.thread112

25:                                               ; preds = %23
  %26 = getelementptr inbounds i8, ptr %0, i64 80
  %27 = load ptr, ptr %26, align 8, !tbaa !17
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %.not81 = icmp eq ptr %28, null
  br i1 %.not81, label %29, label %.thread121

29:                                               ; preds = %25
  %30 = load ptr, ptr %0, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %31 = getelementptr inbounds i8, ptr %0, i64 216
  %32 = load ptr, ptr %31, align 8, !tbaa !21
  %33 = call i32 @sqlite3OsAccess(ptr noundef %30, ptr noundef %32, i32 noundef 0, ptr noundef nonnull %3) #5
  %34 = icmp eq i32 %33, 0
  %35 = load i32, ptr %3, align 4
  %36 = icmp ne i32 %35, 0
  %or.cond = select i1 %34, i1 %36, i1 false
  br i1 %or.cond, label %37, label %49

37:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  store i32 0, ptr %4, align 4, !tbaa !14
  %38 = load ptr, ptr %31, align 8, !tbaa !21
  %39 = load ptr, ptr %26, align 8, !tbaa !17
  %40 = call i32 @sqlite3OsOpen(ptr noundef %30, ptr noundef %38, ptr noundef %39, i32 noundef 2050, ptr noundef nonnull %4) #5
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %48

42:                                               ; preds = %37
  %43 = load i32, ptr %4, align 4, !tbaa !14
  %44 = and i32 %43, 1
  %.not82 = icmp eq i32 %44, 0
  br i1 %.not82, label %48, label %45

45:                                               ; preds = %42
  %46 = call i32 @sqlite3CantopenError(i32 noundef 5165) #5
  %47 = load ptr, ptr %26, align 8, !tbaa !17
  call void @sqlite3OsClose(ptr noundef %47) #5
  br label %48

48:                                               ; preds = %45, %42, %37
  %.165 = phi i32 [ %46, %45 ], [ 0, %42 ], [ %40, %37 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  br label %49

49:                                               ; preds = %29, %48
  %.2 = phi i32 [ %.165, %48 ], [ %33, %29 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  %.pre117 = load ptr, ptr %26, align 8, !tbaa !17
  %.pre118 = load ptr, ptr %.pre117, align 8, !tbaa !18
  %50 = icmp eq ptr %.pre118, null
  br i1 %50, label %58, label %.thread121

.thread121:                                       ; preds = %25, %49
  %51 = call i32 @pagerSyncHotJournal(ptr noundef nonnull %0)
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %.thread97

53:                                               ; preds = %.thread121
  %54 = getelementptr inbounds i8, ptr %0, i64 17
  %55 = load i8, ptr %54, align 1, !tbaa !22
  %.not85 = icmp eq i8 %55, 0
  %56 = zext i1 %.not85 to i32
  %57 = call i32 @pager_playback(ptr noundef nonnull %0, i32 noundef %56)
  store i8 0, ptr %10, align 1, !tbaa !13
  br label %63

58:                                               ; preds = %49
  %59 = getelementptr inbounds i8, ptr %0, i64 8
  %60 = load i8, ptr %59, align 8, !tbaa !23
  %.not84 = icmp eq i8 %60, 0
  br i1 %.not84, label %61, label %63

61:                                               ; preds = %58
  %62 = call i32 @pagerUnlockDb(ptr noundef nonnull %0, i32 noundef 1)
  br label %63

63:                                               ; preds = %58, %61, %53
  %.4 = phi i32 [ %57, %53 ], [ %.2, %58 ], [ %.2, %61 ]
  %.not86 = icmp eq i32 %.4, 0
  br i1 %.not86, label %65, label %.thread97

.thread97:                                        ; preds = %.thread121, %63
  %.4100 = phi i32 [ %.4, %63 ], [ %51, %.thread121 ]
  %64 = call i32 @pager_error(ptr noundef nonnull %0, i32 noundef %.4100)
  br label %.thread112

65:                                               ; preds = %63, %.thread
  %66 = getelementptr inbounds i8, ptr %0, i64 17
  %67 = load i8, ptr %66, align 1, !tbaa !22
  %.not87 = icmp eq i8 %67, 0
  br i1 %.not87, label %68, label %90

68:                                               ; preds = %65
  %69 = getelementptr inbounds i8, ptr %0, i64 28
  %70 = load i8, ptr %69, align 4, !tbaa !24
  %.not88 = icmp eq i8 %70, 0
  br i1 %.not88, label %90, label %71

71:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store i32 0, ptr %5, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  %72 = call i32 @pagerPagecount(ptr noundef nonnull %0, ptr noundef nonnull %5)
  %.not89 = icmp eq i32 %72, 0
  br i1 %.not89, label %73, label %89

73:                                               ; preds = %71
  %74 = load i32, ptr %5, align 4, !tbaa !14
  %.not90 = icmp eq i32 %74, 0
  br i1 %.not90, label %79, label %75

75:                                               ; preds = %73
  %76 = getelementptr inbounds i8, ptr %0, i64 72
  %77 = load ptr, ptr %76, align 8, !tbaa !25
  %78 = call i32 @sqlite3OsRead(ptr noundef %77, ptr noundef nonnull %6, i32 noundef 16, i64 noundef 24) #5
  switch i32 %78, label %89 [
    i32 522, label %80
    i32 0, label %80
  ]

79:                                               ; preds = %73
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %6, i8 0, i64 16, i1 false)
  br label %80

80:                                               ; preds = %75, %75, %79
  %81 = getelementptr inbounds i8, ptr %0, i64 136
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(16) %81, ptr noundef nonnull dereferenceable(16) %6, i64 16)
  %.not91 = icmp eq i32 %bcmp, 0
  br i1 %.not91, label %.thread101, label %82

82:                                               ; preds = %80
  call void @pager_reset(ptr noundef nonnull %0)
  %83 = getelementptr inbounds i8, ptr %0, i64 27
  %84 = load i8, ptr %83, align 1, !tbaa !26
  %.not92 = icmp eq i8 %84, 0
  br i1 %.not92, label %.thread101, label %85

85:                                               ; preds = %82
  %86 = getelementptr inbounds i8, ptr %0, i64 72
  %87 = load ptr, ptr %86, align 8, !tbaa !25
  %88 = call i32 @sqlite3OsUnfetch(ptr noundef %87, i64 noundef 0, ptr noundef null) #5
  br label %.thread101

.thread101:                                       ; preds = %82, %85, %80
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  br label %90

89:                                               ; preds = %75, %71
  %.6 = phi i32 [ %72, %71 ], [ %78, %75 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  br label %.thread112

.thread112:                                       ; preds = %23, %.thread.thread, %19, %13, %89, %.thread97
  %.7.ph = phi i32 [ %24, %23 ], [ 776, %.thread.thread ], [ %20, %19 ], [ %14, %13 ], [ %.6, %89 ], [ %.4100, %.thread97 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  br label %106

90:                                               ; preds = %.thread101, %68, %65
  %91 = call i32 @pagerOpenWalIfPresent(ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  %.pr.pre = load ptr, ptr %7, align 8, !tbaa !5
  %92 = icmp eq ptr %.pr.pre, null
  br i1 %92, label %.thread124, label %.thread109

.thread109:                                       ; preds = %1, %90
  %93 = call i32 @pagerBeginReadTransaction(ptr noundef nonnull %0)
  br label %.thread124

.thread124:                                       ; preds = %9, %.thread109, %90
  %.9 = phi i32 [ %93, %.thread109 ], [ %91, %90 ], [ 0, %9 ]
  %94 = getelementptr inbounds i8, ptr %0, i64 17
  %95 = load i8, ptr %94, align 1, !tbaa !22
  %96 = icmp eq i8 %95, 0
  br i1 %96, label %97, label %105

97:                                               ; preds = %.thread124
  %98 = getelementptr inbounds i8, ptr %0, i64 21
  %99 = load i8, ptr %98, align 1, !tbaa !13
  %100 = icmp eq i8 %99, 0
  %101 = icmp eq i32 %.9, 0
  %or.cond5 = select i1 %100, i1 %101, i1 false
  br i1 %or.cond5, label %102, label %105

102:                                              ; preds = %97
  %103 = getelementptr inbounds i8, ptr %0, i64 32
  %104 = call i32 @pagerPagecount(ptr noundef nonnull %0, ptr noundef nonnull %103)
  br label %105

105:                                              ; preds = %.thread124, %97, %102
  %.10 = phi i32 [ %104, %102 ], [ %.9, %97 ], [ %.9, %.thread124 ]
  %.not94 = icmp eq i32 %.10, 0
  br i1 %.not94, label %107, label %106

106:                                              ; preds = %.thread112, %105
  %.10116 = phi i32 [ %.7.ph, %.thread112 ], [ %.10, %105 ]
  call void @pager_unlock(ptr noundef nonnull %0)
  br label %110

107:                                              ; preds = %105
  %108 = getelementptr inbounds i8, ptr %0, i64 21
  store i8 1, ptr %108, align 1, !tbaa !13
  %109 = getelementptr inbounds i8, ptr %0, i64 28
  store i8 1, ptr %109, align 4, !tbaa !24
  br label %110

110:                                              ; preds = %106, %107
  %.10115 = phi i32 [ %.10116, %106 ], [ 0, %107 ]
  ret i32 %.10115
}

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

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

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

declare i32 @sqlite3OsAccess(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

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

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

declare i32 @sqlite3OsUnfetch(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

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

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

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = { nofree nounwind willreturn memory(argmem: read) }
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, !7, i64 288}
!6 = !{!"Pager", !7, i64 0, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !8, i64 12, !8, i64 13, !8, i64 14, !8, i64 15, !8, i64 16, !8, i64 17, !8, i64 18, !8, i64 19, !8, i64 20, !8, i64 21, !8, i64 22, !8, i64 23, !8, i64 24, !8, i64 25, !8, i64 26, !8, i64 27, !8, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !11, i64 96, !11, i64 104, !7, i64 112, !7, i64 120, !10, i64 128, !10, i64 132, !8, i64 136, !10, i64 152, !11, i64 160, !7, i64 168, !12, i64 176, !12, i64 178, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !11, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !8, i64 240, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !8, i64 21}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !8, i64 22}
!16 = !{!6, !8, i64 19}
!17 = !{!6, !7, i64 80}
!18 = !{!19, !7, i64 0}
!19 = !{!"sqlite3_file", !7, i64 0}
!20 = !{!6, !7, i64 0}
!21 = !{!6, !7, i64 216}
!22 = !{!6, !8, i64 17}
!23 = !{!6, !8, i64 8}
!24 = !{!6, !8, i64 28}
!25 = !{!6, !7, i64 72}
!26 = !{!6, !8, i64 27}


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