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

; 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.Vdbe = type { ptr, ptr, ptr, ptr, i16, i32, i32, i32, i32, i32, i32, i32, i32, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i32, i16, i8, i8, i16, i32, i32, [5 x i32], ptr, ptr, ptr, ptr, i32, i32, ptr, ptr }
%struct.SubProgram = type { ptr, i32, i32, i32, ptr, ptr, ptr }

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

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

declare void @sqlite3DbFree(ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @sqlite3VdbeClearObject(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.Vdbe, ptr %7, i32 0, i32 20
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.Vdbe, ptr %10, i32 0, i32 28
  %12 = load i16, ptr %11, align 4, !tbaa !14
  %13 = zext i16 %12 to i32
  %14 = mul nsw i32 %13, 2
  call void @releaseMemArray(ptr noundef %9, i32 noundef %14)
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.Vdbe, ptr %15, i32 0, i32 41
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  store ptr %17, ptr %5, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %34, %2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %36

21:                                               ; preds = %18
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.SubProgram, ptr %22, i32 0, i32 6
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  store ptr %24, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.SubProgram, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.SubProgram, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 8, !tbaa !19
  call void @vdbeFreeOpArray(ptr noundef %25, ptr noundef %28, i32 noundef %31)
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  call void @sqlite3DbFree(ptr noundef %32, ptr noundef %33)
  br label %34

34:                                               ; preds = %21
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %35, ptr %5, align 8, !tbaa !5
  br label %18, !llvm.loop !20

36:                                               ; preds = %18
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Vdbe, ptr %37, i32 0, i32 5
  %39 = load i32, ptr %38, align 4, !tbaa !22
  %40 = icmp ne i32 %39, 381479589
  br i1 %40, label %41, label %57

41:                                               ; preds = %36
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Vdbe, ptr %42, i32 0, i32 24
  %44 = load ptr, ptr %43, align 8, !tbaa !23
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.Vdbe, ptr %45, i32 0, i32 4
  %47 = load i16, ptr %46, align 8, !tbaa !24
  %48 = sext i16 %47 to i32
  call void @releaseMemArray(ptr noundef %44, i32 noundef %48)
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Vdbe, ptr %50, i32 0, i32 25
  %52 = load ptr, ptr %51, align 8, !tbaa !25
  call void @sqlite3DbFree(ptr noundef %49, ptr noundef %52)
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.Vdbe, ptr %54, i32 0, i32 36
  %56 = load ptr, ptr %55, align 8, !tbaa !26
  call void @sqlite3DbFree(ptr noundef %53, ptr noundef %56)
  br label %57

57:                                               ; preds = %41, %36
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Vdbe, ptr %59, i32 0, i32 17
  %61 = load ptr, ptr %60, align 8, !tbaa !27
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.Vdbe, ptr %62, i32 0, i32 27
  %64 = load i32, ptr %63, align 8, !tbaa !28
  call void @vdbeFreeOpArray(ptr noundef %58, ptr noundef %61, i32 noundef %64)
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Vdbe, ptr %66, i32 0, i32 20
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  call void @sqlite3DbFree(ptr noundef %65, ptr noundef %68)
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Vdbe, ptr %70, i32 0, i32 35
  %72 = load ptr, ptr %71, align 8, !tbaa !29
  call void @sqlite3DbFree(ptr noundef %69, ptr noundef %72)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 128}
!10 = !{!"Vdbe", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !12, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !13, i64 176, !12, i64 184, !11, i64 188, !7, i64 190, !7, i64 191, !12, i64 192, !12, i64 192, !12, i64 192, !12, i64 192, !12, i64 192, !12, i64 192, !12, i64 192, !12, i64 193, !12, i64 193, !12, i64 196, !12, i64 200, !7, i64 204, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !12, i64 256, !12, i64 260, !6, i64 264, !6, i64 272}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = !{!10, !11, i64 188}
!15 = !{!10, !6, i64 264}
!16 = !{!17, !6, i64 40}
!17 = !{!"SubProgram", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!18 = !{!17, !6, i64 0}
!19 = !{!17, !12, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!10, !12, i64 36}
!23 = !{!10, !6, i64 160}
!24 = !{!10, !11, i64 32}
!25 = !{!10, !6, i64 168}
!26 = !{!10, !6, i64 232}
!27 = !{!10, !6, i64 104}
!28 = !{!10, !12, i64 184}
!29 = !{!10, !6, i64 224}


; 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 void @sqlite3DbFree(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @sqlite3VdbeClearObject(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %1, i64 128
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 188
  %6 = load i16, ptr %5, align 4, !tbaa !13
  %7 = zext i16 %6 to i32
  %8 = shl nuw nsw i32 %7, 1
  tail call void @releaseMemArray(ptr noundef %4, i32 noundef %8)
  %9 = getelementptr inbounds i8, ptr %1, i64 264
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %.not26 = icmp eq ptr %10, null
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.027 = phi ptr [ %12, %.lr.ph ], [ %10, %2 ]
  %11 = getelementptr inbounds i8, ptr %.027, i64 40
  %12 = load ptr, ptr %11, align 8, !tbaa !15
  %13 = load ptr, ptr %.027, align 8, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %.027, i64 8
  %15 = load i32, ptr %14, align 8, !tbaa !18
  tail call void @vdbeFreeOpArray(ptr noundef %0, ptr noundef %13, i32 noundef %15)
  tail call void @sqlite3DbFree(ptr noundef %0, ptr noundef nonnull %.027) #2
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %2
  %16 = getelementptr inbounds i8, ptr %1, i64 36
  %17 = load i32, ptr %16, align 4, !tbaa !21
  %.not25 = icmp eq i32 %17, 381479589
  br i1 %.not25, label %28, label %18

18:                                               ; preds = %._crit_edge
  %19 = getelementptr inbounds i8, ptr %1, i64 160
  %20 = load ptr, ptr %19, align 8, !tbaa !22
  %21 = getelementptr inbounds i8, ptr %1, i64 32
  %22 = load i16, ptr %21, align 8, !tbaa !23
  %23 = sext i16 %22 to i32
  tail call void @releaseMemArray(ptr noundef %20, i32 noundef %23)
  %24 = getelementptr inbounds i8, ptr %1, i64 168
  %25 = load ptr, ptr %24, align 8, !tbaa !24
  tail call void @sqlite3DbFree(ptr noundef %0, ptr noundef %25) #2
  %26 = getelementptr inbounds i8, ptr %1, i64 232
  %27 = load ptr, ptr %26, align 8, !tbaa !25
  tail call void @sqlite3DbFree(ptr noundef %0, ptr noundef %27) #2
  br label %28

28:                                               ; preds = %18, %._crit_edge
  %29 = getelementptr inbounds i8, ptr %1, i64 104
  %30 = load ptr, ptr %29, align 8, !tbaa !26
  %31 = getelementptr inbounds i8, ptr %1, i64 184
  %32 = load i32, ptr %31, align 8, !tbaa !27
  tail call void @vdbeFreeOpArray(ptr noundef %0, ptr noundef %30, i32 noundef %32)
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  tail call void @sqlite3DbFree(ptr noundef %0, ptr noundef %33) #2
  %34 = getelementptr inbounds i8, ptr %1, i64 224
  %35 = load ptr, ptr %34, align 8, !tbaa !28
  tail call void @sqlite3DbFree(ptr noundef %0, ptr noundef %35) #2
  ret void
}

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

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, !7, i64 128}
!6 = !{!"Vdbe", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !7, i64 144, !7, i64 152, !7, i64 160, !7, i64 168, !12, i64 176, !11, i64 184, !10, i64 188, !8, i64 190, !8, i64 191, !11, i64 192, !11, i64 192, !11, i64 192, !11, i64 192, !11, i64 192, !11, i64 192, !11, i64 192, !11, i64 193, !11, i64 193, !11, i64 196, !11, i64 200, !8, i64 204, !7, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !11, i64 256, !11, i64 260, !7, i64 264, !7, i64 272}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!6, !10, i64 188}
!14 = !{!6, !7, i64 264}
!15 = !{!16, !7, i64 40}
!16 = !{!"SubProgram", !7, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!17 = !{!16, !7, i64 0}
!18 = !{!16, !11, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!6, !11, i64 36}
!22 = !{!6, !7, i64 160}
!23 = !{!6, !10, i64 32}
!24 = !{!6, !7, i64 168}
!25 = !{!6, !7, i64 232}
!26 = !{!6, !7, i64 104}
!27 = !{!6, !11, i64 184}
!28 = !{!6, !7, i64 224}


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