; LLVM IR from eProsima/Fast-DDS :: src/cpp/rtps/persistence (sqlite3)

; 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.sqlite3 = type { ptr, ptr, ptr, ptr, ptr, i32, i32, i64, i64, i64, i32, i32, i32, i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i64, i64, [12 x i32], i32, %struct.sqlite3InitInfo, i32, i32, i32, i32, i32, i32, ptr, %union.anon, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %union.anon.0, %struct.Lookaside, ptr, ptr, ptr, ptr, i32, i32, %struct.Hash, ptr, ptr, ptr, %struct.Hash, %struct.Hash, %struct.BusyHandler, [2 x %struct.Db], ptr, i32, i32, i32, i32, i64, i64, ptr, ptr }
%struct.sqlite3InitInfo = type { i32, i8, i8, i8, ptr }
%union.anon = type { ptr }
%union.anon.0 = type { double }
%struct.Lookaside = type { i32, i16, i16, i8, i32, [3 x i32], ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.Hash = type { i32, i32, ptr, ptr }
%struct.BusyHandler = type { ptr, ptr, i32 }
%struct.Db = type { ptr, ptr, i8, i8, ptr }
%struct.MemFile = type { %struct.sqlite3_file, ptr, i32 }
%struct.sqlite3_file = type { ptr }
%struct.MemStore = type { i64, i64, i64, ptr, ptr, i32, i32, i32, i32, i32, ptr }

@.str.15 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @sqlite3_malloc64(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_free(ptr 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

; Function Attrs: nounwind uwtable
declare dso_local ptr @sqlite3_mprintf(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) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_serialize(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  %21 = alloca i32, align 4
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store ptr null, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %35

28:                                               ; preds = %4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.sqlite3, ptr %29, i32 0, i32 4
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.Db, ptr %31, i64 0
  %33 = getelementptr inbounds %struct.Db, ptr %32, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !19
  store ptr %34, ptr %7, align 8, !tbaa !5
  br label %35

35:                                               ; preds = %28, %4
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = call ptr @memdbFromDbSchema(ptr noundef %36, ptr noundef %37)
  store ptr %38, ptr %10, align 8, !tbaa !5
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call i32 @sqlite3FindDbName(ptr noundef %39, ptr noundef %40)
  store i32 %41, ptr %11, align 4, !tbaa !9
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %46

44:                                               ; preds = %35
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 -1, ptr %45, align 8, !tbaa !21
  br label %46

46:                                               ; preds = %44, %35
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = icmp slt i32 %47, 0
  br i1 %48, label %49, label %50

49:                                               ; preds = %46
  store ptr null, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %211

50:                                               ; preds = %46
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %90

53:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.MemFile, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !22
  store ptr %56, ptr %20, align 8, !tbaa !5
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %64

59:                                               ; preds = %53
  %60 = load ptr, ptr %20, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.MemStore, ptr %60, i32 0, i32 0
  %62 = load i64, ptr %61, align 8, !tbaa !25
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %62, ptr %63, align 8, !tbaa !21
  br label %64

64:                                               ; preds = %59, %53
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = and i32 %65, 1
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %72

68:                                               ; preds = %64
  %69 = load ptr, ptr %20, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.MemStore, ptr %69, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !27
  store ptr %71, ptr %16, align 8, !tbaa !5
  br label %88

72:                                               ; preds = %64
  %73 = load ptr, ptr %20, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.MemStore, ptr %73, i32 0, i32 0
  %75 = load i64, ptr %74, align 8, !tbaa !25
  %76 = call ptr @sqlite3_malloc64(i64 noundef %75)
  store ptr %76, ptr %16, align 8, !tbaa !5
  %77 = load ptr, ptr %16, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %87

79:                                               ; preds = %72
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  %81 = load ptr, ptr %20, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.MemStore, ptr %81, i32 0, i32 3
  %83 = load ptr, ptr %82, align 8, !tbaa !27
  %84 = load ptr, ptr %20, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.MemStore, ptr %84, i32 0, i32 0
  %86 = load i64, ptr %85, align 8, !tbaa !25
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %80, ptr align 1 %83, i64 %86, i1 false)
  br label %87

87:                                               ; preds = %79, %72
  br label %88

88:                                               ; preds = %87, %68
  %89 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %89, ptr %5, align 8
  store i32 1, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  br label %211

90:                                               ; preds = %50
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.sqlite3, ptr %91, i32 0, i32 4
  %93 = load ptr, ptr %92, align 8, !tbaa !11
  %94 = load i32, ptr %11, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds %struct.Db, ptr %93, i64 %95
  %97 = getelementptr inbounds %struct.Db, ptr %96, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8, !tbaa !28
  store ptr %98, ptr %12, align 8, !tbaa !5
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = icmp eq ptr %99, null
  br i1 %100, label %101, label %102

101:                                              ; preds = %90
  store ptr null, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %211

102:                                              ; preds = %90
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = call i32 @sqlite3BtreeGetPageSize(ptr noundef %103)
  store i32 %104, ptr %14, align 4, !tbaa !9
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  %106 = call ptr (ptr, ...) @sqlite3_mprintf(ptr noundef @.str.15, ptr noundef %105)
  store ptr %106, ptr %17, align 8, !tbaa !5
  %107 = load ptr, ptr %17, align 8, !tbaa !5
  %108 = icmp ne ptr %107, null
  br i1 %108, label %109, label %113

109:                                              ; preds = %102
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = load ptr, ptr %17, align 8, !tbaa !5
  %112 = call i32 @sqlite3_prepare_v2(ptr noundef %110, ptr noundef %111, i32 noundef -1, ptr noundef %15, ptr noundef null)
  br label %114

113:                                              ; preds = %102
  br label %114

114:                                              ; preds = %113, %109
  %115 = phi i32 [ %112, %109 ], [ 7, %113 ]
  store i32 %115, ptr %18, align 4, !tbaa !9
  %116 = load ptr, ptr %17, align 8, !tbaa !5
  call void @sqlite3_free(ptr noundef %116)
  %117 = load i32, ptr %18, align 4, !tbaa !9
  %118 = icmp ne i32 %117, 0
  br i1 %118, label %119, label %120

119:                                              ; preds = %114
  store ptr null, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %211

120:                                              ; preds = %114
  %121 = load ptr, ptr %15, align 8, !tbaa !5
  %122 = call i32 @sqlite3_step(ptr noundef %121)
  store i32 %122, ptr %18, align 4, !tbaa !9
  %123 = load i32, ptr %18, align 4, !tbaa !9
  %124 = icmp ne i32 %123, 100
  br i1 %124, label %125, label %126

125:                                              ; preds = %120
  store ptr null, ptr %16, align 8, !tbaa !5
  br label %207

126:                                              ; preds = %120
  %127 = load ptr, ptr %15, align 8, !tbaa !5
  %128 = call i64 @sqlite3_column_int64(ptr noundef %127, i32 noundef 0)
  %129 = load i32, ptr %14, align 4, !tbaa !9
  %130 = sext i32 %129 to i64
  %131 = mul nsw i64 %128, %130
  store i64 %131, ptr %13, align 8, !tbaa !21
  %132 = load i64, ptr %13, align 8, !tbaa !21
  %133 = icmp eq i64 %132, 0
  br i1 %133, label %134, label %150

134:                                              ; preds = %126
  %135 = load ptr, ptr %15, align 8, !tbaa !5
  %136 = call i32 @sqlite3_reset(ptr noundef %135)
  %137 = load ptr, ptr %6, align 8, !tbaa !5
  %138 = call i32 @sqlite3_exec(ptr noundef %137, ptr noundef @.str.16, ptr noundef null, ptr noundef null, ptr noundef null)
  %139 = load ptr, ptr %15, align 8, !tbaa !5
  %140 = call i32 @sqlite3_step(ptr noundef %139)
  store i32 %140, ptr %18, align 4, !tbaa !9
  %141 = load i32, ptr %18, align 4, !tbaa !9
  %142 = icmp eq i32 %141, 100
  br i1 %142, label %143, label %149

143:                                              ; preds = %134
  %144 = load ptr, ptr %15, align 8, !tbaa !5
  %145 = call i64 @sqlite3_column_int64(ptr noundef %144, i32 noundef 0)
  %146 = load i32, ptr %14, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = mul nsw i64 %145, %147
  store i64 %148, ptr %13, align 8, !tbaa !21
  br label %149

149:                                              ; preds = %143, %134
  br label %150

150:                                              ; preds = %149, %126
  %151 = load ptr, ptr %8, align 8, !tbaa !5
  %152 = icmp ne ptr %151, null
  br i1 %152, label %153, label %156

153:                                              ; preds = %150
  %154 = load i64, ptr %13, align 8, !tbaa !21
  %155 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %154, ptr %155, align 8, !tbaa !21
  br label %156

156:                                              ; preds = %153, %150
  %157 = load i32, ptr %9, align 4, !tbaa !9
  %158 = and i32 %157, 1
  %159 = icmp ne i32 %158, 0
  br i1 %159, label %160, label %161

160:                                              ; preds = %156
  store ptr null, ptr %16, align 8, !tbaa !5
  br label %206

161:                                              ; preds = %156
  %162 = load i64, ptr %13, align 8, !tbaa !21
  %163 = call ptr @sqlite3_malloc64(i64 noundef %162)
  store ptr %163, ptr %16, align 8, !tbaa !5
  %164 = load ptr, ptr %16, align 8, !tbaa !5
  %165 = icmp ne ptr %164, null
  br i1 %165, label %166, label %205

166:                                              ; preds = %161
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %167 = load ptr, ptr %15, align 8, !tbaa !5
  %168 = call i32 @sqlite3_column_int(ptr noundef %167, i32 noundef 0)
  store i32 %168, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %169 = load ptr, ptr %12, align 8, !tbaa !5
  %170 = call ptr @sqlite3BtreePager(ptr noundef %169)
  store ptr %170, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  store i32 1, ptr %23, align 4, !tbaa !9
  br label %171

171:                                              ; preds = %201, %166
  %172 = load i32, ptr %23, align 4, !tbaa !9
  %173 = load i32, ptr %21, align 4, !tbaa !9
  %174 = icmp sle i32 %172, %173
  br i1 %174, label %175, label %204

175:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  store ptr null, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %176 = load ptr, ptr %16, align 8, !tbaa !5
  %177 = load i32, ptr %14, align 4, !tbaa !9
  %178 = sext i32 %177 to i64
  %179 = load i32, ptr %23, align 4, !tbaa !9
  %180 = sub nsw i32 %179, 1
  %181 = sext i32 %180 to i64
  %182 = mul nsw i64 %178, %181
  %183 = getelementptr inbounds i8, ptr %176, i64 %182
  store ptr %183, ptr %25, align 8, !tbaa !5
  %184 = load ptr, ptr %22, align 8, !tbaa !5
  %185 = load i32, ptr %23, align 4, !tbaa !9
  %186 = call i32 @sqlite3PagerGet(ptr noundef %184, i32 noundef %185, ptr noundef %24, i32 noundef 0)
  store i32 %186, ptr %18, align 4, !tbaa !9
  %187 = load i32, ptr %18, align 4, !tbaa !9
  %188 = icmp eq i32 %187, 0
  br i1 %188, label %189, label %195

189:                                              ; preds = %175
  %190 = load ptr, ptr %25, align 8, !tbaa !5
  %191 = load ptr, ptr %24, align 8, !tbaa !5
  %192 = call ptr @sqlite3PagerGetData(ptr noundef %191)
  %193 = load i32, ptr %14, align 4, !tbaa !9
  %194 = sext i32 %193 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %190, ptr align 1 %192, i64 %194, i1 false)
  br label %199

195:                                              ; preds = %175
  %196 = load ptr, ptr %25, align 8, !tbaa !5
  %197 = load i32, ptr %14, align 4, !tbaa !9
  %198 = sext i32 %197 to i64
  call void @llvm.memset.p0.i64(ptr align 1 %196, i8 0, i64 %198, i1 false)
  br label %199

199:                                              ; preds = %195, %189
  %200 = load ptr, ptr %24, align 8, !tbaa !5
  call void @sqlite3PagerUnref(ptr noundef %200)
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  br label %201

201:                                              ; preds = %199
  %202 = load i32, ptr %23, align 4, !tbaa !9
  %203 = add nsw i32 %202, 1
  store i32 %203, ptr %23, align 4, !tbaa !9
  br label %171, !llvm.loop !29

204:                                              ; preds = %171
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  br label %205

205:                                              ; preds = %204, %161
  br label %206

206:                                              ; preds = %205, %160
  br label %207

207:                                              ; preds = %206, %125
  %208 = load ptr, ptr %15, align 8, !tbaa !5
  %209 = call i32 @sqlite3_finalize(ptr noundef %208)
  %210 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %210, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %211

211:                                              ; preds = %207, %119, %101, %88, %49
  call void @llvm.lifetime.end.p0(i64 4, 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 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %212 = load ptr, ptr %5, align 8
  ret ptr %212
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3_step(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3_reset(ptr noundef) #1

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3_finalize(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: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 32}
!12 = !{!"sqlite3", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !13, i64 48, !13, i64 56, !13, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !7, i64 100, !7, i64 101, !7, i64 102, !7, i64 103, !7, i64 104, !7, i64 105, !7, i64 106, !7, i64 107, !7, i64 108, !7, i64 109, !7, i64 110, !7, i64 111, !7, i64 112, !7, i64 113, !10, i64 116, !13, i64 120, !13, i64 128, !7, i64 136, !10, i64 184, !14, i64 192, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !6, i64 232, !7, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !6, i64 392, !7, i64 400, !15, i64 408, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !10, i64 536, !10, i64 540, !17, i64 544, !6, i64 568, !6, i64 576, !6, i64 584, !17, i64 592, !17, i64 616, !18, i64 640, !7, i64 664, !6, i64 728, !10, i64 736, !10, i64 740, !10, i64 744, !10, i64 748, !13, i64 752, !13, i64 760, !6, i64 768, !6, i64 776}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"sqlite3InitInfo", !10, i64 0, !7, i64 4, !7, i64 5, !10, i64 6, !10, i64 6, !10, i64 6, !6, i64 8}
!15 = !{!"Lookaside", !10, i64 0, !16, i64 4, !16, i64 6, !7, i64 8, !10, i64 12, !7, i64 16, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!16 = !{!"short", !7, i64 0}
!17 = !{!"Hash", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16}
!18 = !{!"BusyHandler", !6, i64 0, !6, i64 8, !10, i64 16}
!19 = !{!20, !6, i64 0}
!20 = !{!"Db", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !6, i64 24}
!21 = !{!13, !13, i64 0}
!22 = !{!23, !6, i64 8}
!23 = !{!"MemFile", !24, i64 0, !6, i64 8, !10, i64 16}
!24 = !{!"sqlite3_file", !6, i64 0}
!25 = !{!26, !13, i64 0}
!26 = !{!"MemStore", !13, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !6, i64 64}
!27 = !{!26, !6, i64 24}
!28 = !{!20, !6, i64 8}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}


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

@.str.15 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [25 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @sqlite3_malloc64(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_free(ptr 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

; Function Attrs: nounwind uwtable
declare dso_local ptr @sqlite3_mprintf(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) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_serialize(ptr noundef %0, ptr noundef %1, ptr noundef writeonly %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store ptr null, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %1, null
  br i1 %7, label %8, label %12

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %10, align 8, !tbaa !18
  br label %12

12:                                               ; preds = %8, %4
  %.060 = phi ptr [ %11, %8 ], [ %1, %4 ]
  %13 = tail call ptr @memdbFromDbSchema(ptr noundef %0, ptr noundef %.060)
  %14 = tail call i32 @sqlite3FindDbName(ptr noundef %0, ptr noundef %.060)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %16, label %15

15:                                               ; preds = %12
  store i64 -1, ptr %2, align 8, !tbaa !20
  br label %16

16:                                               ; preds = %15, %12
  %17 = icmp slt i32 %14, 0
  br i1 %17, label %94, label %18

18:                                               ; preds = %16
  %.not76 = icmp eq ptr %13, null
  br i1 %.not76, label %36, label %19

19:                                               ; preds = %18
  %20 = getelementptr inbounds i8, ptr %13, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !21
  br i1 %.not, label %24, label %22

22:                                               ; preds = %19
  %23 = load i64, ptr %21, align 8, !tbaa !24
  store i64 %23, ptr %2, align 8, !tbaa !20
  br label %24

24:                                               ; preds = %22, %19
  %25 = and i32 %3, 1
  %.not83 = icmp eq i32 %25, 0
  br i1 %.not83, label %29, label %26

26:                                               ; preds = %24
  %27 = getelementptr inbounds i8, ptr %21, i64 24
  %28 = load ptr, ptr %27, align 8, !tbaa !26
  br label %94

29:                                               ; preds = %24
  %30 = load i64, ptr %21, align 8, !tbaa !24
  %31 = tail call ptr @sqlite3_malloc64(i64 noundef %30)
  %.not84 = icmp eq ptr %31, null
  br i1 %.not84, label %94, label %32

32:                                               ; preds = %29
  %33 = getelementptr inbounds i8, ptr %21, i64 24
  %34 = load ptr, ptr %33, align 8, !tbaa !26
  %35 = load i64, ptr %21, align 8, !tbaa !24
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %31, ptr align 1 %34, i64 %35, i1 false)
  br label %94

36:                                               ; preds = %18
  %37 = getelementptr inbounds i8, ptr %0, i64 32
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = zext nneg i32 %14 to i64
  %40 = getelementptr inbounds %struct.Db, ptr %38, i64 %39, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !27
  %42 = icmp eq ptr %41, null
  br i1 %42, label %94, label %43

43:                                               ; preds = %36
  %44 = tail call i32 @sqlite3BtreeGetPageSize(ptr noundef nonnull %41)
  %45 = tail call ptr (ptr, ...) @sqlite3_mprintf(ptr noundef nonnull @.str.15, ptr noundef %.060)
  %.not77 = icmp eq ptr %45, null
  br i1 %.not77, label %.critedge, label %46

46:                                               ; preds = %43
  %47 = call i32 @sqlite3_prepare_v2(ptr noundef nonnull %0, ptr noundef nonnull %45, i32 noundef -1, ptr noundef nonnull %5, ptr noundef null)
  %48 = icmp eq i32 %47, 0
  call void @sqlite3_free(ptr noundef nonnull %45)
  br i1 %48, label %49, label %94

.critedge:                                        ; preds = %43
  tail call void @sqlite3_free(ptr noundef null)
  br label %94

49:                                               ; preds = %46
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = call i32 @sqlite3_step(ptr noundef %50)
  %.not79 = icmp eq i32 %51, 100
  br i1 %.not79, label %52, label %.loopexit

52:                                               ; preds = %49
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = call i64 @sqlite3_column_int64(ptr noundef %53, i32 noundef 0)
  %55 = sext i32 %44 to i64
  %56 = mul nsw i64 %54, %55
  %57 = icmp eq i64 %56, 0
  br i1 %57, label %58, label %69

58:                                               ; preds = %52
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call i32 @sqlite3_reset(ptr noundef %59)
  %61 = call i32 @sqlite3_exec(ptr noundef nonnull %0, ptr noundef nonnull @.str.16, ptr noundef null, ptr noundef null, ptr noundef null)
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = call i32 @sqlite3_step(ptr noundef %62)
  %64 = icmp eq i32 %63, 100
  br i1 %64, label %65, label %69

65:                                               ; preds = %58
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = call i64 @sqlite3_column_int64(ptr noundef %66, i32 noundef 0)
  %68 = mul nsw i64 %67, %55
  br label %69

69:                                               ; preds = %58, %65, %52
  %.061 = phi i64 [ %68, %65 ], [ 0, %58 ], [ %56, %52 ]
  br i1 %.not, label %71, label %70

70:                                               ; preds = %69
  store i64 %.061, ptr %2, align 8, !tbaa !20
  br label %71

71:                                               ; preds = %70, %69
  %72 = and i32 %3, 1
  %.not80 = icmp eq i32 %72, 0
  br i1 %.not80, label %73, label %.loopexit

73:                                               ; preds = %71
  %74 = call ptr @sqlite3_malloc64(i64 noundef %.061)
  %.not81 = icmp eq ptr %74, null
  br i1 %.not81, label %.loopexit, label %75

75:                                               ; preds = %73
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = call i32 @sqlite3_column_int(ptr noundef %76, i32 noundef 0)
  %78 = call ptr @sqlite3BtreePager(ptr noundef nonnull %41)
  %.not8285 = icmp slt i32 %77, 1
  br i1 %.not8285, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %75
  %79 = add nuw i32 %77, 1
  %wide.trip.count = zext i32 %79 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %90
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %90 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  store ptr null, ptr %6, align 8, !tbaa !5
  %80 = add nsw i64 %indvars.iv, -1
  %81 = mul nsw i64 %80, %55
  %82 = getelementptr inbounds i8, ptr %74, i64 %81
  %83 = trunc nuw nsw i64 %indvars.iv to i32
  %84 = call i32 @sqlite3PagerGet(ptr noundef %78, i32 noundef %83, ptr noundef nonnull %6, i32 noundef 0)
  %85 = icmp eq i32 %84, 0
  br i1 %85, label %86, label %89

86:                                               ; preds = %.lr.ph
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = call ptr @sqlite3PagerGetData(ptr noundef %87)
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %82, ptr align 1 %88, i64 %55, i1 false)
  br label %90

89:                                               ; preds = %.lr.ph
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %82, i8 0, i64 %55, i1 false)
  br label %90

90:                                               ; preds = %89, %86
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  call void @sqlite3PagerUnref(ptr noundef %91)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !28

.loopexit:                                        ; preds = %90, %75, %71, %49, %73
  %.1 = phi ptr [ null, %73 ], [ null, %49 ], [ null, %71 ], [ %74, %75 ], [ %74, %90 ]
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = call i32 @sqlite3_finalize(ptr noundef %92)
  br label %94

94:                                               ; preds = %46, %.critedge, %36, %26, %32, %29, %16, %.loopexit
  %.0 = phi ptr [ %.1, %.loopexit ], [ null, %16 ], [ %28, %26 ], [ %31, %32 ], [ null, %29 ], [ null, %36 ], [ null, %.critedge ], [ null, %46 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret ptr %.0
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !6, i64 32}
!10 = !{!"sqlite3", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !12, i64 48, !12, i64 56, !12, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !7, i64 100, !7, i64 101, !7, i64 102, !7, i64 103, !7, i64 104, !7, i64 105, !7, i64 106, !7, i64 107, !7, i64 108, !7, i64 109, !7, i64 110, !7, i64 111, !7, i64 112, !7, i64 113, !11, i64 116, !12, i64 120, !12, i64 128, !7, i64 136, !11, i64 184, !13, i64 192, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220, !11, i64 224, !11, i64 228, !6, i64 232, !7, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !6, i64 392, !7, i64 400, !14, i64 408, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !11, i64 536, !11, i64 540, !16, i64 544, !6, i64 568, !6, i64 576, !6, i64 584, !16, i64 592, !16, i64 616, !17, i64 640, !7, i64 664, !6, i64 728, !11, i64 736, !11, i64 740, !11, i64 744, !11, i64 748, !12, i64 752, !12, i64 760, !6, i64 768, !6, i64 776}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"sqlite3InitInfo", !11, i64 0, !7, i64 4, !7, i64 5, !11, i64 6, !11, i64 6, !11, i64 6, !6, i64 8}
!14 = !{!"Lookaside", !11, i64 0, !15, i64 4, !15, i64 6, !7, i64 8, !11, i64 12, !7, i64 16, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!15 = !{!"short", !7, i64 0}
!16 = !{!"Hash", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!17 = !{!"BusyHandler", !6, i64 0, !6, i64 8, !11, i64 16}
!18 = !{!19, !6, i64 0}
!19 = !{!"Db", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !6, i64 24}
!20 = !{!12, !12, i64 0}
!21 = !{!22, !6, i64 8}
!22 = !{!"MemFile", !23, i64 0, !6, i64 8, !11, i64 16}
!23 = !{!"sqlite3_file", !6, i64 0}
!24 = !{!25, !12, i64 0}
!25 = !{!"MemStore", !12, i64 0, !12, i64 8, !12, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !6, i64 64}
!26 = !{!25, !6, i64 24}
!27 = !{!19, !6, i64 8}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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