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

@.str.28 = external hidden unnamed_addr constant [3 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: 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: nounwind uwtable
declare hidden void @sqlite3DbFree(ptr noundef, ptr noundef) #1

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

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

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

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

14:                                               ; preds = %2
  %15 = call i32 @sqlite3MisuseError(i32 noundef 103116)
  store i32 %15, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %57

16:                                               ; preds = %2
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Incrblob, ptr %17, i32 0, i32 5
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  store ptr %19, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.sqlite3, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  call void @sqlite3_mutex_enter(ptr noundef %22)
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Incrblob, ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !21
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %16
  store i32 4, ptr %6, align 4, !tbaa !22
  br label %49

28:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.Incrblob, ptr %29, i32 0, i32 4
  %31 = load ptr, ptr %30, align 8, !tbaa !21
  %32 = getelementptr inbounds %struct.Vdbe, ptr %31, i32 0, i32 9
  store i32 0, ptr %32, align 4, !tbaa !23
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i64, ptr %5, align 8, !tbaa !9
  %35 = call i32 @blobSeekToRow(ptr noundef %33, i64 noundef %34, ptr noundef %10)
  store i32 %35, ptr %6, align 4, !tbaa !22
  %36 = load i32, ptr %6, align 4, !tbaa !22
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %48

38:                                               ; preds = %28
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load i32, ptr %6, align 4, !tbaa !22
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  %43 = zext i1 %42 to i64
  %44 = select i1 %42, ptr @.str.28, ptr null
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, i32, ptr, ...) @sqlite3ErrorWithMsg(ptr noundef %39, i32 noundef %40, ptr noundef %44, ptr noundef %45)
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  call void @sqlite3DbFree(ptr noundef %46, ptr noundef %47)
  br label %48

48:                                               ; preds = %38, %28
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %49

49:                                               ; preds = %48, %27
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !22
  %52 = call i32 @sqlite3ApiExit(ptr noundef %50, i32 noundef %51)
  store i32 %52, ptr %6, align 4, !tbaa !22
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.sqlite3, ptr %53, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  call void @sqlite3_mutex_leave(ptr noundef %55)
  %56 = load i32, ptr %6, align 4, !tbaa !22
  store i32 %56, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %57

57:                                               ; preds = %49, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %58 = load i32, ptr %3, align 4
  ret i32 %58
}

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 = { 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 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"Incrblob", !13, i64 0, !13, i64 4, !14, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !6, i64 24}
!16 = !{!"sqlite3", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !13, i64 44, !10, i64 48, !10, i64 56, !10, i64 64, !13, i64 72, !13, i64 76, !13, i64 80, !13, i64 84, !13, i64 88, !13, i64 92, !13, 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, !13, i64 116, !10, i64 120, !10, i64 128, !7, i64 136, !13, i64 184, !17, i64 192, !13, i64 208, !13, i64 212, !13, i64 216, !13, i64 220, !13, i64 224, !13, 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, !18, i64 408, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !13, i64 536, !13, i64 540, !19, i64 544, !6, i64 568, !6, i64 576, !6, i64 584, !19, i64 592, !19, i64 616, !20, i64 640, !7, i64 664, !6, i64 728, !13, i64 736, !13, i64 740, !13, i64 744, !13, i64 748, !10, i64 752, !10, i64 760, !6, i64 768, !6, i64 776}
!17 = !{!"sqlite3InitInfo", !13, i64 0, !7, i64 4, !7, i64 5, !13, i64 6, !13, i64 6, !13, i64 6, !6, i64 8}
!18 = !{!"Lookaside", !13, i64 0, !14, i64 4, !14, i64 6, !7, i64 8, !13, 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}
!19 = !{!"Hash", !13, i64 0, !13, i64 4, !6, i64 8, !6, i64 16}
!20 = !{!"BusyHandler", !6, i64 0, !6, i64 8, !13, i64 16}
!21 = !{!12, !6, i64 24}
!22 = !{!13, !13, i64 0}
!23 = !{!24, !13, i64 52}
!24 = !{!"Vdbe", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !13, i64 36, !13, i64 40, !13, i64 44, !13, i64 48, !13, i64 52, !10, i64 56, !13, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !13, i64 144, !13, i64 148, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !10, i64 184, !14, i64 192, !14, i64 194, !7, i64 196, !7, i64 197, !7, i64 198, !7, i64 199, !13, i64 200, !13, i64 200, !13, i64 200, !13, i64 200, !13, i64 200, !13, i64 200, !13, i64 201, !13, i64 204, !13, i64 208, !7, i64 212, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !13, i64 280, !13, i64 284, !6, i64 288, !6, i64 296}


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

@.str.28 = external hidden unnamed_addr constant [3 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: 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: nounwind uwtable
declare hidden void @sqlite3DbFree(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3_blob_reopen(ptr noundef %0, i64 noundef %1) local_unnamed_addr #1 {
  %3 = alloca ptr, align 8
  %4 = icmp eq ptr %0, null
  br i1 %4, label %5, label %7

5:                                                ; preds = %2
  %6 = tail call i32 @sqlite3MisuseError(i32 noundef 103116)
  br label %26

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  tail call void @sqlite3_mutex_enter(ptr noundef %11)
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !19
  %14 = icmp eq ptr %13, null
  br i1 %14, label %23, label %15

15:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #2
  %16 = getelementptr inbounds i8, ptr %13, i64 52
  store i32 0, ptr %16, align 4, !tbaa !20
  %17 = call i32 @blobSeekToRow(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %3)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %22, label %18

18:                                               ; preds = %15
  %19 = load ptr, ptr %3, align 8, !tbaa !22
  %.not19 = icmp eq ptr %19, null
  %20 = select i1 %.not19, ptr null, ptr @.str.28
  call void (ptr, i32, ptr, ...) @sqlite3ErrorWithMsg(ptr noundef nonnull %9, i32 noundef %17, ptr noundef %20, ptr noundef %19)
  %21 = load ptr, ptr %3, align 8, !tbaa !22
  call void @sqlite3DbFree(ptr noundef nonnull %9, ptr noundef %21)
  br label %22

22:                                               ; preds = %18, %15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #2
  br label %23

23:                                               ; preds = %7, %22
  %.016 = phi i32 [ %17, %22 ], [ 4, %7 ]
  %24 = call i32 @sqlite3ApiExit(ptr noundef nonnull %9, i32 noundef %.016)
  %25 = load ptr, ptr %10, align 8, !tbaa !12
  call void @sqlite3_mutex_leave(ptr noundef %25)
  br label %26

26:                                               ; preds = %23, %5
  %.0 = phi i32 [ %6, %5 ], [ %24, %23 ]
  ret i32 %.0
}

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 = { 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, !11, i64 32}
!6 = !{!"Incrblob", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !11, i64 24}
!13 = !{!"sqlite3", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !7, i64 40, !7, i64 44, !14, i64 48, !14, i64 56, !14, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, 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, !7, i64 116, !14, i64 120, !14, i64 128, !8, i64 136, !7, i64 184, !15, i64 192, !7, i64 208, !7, i64 212, !7, i64 216, !7, i64 220, !7, i64 224, !7, i64 228, !11, i64 232, !8, i64 240, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !11, i64 280, !11, i64 288, !11, i64 296, !11, i64 304, !11, i64 312, !11, i64 320, !11, i64 328, !11, i64 336, !11, i64 344, !11, i64 352, !11, i64 360, !11, i64 368, !11, i64 376, !11, i64 384, !11, i64 392, !8, i64 400, !16, i64 408, !11, i64 504, !11, i64 512, !11, i64 520, !11, i64 528, !7, i64 536, !7, i64 540, !17, i64 544, !11, i64 568, !11, i64 576, !11, i64 584, !17, i64 592, !17, i64 616, !18, i64 640, !8, i64 664, !11, i64 728, !7, i64 736, !7, i64 740, !7, i64 744, !7, i64 748, !14, i64 752, !14, i64 760, !11, i64 768, !11, i64 776}
!14 = !{!"long long", !8, i64 0}
!15 = !{!"sqlite3InitInfo", !7, i64 0, !8, i64 4, !8, i64 5, !7, i64 6, !7, i64 6, !7, i64 6, !11, i64 8}
!16 = !{!"Lookaside", !7, i64 0, !10, i64 4, !10, i64 6, !8, i64 8, !7, i64 12, !8, i64 16, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88}
!17 = !{!"Hash", !7, i64 0, !7, i64 4, !11, i64 8, !11, i64 16}
!18 = !{!"BusyHandler", !11, i64 0, !11, i64 8, !7, i64 16}
!19 = !{!6, !11, i64 24}
!20 = !{!21, !7, i64 52}
!21 = !{!"Vdbe", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !10, i64 32, !7, i64 36, !7, i64 40, !7, i64 44, !7, i64 48, !7, i64 52, !14, i64 56, !7, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !7, i64 144, !7, i64 148, !11, i64 152, !11, i64 160, !11, i64 168, !11, i64 176, !14, i64 184, !10, i64 192, !10, i64 194, !8, i64 196, !8, i64 197, !8, i64 198, !8, i64 199, !7, i64 200, !7, i64 200, !7, i64 200, !7, i64 200, !7, i64 200, !7, i64 200, !7, i64 201, !7, i64 204, !7, i64 208, !8, i64 212, !11, i64 248, !11, i64 256, !11, i64 264, !11, i64 272, !7, i64 280, !7, i64 284, !11, i64 288, !11, i64 296}
!22 = !{!11, !11, i64 0}


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