; 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_context = type { ptr, ptr, ptr, ptr, i32, i32, i8, i8, i8, [1 x 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 }
%struct.AuxData = type { 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

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

18:                                               ; preds = %40, %4
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %44

21:                                               ; preds = %18
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.AuxData, ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 4, !tbaa !17
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp eq i32 %24, %25
  br i1 %26, label %27, label %39

27:                                               ; preds = %21
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.AuxData, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !19
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.sqlite3_context, ptr %31, i32 0, i32 4
  %33 = load i32, ptr %32, align 8, !tbaa !20
  %34 = icmp eq i32 %30, %33
  br i1 %34, label %38, label %35

35:                                               ; preds = %27
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %35, %27
  br label %44

39:                                               ; preds = %35, %21
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.AuxData, ptr %41, i32 0, i32 4
  %43 = load ptr, ptr %42, align 8, !tbaa !21
  store ptr %43, ptr %9, align 8, !tbaa !5
  br label %18, !llvm.loop !22

44:                                               ; preds = %38, %18
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = icmp eq ptr %45, null
  br i1 %46, label %47, label %80

47:                                               ; preds = %44
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Vdbe, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %49, align 8, !tbaa !24
  %51 = call ptr @sqlite3DbMallocZero(ptr noundef %50, i64 noundef 32)
  store ptr %51, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %55, label %54

54:                                               ; preds = %47
  br label %100

55:                                               ; preds = %47
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.sqlite3_context, ptr %56, i32 0, i32 4
  %58 = load i32, ptr %57, align 8, !tbaa !20
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.AuxData, ptr %59, i32 0, i32 0
  store i32 %58, ptr %60, align 8, !tbaa !19
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.AuxData, ptr %62, i32 0, i32 1
  store i32 %61, ptr %63, align 4, !tbaa !17
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.Vdbe, ptr %64, i32 0, i32 45
  %66 = load ptr, ptr %65, align 8, !tbaa !13
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.AuxData, ptr %67, i32 0, i32 4
  store ptr %66, ptr %68, align 8, !tbaa !21
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.Vdbe, ptr %70, i32 0, i32 45
  store ptr %69, ptr %71, align 8, !tbaa !13
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.sqlite3_context, ptr %72, i32 0, i32 5
  %74 = load i32, ptr %73, align 4, !tbaa !25
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %55
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.sqlite3_context, ptr %77, i32 0, i32 5
  store i32 -1, ptr %78, align 4, !tbaa !25
  br label %79

79:                                               ; preds = %76, %55
  br label %93

80:                                               ; preds = %44
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.AuxData, ptr %81, i32 0, i32 3
  %83 = load ptr, ptr %82, align 8, !tbaa !26
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %92

85:                                               ; preds = %80
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.AuxData, ptr %86, i32 0, i32 3
  %88 = load ptr, ptr %87, align 8, !tbaa !26
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.AuxData, ptr %89, i32 0, i32 2
  %91 = load ptr, ptr %90, align 8, !tbaa !27
  call void %88(ptr noundef %91)
  br label %92

92:                                               ; preds = %85, %80
  br label %93

93:                                               ; preds = %92, %79
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.AuxData, ptr %95, i32 0, i32 2
  store ptr %94, ptr %96, align 8, !tbaa !27
  %97 = load ptr, ptr %8, align 8, !tbaa !5
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.AuxData, ptr %98, i32 0, i32 3
  store ptr %97, ptr %99, align 8, !tbaa !26
  store i32 1, ptr %11, align 4
  br label %107

100:                                              ; preds = %54
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = icmp ne ptr %101, null
  br i1 %102, label %103, label %106

103:                                              ; preds = %100
  %104 = load ptr, ptr %8, align 8, !tbaa !5
  %105 = load ptr, ptr %7, align 8, !tbaa !5
  call void %104(ptr noundef %105)
  br label %106

106:                                              ; preds = %103, %100
  store i32 0, ptr %11, align 4
  br label %107

107:                                              ; preds = %106, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  %108 = load i32, ptr %11, align 4
  switch i32 %108, label %110 [
    i32 0, label %109
    i32 1, label %109
  ]

109:                                              ; preds = %107, %107
  ret void

110:                                              ; preds = %107
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden ptr @sqlite3DbMallocZero(ptr noundef, i64 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 = { 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_context", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 48}
!13 = !{!14, !6, i64 296}
!14 = !{!"Vdbe", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !15, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !16, i64 56, !10, i64 64, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !10, i64 144, !10, i64 148, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !16, i64 184, !15, i64 192, !15, i64 194, !7, i64 196, !7, i64 197, !7, i64 198, !7, i64 199, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 201, !10, i64 204, !10, i64 208, !7, i64 212, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !10, i64 280, !10, i64 284, !6, i64 288, !6, i64 296}
!15 = !{!"short", !7, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!18, !10, i64 4}
!18 = !{!"AuxData", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!18, !10, i64 0}
!20 = !{!12, !10, i64 32}
!21 = !{!18, !6, i64 24}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!14, !6, i64 0}
!25 = !{!12, !10, i64 36}
!26 = !{!18, !6, i64 16}
!27 = !{!18, !6, 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"

; Function Attrs: nounwind uwtable
define dso_local void @sqlite3_set_auxdata(ptr nocapture noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 296
  %.040 = load ptr, ptr %7, align 8, !tbaa !11
  %cond41 = icmp eq ptr %.040, null
  br i1 %cond41, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = icmp slt i32 %1, 0
  br i1 %9, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %13
  %.042.us = phi ptr [ %.0.us, %13 ], [ %.040, %.lr.ph ]
  %10 = getelementptr inbounds i8, ptr %.042.us, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %12 = icmp eq i32 %11, %1
  br i1 %12, label %.split.us, label %13

13:                                               ; preds = %.lr.ph.split.us
  %14 = getelementptr inbounds i8, ptr %.042.us, i64 24
  %.0.us = load ptr, ptr %14, align 8, !tbaa !11
  %cond.us = icmp eq ptr %.0.us, null
  br i1 %cond.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !14

.lr.ph.split:                                     ; preds = %.lr.ph, %22
  %.042 = phi ptr [ %.0, %22 ], [ %.040, %.lr.ph ]
  %15 = getelementptr inbounds i8, ptr %.042, i64 4
  %16 = load i32, ptr %15, align 4, !tbaa !12
  %17 = icmp eq i32 %16, %1
  br i1 %17, label %18, label %22

18:                                               ; preds = %.lr.ph.split
  %19 = load i32, ptr %.042, align 8, !tbaa !16
  %20 = load i32, ptr %8, align 8, !tbaa !17
  %21 = icmp eq i32 %19, %20
  br i1 %21, label %.split.us, label %22

22:                                               ; preds = %.lr.ph.split, %18
  %23 = getelementptr inbounds i8, ptr %.042, i64 24
  %.0 = load ptr, ptr %23, align 8, !tbaa !11
  %cond = icmp eq ptr %.0, null
  br i1 %cond, label %._crit_edge, label %.lr.ph.split, !llvm.loop !14

._crit_edge:                                      ; preds = %22, %13, %4
  %24 = load ptr, ptr %6, align 8, !tbaa !18
  %25 = tail call ptr @sqlite3DbMallocZero(ptr noundef %24, i64 noundef 32)
  %.not37 = icmp eq ptr %25, null
  br i1 %.not37, label %44, label %26

26:                                               ; preds = %._crit_edge
  %27 = getelementptr inbounds i8, ptr %0, i64 32
  %28 = load i32, ptr %27, align 8, !tbaa !17
  store i32 %28, ptr %25, align 8, !tbaa !16
  %29 = getelementptr inbounds i8, ptr %25, i64 4
  store i32 %1, ptr %29, align 4, !tbaa !12
  %30 = load ptr, ptr %7, align 8, !tbaa !22
  %31 = getelementptr inbounds i8, ptr %25, i64 24
  store ptr %30, ptr %31, align 8, !tbaa !23
  store ptr %25, ptr %7, align 8, !tbaa !22
  %32 = getelementptr inbounds i8, ptr %0, i64 36
  %33 = load i32, ptr %32, align 4, !tbaa !24
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %41

35:                                               ; preds = %26
  store i32 -1, ptr %32, align 4, !tbaa !24
  br label %41

.split.us:                                        ; preds = %18, %.lr.ph.split.us
  %.us-phi = phi ptr [ %.042.us, %.lr.ph.split.us ], [ %.042, %18 ]
  %36 = getelementptr inbounds i8, ptr %.us-phi, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !25
  %.not36 = icmp eq ptr %37, null
  br i1 %.not36, label %41, label %38

38:                                               ; preds = %.split.us
  %39 = getelementptr inbounds i8, ptr %.us-phi, i64 8
  %40 = load ptr, ptr %39, align 8, !tbaa !26
  tail call void %37(ptr noundef %40) #1
  br label %41

41:                                               ; preds = %.split.us, %38, %26, %35
  %.1 = phi ptr [ %25, %35 ], [ %25, %26 ], [ %.us-phi, %38 ], [ %.us-phi, %.split.us ]
  %42 = getelementptr inbounds i8, ptr %.1, i64 8
  store ptr %2, ptr %42, align 8, !tbaa !26
  %43 = getelementptr inbounds i8, ptr %.1, i64 16
  store ptr %3, ptr %43, align 8, !tbaa !25
  br label %46

44:                                               ; preds = %._crit_edge
  %.not38 = icmp eq ptr %3, null
  br i1 %.not38, label %46, label %45

45:                                               ; preds = %44
  tail call void %3(ptr noundef %2) #1
  br label %46

46:                                               ; preds = %44, %45, %41
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden ptr @sqlite3DbMallocZero(ptr noundef, i64 noundef) local_unnamed_addr #0

attributes #0 = { 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 #1 = { 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_context", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 36, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 4}
!13 = !{!"AuxData", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 16, !7, i64 24}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !10, i64 0}
!17 = !{!6, !10, i64 32}
!18 = !{!19, !7, i64 0}
!19 = !{!"Vdbe", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !20, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !21, i64 56, !10, i64 64, !21, i64 72, !21, i64 80, !21, i64 88, !21, i64 96, !7, i64 104, !7, i64 112, !7, i64 120, !7, i64 128, !7, i64 136, !10, i64 144, !10, i64 148, !7, i64 152, !7, i64 160, !7, i64 168, !7, i64 176, !21, i64 184, !20, i64 192, !20, i64 194, !8, i64 196, !8, i64 197, !8, i64 198, !8, i64 199, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 200, !10, i64 201, !10, i64 204, !10, i64 208, !8, i64 212, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !10, i64 280, !10, i64 284, !7, i64 288, !7, i64 296}
!20 = !{!"short", !8, i64 0}
!21 = !{!"long long", !8, i64 0}
!22 = !{!19, !7, i64 296}
!23 = !{!13, !7, i64 24}
!24 = !{!6, !10, i64 36}
!25 = !{!13, !7, i64 16}
!26 = !{!13, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass