; 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.__va_list_tag = type { i32, i32, ptr, ptr }
%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.VtabCtx = type { ptr, ptr, ptr, i32 }
%struct.VTable = type { ptr, ptr, ptr, i32, i8, i8, i8, i32, ptr }

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_mutex_enter(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_mutex_leave(ptr 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: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #2

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

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

16:                                               ; preds = %2
  %17 = call i32 @sqlite3MisuseError(i32 noundef 157702)
  store i32 %17, ptr %6, align 4, !tbaa !9
  br label %62

18:                                               ; preds = %2
  %19 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %5, i64 0, i64 0
  call void @llvm.va_start.p0(ptr %19)
  %20 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %20, label %58 [
    i32 1, label %21
    i32 2, label %43
    i32 3, label %48
    i32 4, label %53
  ]

21:                                               ; preds = %18
  %22 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %5, i64 0, i64 0
  %23 = getelementptr inbounds %struct.__va_list_tag, ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 16
  %25 = icmp ule i32 %24, 40
  br i1 %25, label %26, label %31

26:                                               ; preds = %21
  %27 = getelementptr inbounds %struct.__va_list_tag, ptr %22, i32 0, i32 3
  %28 = load ptr, ptr %27, align 16
  %29 = getelementptr i8, ptr %28, i32 %24
  %30 = add i32 %24, 8
  store i32 %30, ptr %23, align 16
  br label %35

31:                                               ; preds = %21
  %32 = getelementptr inbounds %struct.__va_list_tag, ptr %22, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8
  %34 = getelementptr i8, ptr %33, i32 8
  store ptr %34, ptr %32, align 8
  br label %35

35:                                               ; preds = %31, %26
  %36 = phi ptr [ %29, %26 ], [ %33, %31 ]
  %37 = load i32, ptr %36, align 4, !tbaa !9
  %38 = trunc i32 %37 to i8
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.VtabCtx, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !20
  %42 = getelementptr inbounds %struct.VTable, ptr %41, i32 0, i32 4
  store i8 %38, ptr %42, align 4, !tbaa !22
  br label %60

43:                                               ; preds = %18
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.VtabCtx, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !20
  %47 = getelementptr inbounds %struct.VTable, ptr %46, i32 0, i32 6
  store i8 0, ptr %47, align 2, !tbaa !24
  br label %60

48:                                               ; preds = %18
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.VtabCtx, ptr %49, i32 0, i32 0
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = getelementptr inbounds %struct.VTable, ptr %51, i32 0, i32 6
  store i8 2, ptr %52, align 2, !tbaa !24
  br label %60

53:                                               ; preds = %18
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.VtabCtx, ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !20
  %57 = getelementptr inbounds %struct.VTable, ptr %56, i32 0, i32 5
  store i8 1, ptr %57, align 1, !tbaa !25
  br label %60

58:                                               ; preds = %18
  %59 = call i32 @sqlite3MisuseError(i32 noundef 157724)
  store i32 %59, ptr %6, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %58, %53, %48, %43, %35
  %61 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %5, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %61)
  br label %62

62:                                               ; preds = %60, %16
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %68

65:                                               ; preds = %62
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = load i32, ptr %6, align 4, !tbaa !9
  call void @sqlite3Error(ptr noundef %66, i32 noundef %67)
  br label %68

68:                                               ; preds = %65, %62
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.sqlite3, ptr %69, i32 0, i32 3
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  call void @sqlite3_mutex_leave(ptr noundef %71)
  %72 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #3
  ret i32 %72
}

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 nosync nounwind willreturn }
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 = !{!12, !6, i64 24}
!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 = !{!12, !6, i64 568}
!20 = !{!21, !6, i64 0}
!21 = !{!"VtabCtx", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24}
!22 = !{!23, !7, i64 28}
!23 = !{!"VTable", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !7, i64 28, !7, i64 29, !7, i64 30, !10, i64 32, !6, i64 40}
!24 = !{!23, !7, i64 30}
!25 = !{!23, !7, i64 29}


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

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

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3_vtab_config(ptr noundef %0, i32 noundef %1, ...) local_unnamed_addr #1 {
  %3 = alloca [1 x %struct.__va_list_tag], align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @sqlite3_mutex_enter(ptr noundef %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 568
  %7 = load ptr, ptr %6, align 8, !tbaa !17
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %10

8:                                                ; preds = %2
  %9 = tail call i32 @sqlite3MisuseError(i32 noundef 157702)
  br label %42

10:                                               ; preds = %2
  call void @llvm.va_start.p0(ptr nonnull %3)
  switch i32 %1, label %39 [
    i32 1, label %11
    i32 2, label %30
    i32 3, label %33
    i32 4, label %36
  ]

11:                                               ; preds = %10
  %12 = load i32, ptr %3, align 16
  %13 = icmp ult i32 %12, 41
  br i1 %13, label %14, label %20

14:                                               ; preds = %11
  %15 = getelementptr inbounds i8, ptr %3, i64 16
  %16 = load ptr, ptr %15, align 16
  %17 = zext nneg i32 %12 to i64
  %18 = getelementptr i8, ptr %16, i64 %17
  %19 = add nuw nsw i32 %12, 8
  store i32 %19, ptr %3, align 16
  br label %24

20:                                               ; preds = %11
  %21 = getelementptr inbounds i8, ptr %3, i64 8
  %22 = load ptr, ptr %21, align 8
  %23 = getelementptr i8, ptr %22, i64 8
  store ptr %23, ptr %21, align 8
  br label %24

24:                                               ; preds = %20, %14
  %25 = phi ptr [ %18, %14 ], [ %22, %20 ]
  %26 = load i32, ptr %25, align 4, !tbaa !18
  %27 = trunc i32 %26 to i8
  %28 = load ptr, ptr %7, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %28, i64 28
  store i8 %27, ptr %29, align 4, !tbaa !21
  br label %41

30:                                               ; preds = %10
  %31 = load ptr, ptr %7, align 8, !tbaa !19
  %32 = getelementptr inbounds i8, ptr %31, i64 30
  store i8 0, ptr %32, align 2, !tbaa !23
  br label %41

33:                                               ; preds = %10
  %34 = load ptr, ptr %7, align 8, !tbaa !19
  %35 = getelementptr inbounds i8, ptr %34, i64 30
  store i8 2, ptr %35, align 2, !tbaa !23
  br label %41

36:                                               ; preds = %10
  %37 = load ptr, ptr %7, align 8, !tbaa !19
  %38 = getelementptr inbounds i8, ptr %37, i64 29
  store i8 1, ptr %38, align 1, !tbaa !24
  br label %41

39:                                               ; preds = %10
  %40 = call i32 @sqlite3MisuseError(i32 noundef 157724)
  br label %41

41:                                               ; preds = %39, %36, %33, %30, %24
  %.0 = phi i32 [ %40, %39 ], [ 0, %36 ], [ 0, %33 ], [ 0, %30 ], [ 0, %24 ]
  call void @llvm.va_end.p0(ptr nonnull %3)
  br label %42

42:                                               ; preds = %41, %8
  %.1 = phi i32 [ %.0, %41 ], [ %9, %8 ]
  %.not14 = icmp eq i32 %.1, 0
  br i1 %.not14, label %44, label %43

43:                                               ; preds = %42
  call void @sqlite3Error(ptr noundef nonnull %0, i32 noundef %.1)
  br label %44

44:                                               ; preds = %43, %42
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  call void @sqlite3_mutex_leave(ptr noundef %45)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  ret i32 %.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 nosync nounwind willreturn }
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, !7, i64 24}
!6 = !{!"sqlite3", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !11, i64 48, !11, i64 56, !11, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !8, i64 100, !8, i64 101, !8, i64 102, !8, i64 103, !8, i64 104, !8, i64 105, !8, i64 106, !8, i64 107, !8, i64 108, !8, i64 109, !8, i64 110, !8, i64 111, !8, i64 112, !8, i64 113, !10, i64 116, !11, i64 120, !11, i64 128, !8, i64 136, !10, i64 184, !12, i64 192, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !7, i64 232, !8, i64 240, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360, !7, i64 368, !7, i64 376, !7, i64 384, !7, i64 392, !8, i64 400, !13, i64 408, !7, i64 504, !7, i64 512, !7, i64 520, !7, i64 528, !10, i64 536, !10, i64 540, !15, i64 544, !7, i64 568, !7, i64 576, !7, i64 584, !15, i64 592, !15, i64 616, !16, i64 640, !8, i64 664, !7, i64 728, !10, i64 736, !10, i64 740, !10, i64 744, !10, i64 748, !11, i64 752, !11, i64 760, !7, i64 768, !7, i64 776}
!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 = !{!"sqlite3InitInfo", !10, i64 0, !8, i64 4, !8, i64 5, !10, i64 6, !10, i64 6, !10, i64 6, !7, i64 8}
!13 = !{!"Lookaside", !10, i64 0, !14, i64 4, !14, i64 6, !8, i64 8, !10, i64 12, !8, i64 16, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88}
!14 = !{!"short", !8, i64 0}
!15 = !{!"Hash", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 16}
!16 = !{!"BusyHandler", !7, i64 0, !7, i64 8, !10, i64 16}
!17 = !{!6, !7, i64 568}
!18 = !{!10, !10, i64 0}
!19 = !{!20, !7, i64 0}
!20 = !{!"VtabCtx", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!21 = !{!22, !8, i64 28}
!22 = !{!"VTable", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !8, i64 28, !8, i64 29, !8, i64 30, !10, i64 32, !7, i64 40}
!23 = !{!22, !8, i64 30}
!24 = !{!22, !8, i64 29}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass