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

; 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.Table = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i16, i16, i16, i16, i8, i32, i32, ptr, ptr, ptr, ptr, ptr }
%struct.Index = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i16, i16, i16, i8, i8 }
%struct.Parse = type { ptr, ptr, ptr, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, ptr, %struct.Token, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i8, i8, i8, [10 x %struct.yColCache], [8 x i32], %struct.Token, %struct.Token, i16, i8, i8, i8, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, %struct.Token, ptr, ptr, ptr, ptr, ptr }
%struct.yColCache = type { i32, i16, i8, i32, i32, i32 }
%struct.Token = type { ptr, i32 }

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

declare ptr @sqlite3GetVdbe(ptr noundef) #1

declare i32 @sqlite3VdbeAddOp4Int(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

declare i32 @sqlite3VdbeAddOp3(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; 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 dso_local void @sqlite3TableAffinity(ptr noundef, ptr noundef, i32 noundef) #2

declare i32 @sqlite3VdbeCurrentAddr(ptr noundef) #1

declare i32 @sqlite3GetTempReg(ptr noundef) #1

declare i32 @sqlite3VdbeAddOp2(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #1

declare void @sqlite3VdbeChangeP5(ptr noundef, i16 noundef zeroext) #1

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

32:                                               ; preds = %127, %9
  %33 = load ptr, ptr %20, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %133

35:                                               ; preds = %32
  %36 = load ptr, ptr %15, align 8, !tbaa !5
  %37 = load i32, ptr %24, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds i32, ptr %36, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %35
  br label %127

43:                                               ; preds = %35
  store i8 1, ptr %25, align 1, !tbaa !11
  %44 = load ptr, ptr %20, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Index, ptr %44, i32 0, i32 9
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %59

48:                                               ; preds = %43
  %49 = load ptr, ptr %19, align 8, !tbaa !5
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = load i32, ptr %24, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i32, ptr %50, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !9
  %55 = load ptr, ptr %19, align 8, !tbaa !5
  %56 = call i32 @sqlite3VdbeCurrentAddr(ptr noundef %55)
  %57 = add nsw i32 %56, 2
  %58 = call i32 @sqlite3VdbeAddOp2(ptr noundef %49, i32 noundef 34, i32 noundef %54, i32 noundef %57)
  br label %59

59:                                               ; preds = %48, %43
  %60 = load i32, ptr %18, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  %62 = zext i1 %61 to i64
  %63 = select i1 %61, i32 16, i32 0
  %64 = trunc i32 %63 to i8
  store i8 %64, ptr %21, align 1, !tbaa !11
  %65 = load ptr, ptr %20, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Index, ptr %65, i32 0, i32 16
  %67 = load i8, ptr %66, align 1
  %68 = and i8 %67, 3
  %69 = zext i8 %68 to i32
  %70 = icmp eq i32 %69, 2
  br i1 %70, label %71, label %88

71:                                               ; preds = %59
  %72 = load ptr, ptr %11, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.Table, ptr %72, i32 0, i32 9
  %74 = load i32, ptr %73, align 8, !tbaa !17
  %75 = and i32 %74, 32
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %88, label %77

77:                                               ; preds = %71
  %78 = load i8, ptr %21, align 1, !tbaa !11
  %79 = zext i8 %78 to i32
  %80 = or i32 %79, 1
  %81 = trunc i32 %80 to i8
  store i8 %81, ptr %21, align 1, !tbaa !11
  %82 = load i32, ptr %16, align 4, !tbaa !9
  %83 = and i32 %82, 2
  %84 = load i8, ptr %21, align 1, !tbaa !11
  %85 = zext i8 %84 to i32
  %86 = or i32 %85, %83
  %87 = trunc i32 %86 to i8
  store i8 %87, ptr %21, align 1, !tbaa !11
  br label %88

88:                                               ; preds = %77, %71, %59
  %89 = load ptr, ptr %19, align 8, !tbaa !5
  %90 = load i32, ptr %13, align 4, !tbaa !9
  %91 = load i32, ptr %24, align 4, !tbaa !9
  %92 = add nsw i32 %90, %91
  %93 = load ptr, ptr %15, align 8, !tbaa !5
  %94 = load i32, ptr %24, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds i32, ptr %93, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !9
  %98 = load ptr, ptr %15, align 8, !tbaa !5
  %99 = load i32, ptr %24, align 4, !tbaa !9
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds i32, ptr %98, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !9
  %103 = add nsw i32 %102, 1
  %104 = load ptr, ptr %20, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.Index, ptr %104, i32 0, i32 16
  %106 = load i8, ptr %105, align 1
  %107 = lshr i8 %106, 3
  %108 = and i8 %107, 1
  %109 = zext i8 %108 to i32
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %116

111:                                              ; preds = %88
  %112 = load ptr, ptr %20, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.Index, ptr %112, i32 0, i32 13
  %114 = load i16, ptr %113, align 2, !tbaa !18
  %115 = zext i16 %114 to i32
  br label %121

116:                                              ; preds = %88
  %117 = load ptr, ptr %20, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.Index, ptr %117, i32 0, i32 14
  %119 = load i16, ptr %118, align 8, !tbaa !19
  %120 = zext i16 %119 to i32
  br label %121

121:                                              ; preds = %116, %111
  %122 = phi i32 [ %115, %111 ], [ %120, %116 ]
  %123 = call i32 @sqlite3VdbeAddOp4Int(ptr noundef %89, i32 noundef 126, i32 noundef %92, i32 noundef %97, i32 noundef %103, i32 noundef %122)
  %124 = load ptr, ptr %19, align 8, !tbaa !5
  %125 = load i8, ptr %21, align 1, !tbaa !11
  %126 = zext i8 %125 to i16
  call void @sqlite3VdbeChangeP5(ptr noundef %124, i16 noundef zeroext %126)
  br label %127

127:                                              ; preds = %121, %42
  %128 = load ptr, ptr %20, align 8, !tbaa !5
  %129 = getelementptr inbounds %struct.Index, ptr %128, i32 0, i32 5
  %130 = load ptr, ptr %129, align 8, !tbaa !20
  store ptr %130, ptr %20, align 8, !tbaa !5
  %131 = load i32, ptr %24, align 4, !tbaa !9
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %24, align 4, !tbaa !9
  br label %32, !llvm.loop !21

133:                                              ; preds = %32
  %134 = load ptr, ptr %11, align 8, !tbaa !5
  %135 = getelementptr inbounds %struct.Table, ptr %134, i32 0, i32 9
  %136 = load i32, ptr %135, align 8, !tbaa !17
  %137 = and i32 %136, 32
  %138 = icmp eq i32 %137, 0
  br i1 %138, label %140, label %139

139:                                              ; preds = %133
  store i32 1, ptr %26, align 4
  br label %215

140:                                              ; preds = %133
  %141 = load i32, ptr %14, align 4, !tbaa !9
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %22, align 4, !tbaa !9
  %143 = load ptr, ptr %10, align 8, !tbaa !5
  %144 = call i32 @sqlite3GetTempReg(ptr noundef %143)
  store i32 %144, ptr %23, align 4, !tbaa !9
  %145 = load ptr, ptr %19, align 8, !tbaa !5
  %146 = load i32, ptr %22, align 4, !tbaa !9
  %147 = load ptr, ptr %11, align 8, !tbaa !5
  %148 = getelementptr inbounds %struct.Table, ptr %147, i32 0, i32 11
  %149 = load i16, ptr %148, align 2, !tbaa !23
  %150 = sext i16 %149 to i32
  %151 = load i32, ptr %23, align 4, !tbaa !9
  %152 = call i32 @sqlite3VdbeAddOp3(ptr noundef %145, i32 noundef 100, i32 noundef %146, i32 noundef %150, i32 noundef %151)
  %153 = load i8, ptr %25, align 1, !tbaa !11
  %154 = icmp ne i8 %153, 0
  br i1 %154, label %164, label %155

155:                                              ; preds = %140
  %156 = load ptr, ptr %19, align 8, !tbaa !5
  %157 = load ptr, ptr %11, align 8, !tbaa !5
  call void @sqlite3TableAffinity(ptr noundef %156, ptr noundef %157, i32 noundef 0)
  %158 = load ptr, ptr %10, align 8, !tbaa !5
  %159 = load i32, ptr %22, align 4, !tbaa !9
  %160 = load ptr, ptr %11, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.Table, ptr %160, i32 0, i32 11
  %162 = load i16, ptr %161, align 2, !tbaa !23
  %163 = sext i16 %162 to i32
  call void @sqlite3ExprCacheAffinityChange(ptr noundef %158, i32 noundef %159, i32 noundef %163)
  br label %164

164:                                              ; preds = %155, %140
  %165 = load ptr, ptr %10, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.Parse, ptr %165, i32 0, i32 6
  %167 = load i8, ptr %166, align 2, !tbaa !24
  %168 = icmp ne i8 %167, 0
  br i1 %168, label %169, label %170

169:                                              ; preds = %164
  store i8 0, ptr %21, align 1, !tbaa !11
  br label %182

170:                                              ; preds = %164
  store i8 1, ptr %21, align 1, !tbaa !11
  %171 = load i32, ptr %16, align 4, !tbaa !9
  %172 = icmp ne i32 %171, 0
  br i1 %172, label %173, label %175

173:                                              ; preds = %170
  %174 = load i32, ptr %16, align 4, !tbaa !9
  br label %176

175:                                              ; preds = %170
  br label %176

176:                                              ; preds = %175, %173
  %177 = phi i32 [ %174, %173 ], [ 32, %175 ]
  %178 = load i8, ptr %21, align 1, !tbaa !11
  %179 = zext i8 %178 to i32
  %180 = or i32 %179, %177
  %181 = trunc i32 %180 to i8
  store i8 %181, ptr %21, align 1, !tbaa !11
  br label %182

182:                                              ; preds = %176, %169
  %183 = load i32, ptr %17, align 4, !tbaa !9
  %184 = icmp ne i32 %183, 0
  br i1 %184, label %185, label %190

185:                                              ; preds = %182
  %186 = load i8, ptr %21, align 1, !tbaa !11
  %187 = zext i8 %186 to i32
  %188 = or i32 %187, 8
  %189 = trunc i32 %188 to i8
  store i8 %189, ptr %21, align 1, !tbaa !11
  br label %190

190:                                              ; preds = %185, %182
  %191 = load i32, ptr %18, align 4, !tbaa !9
  %192 = icmp ne i32 %191, 0
  br i1 %192, label %193, label %198

193:                                              ; preds = %190
  %194 = load i8, ptr %21, align 1, !tbaa !11
  %195 = zext i8 %194 to i32
  %196 = or i32 %195, 16
  %197 = trunc i32 %196 to i8
  store i8 %197, ptr %21, align 1, !tbaa !11
  br label %198

198:                                              ; preds = %193, %190
  %199 = load ptr, ptr %19, align 8, !tbaa !5
  %200 = load i32, ptr %12, align 4, !tbaa !9
  %201 = load i32, ptr %23, align 4, !tbaa !9
  %202 = load i32, ptr %14, align 4, !tbaa !9
  %203 = call i32 @sqlite3VdbeAddOp3(ptr noundef %199, i32 noundef 116, i32 noundef %200, i32 noundef %201, i32 noundef %202)
  %204 = load ptr, ptr %10, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.Parse, ptr %204, i32 0, i32 6
  %206 = load i8, ptr %205, align 2, !tbaa !24
  %207 = icmp ne i8 %206, 0
  br i1 %207, label %211, label %208

208:                                              ; preds = %198
  %209 = load ptr, ptr %19, align 8, !tbaa !5
  %210 = load ptr, ptr %11, align 8, !tbaa !5
  call void @sqlite3VdbeAppendP4(ptr noundef %209, ptr noundef %210, i32 noundef -15)
  br label %211

211:                                              ; preds = %208, %198
  %212 = load ptr, ptr %19, align 8, !tbaa !5
  %213 = load i8, ptr %21, align 1, !tbaa !11
  %214 = zext i8 %213 to i16
  call void @sqlite3VdbeChangeP5(ptr noundef %212, i16 noundef zeroext %214)
  store i32 0, ptr %26, align 4
  br label %215

215:                                              ; preds = %211, %139
  call void @llvm.lifetime.end.p0(i64 1, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  %216 = load i32, ptr %26, align 4
  switch i32 %216, label %218 [
    i32 0, label %217
    i32 1, label %217
  ]

217:                                              ; preds = %215, %215
  ret void

218:                                              ; preds = %215
  unreachable
}

declare void @sqlite3VdbeAppendP4(ptr noundef, ptr noundef, i32 noundef) #1

declare void @sqlite3ExprCacheAffinityChange(ptr noundef, i32 noundef, i32 noundef) #1

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 16}
!13 = !{!"Table", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !14, i64 68, !14, i64 70, !14, i64 72, !14, i64 74, !7, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !6, i64 72}
!16 = !{!"Index", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !14, i64 92, !14, i64 94, !14, i64 96, !7, i64 98, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99}
!17 = !{!13, !10, i64 64}
!18 = !{!16, !14, i64 94}
!19 = !{!16, !14, i64 96}
!20 = !{!16, !6, i64 40}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!13, !14, i64 70}
!24 = !{!25, !7, i64 30}
!25 = !{!"Parse", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !7, i64 28, !7, i64 29, !7, i64 30, !7, i64 31, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !7, i64 36, !7, i64 37, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !26, i64 104, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !7, i64 192, !7, i64 193, !7, i64 194, !7, i64 196, !7, i64 396, !26, i64 432, !26, i64 448, !14, i64 464, !7, i64 466, !7, i64 467, !7, i64 468, !10, i64 472, !10, i64 476, !10, i64 480, !10, i64 484, !6, i64 488, !6, i64 496, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !26, i64 536, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584}
!26 = !{!"Token", !6, i64 0, !10, i64 8}


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

declare ptr @sqlite3GetVdbe(ptr noundef) local_unnamed_addr #0

declare i32 @sqlite3VdbeAddOp4Int(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare i32 @sqlite3VdbeAddOp3(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

declare i32 @sqlite3VdbeCurrentAddr(ptr noundef) local_unnamed_addr #0

declare i32 @sqlite3GetTempReg(ptr noundef) local_unnamed_addr #0

declare i32 @sqlite3VdbeAddOp2(ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

declare void @sqlite3VdbeChangeP5(ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @sqlite3CompleteInsertion(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef readonly %5, i32 noundef %6, i32 noundef %7, i32 noundef %8) local_unnamed_addr #1 {
  %10 = tail call ptr @sqlite3GetVdbe(ptr noundef %0) #2
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  %.06073 = load ptr, ptr %11, align 8, !tbaa !5
  %.not74 = icmp eq ptr %.06073, null
  br i1 %.not74, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9
  %.not71 = icmp eq i32 %8, 0
  %12 = select i1 %.not71, i8 0, i8 16
  %13 = getelementptr inbounds i8, ptr %1, i64 64
  %14 = trunc i32 %6 to i8
  %15 = and i8 %14, 2
  %16 = or disjoint i8 %15, %12
  %17 = or disjoint i8 %16, 1
  br label %18

18:                                               ; preds = %.lr.ph, %47
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %47 ]
  %.06077 = phi ptr [ %.06073, %.lr.ph ], [ %.060, %47 ]
  %.076 = phi i8 [ 0, %.lr.ph ], [ %.1, %47 ]
  %19 = getelementptr inbounds i32, ptr %5, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %47, label %22

22:                                               ; preds = %18
  %23 = getelementptr inbounds i8, ptr %.06077, i64 72
  %24 = load ptr, ptr %23, align 8, !tbaa !11
  %.not70 = icmp eq ptr %24, null
  br i1 %.not70, label %29, label %25

25:                                               ; preds = %22
  %26 = tail call i32 @sqlite3VdbeCurrentAddr(ptr noundef %10) #2
  %27 = add nsw i32 %26, 2
  %28 = tail call i32 @sqlite3VdbeAddOp2(ptr noundef %10, i32 noundef 34, i32 noundef %20, i32 noundef %27) #2
  br label %29

29:                                               ; preds = %25, %22
  %30 = getelementptr inbounds i8, ptr %.06077, i64 99
  %31 = load i8, ptr %30, align 1
  %32 = and i8 %31, 3
  %33 = icmp eq i8 %32, 2
  br i1 %33, label %34, label %38

34:                                               ; preds = %29
  %35 = load i32, ptr %13, align 8, !tbaa !14
  %36 = and i32 %35, 32
  %37 = icmp eq i32 %36, 0
  %spec.select = select i1 %37, i8 %12, i8 %17
  br label %38

38:                                               ; preds = %34, %29
  %.061 = phi i8 [ %12, %29 ], [ %spec.select, %34 ]
  %39 = load i32, ptr %19, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  %41 = and i8 %31, 8
  %.not72 = icmp eq i8 %41, 0
  %.in.in.v = select i1 %.not72, i64 96, i64 94
  %.in.in = getelementptr inbounds i8, ptr %.06077, i64 %.in.in.v
  %.in = load i16, ptr %.in.in, align 2, !tbaa !16
  %42 = zext i16 %.in to i32
  %43 = trunc i64 %indvars.iv to i32
  %44 = add i32 %43, %3
  %45 = tail call i32 @sqlite3VdbeAddOp4Int(ptr noundef %10, i32 noundef 126, i32 noundef %44, i32 noundef %39, i32 noundef %40, i32 noundef %42) #2
  %46 = zext nneg i8 %.061 to i16
  tail call void @sqlite3VdbeChangeP5(ptr noundef %10, i16 noundef zeroext %46) #2
  br label %47

47:                                               ; preds = %18, %38
  %.1 = phi i8 [ %.076, %18 ], [ 1, %38 ]
  %48 = getelementptr inbounds i8, ptr %.06077, i64 40
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.060 = load ptr, ptr %48, align 8, !tbaa !5
  %.not = icmp eq ptr %.060, null
  br i1 %.not, label %._crit_edge.loopexit, label %18, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %47
  %49 = icmp eq i8 %.1, 0
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %9
  %.0.lcssa = phi i1 [ true, %9 ], [ %49, %._crit_edge.loopexit ]
  %50 = getelementptr inbounds i8, ptr %1, i64 64
  %51 = load i32, ptr %50, align 8, !tbaa !14
  %52 = and i32 %51, 32
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %77

54:                                               ; preds = %._crit_edge
  %55 = add nsw i32 %4, 1
  %56 = tail call i32 @sqlite3GetTempReg(ptr noundef %0) #2
  %57 = getelementptr inbounds i8, ptr %1, i64 70
  %58 = load i16, ptr %57, align 2, !tbaa !19
  %59 = sext i16 %58 to i32
  %60 = tail call i32 @sqlite3VdbeAddOp3(ptr noundef %10, i32 noundef 100, i32 noundef %55, i32 noundef %59, i32 noundef %56) #2
  br i1 %.0.lcssa, label %61, label %64

61:                                               ; preds = %54
  tail call void @sqlite3TableAffinity(ptr noundef %10, ptr noundef nonnull %1, i32 noundef 0)
  %62 = load i16, ptr %57, align 2, !tbaa !19
  %63 = sext i16 %62 to i32
  tail call void @sqlite3ExprCacheAffinityChange(ptr noundef %0, i32 noundef %55, i32 noundef %63) #2
  br label %64

64:                                               ; preds = %61, %54
  %65 = getelementptr inbounds i8, ptr %0, i64 30
  %66 = load i8, ptr %65, align 2, !tbaa !20
  %.not65 = icmp eq i8 %66, 0
  %.not66 = icmp eq i32 %6, 0
  %67 = trunc i32 %6 to i8
  %68 = or i8 %67, 1
  %69 = select i1 %.not66, i8 33, i8 %68
  %.162 = select i1 %.not65, i8 %69, i8 0
  %.not67 = icmp eq i32 %7, 0
  %70 = or i8 %.162, 8
  %.2 = select i1 %.not67, i8 %.162, i8 %70
  %.not68 = icmp eq i32 %8, 0
  %71 = or i8 %.2, 16
  %.3 = select i1 %.not68, i8 %.2, i8 %71
  %72 = tail call i32 @sqlite3VdbeAddOp3(ptr noundef %10, i32 noundef 116, i32 noundef %2, i32 noundef %56, i32 noundef %4) #2
  %73 = load i8, ptr %65, align 2, !tbaa !20
  %.not69 = icmp eq i8 %73, 0
  br i1 %.not69, label %74, label %75

74:                                               ; preds = %64
  tail call void @sqlite3VdbeAppendP4(ptr noundef %10, ptr noundef nonnull %1, i32 noundef -15) #2
  br label %75

75:                                               ; preds = %74, %64
  %76 = zext i8 %.3 to i16
  tail call void @sqlite3VdbeChangeP5(ptr noundef %10, i16 noundef zeroext %76) #2
  br label %77

77:                                               ; preds = %._crit_edge, %75
  ret void
}

declare void @sqlite3VdbeAppendP4(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

declare void @sqlite3ExprCacheAffinityChange(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

attributes #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 #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 = { 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 72}
!12 = !{!"Index", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !13, i64 92, !13, i64 94, !13, i64 96, !7, i64 98, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99, !10, i64 99}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !10, i64 64}
!15 = !{!"Table", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !13, i64 68, !13, i64 70, !13, i64 72, !13, i64 74, !7, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!15, !13, i64 70}
!20 = !{!21, !7, i64 30}
!21 = !{!"Parse", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !7, i64 28, !7, i64 29, !7, i64 30, !7, i64 31, !7, i64 32, !7, i64 33, !7, i64 34, !7, i64 35, !7, i64 36, !7, i64 37, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !6, i64 88, !6, i64 96, !22, i64 104, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !7, i64 192, !7, i64 193, !7, i64 194, !7, i64 196, !7, i64 396, !22, i64 432, !22, i64 448, !13, i64 464, !7, i64 466, !7, i64 467, !7, i64 468, !10, i64 472, !10, i64 476, !10, i64 480, !10, i64 484, !6, i64 488, !6, i64 496, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !22, i64 536, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584}
!22 = !{!"Token", !6, i64 0, !10, i64 8}


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