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

; Function Attrs: nounwind uwtable
declare hidden i32 @sqlite3Strlen30(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden ptr @databaseName(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_filename_journal(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %1
  store ptr null, ptr %2, align 8
  br label %43

7:                                                ; preds = %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call ptr @databaseName(ptr noundef %8)
  store ptr %9, ptr %3, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i32 @sqlite3Strlen30(ptr noundef %10)
  %12 = add nsw i32 %11, 1
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = sext i32 %12 to i64
  %15 = getelementptr inbounds i8, ptr %13, i64 %14
  store ptr %15, ptr %3, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %27, %7
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %25

19:                                               ; preds = %16
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %20, i64 0
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = sext i8 %22 to i32
  %24 = icmp ne i32 %23, 0
  br label %25

25:                                               ; preds = %19, %16
  %26 = phi i1 [ false, %16 ], [ %24, %19 ]
  br i1 %26, label %27, label %40

27:                                               ; preds = %25
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call i32 @sqlite3Strlen30(ptr noundef %28)
  %30 = add nsw i32 %29, 1
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = sext i32 %30 to i64
  %33 = getelementptr inbounds i8, ptr %31, i64 %32
  store ptr %33, ptr %3, align 8, !tbaa !5
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = call i32 @sqlite3Strlen30(ptr noundef %34)
  %36 = add nsw i32 %35, 1
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = sext i32 %36 to i64
  %39 = getelementptr inbounds i8, ptr %37, i64 %38
  store ptr %39, ptr %3, align 8, !tbaa !5
  br label %16, !llvm.loop !10

40:                                               ; preds = %25
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 1
  store ptr %42, ptr %2, align 8
  br label %43

43:                                               ; preds = %40, %6
  %44 = load ptr, ptr %2, align 8
  ret ptr %44
}

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

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; 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
declare hidden i32 @sqlite3Strlen30(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_filename_journal(ptr noundef %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %18, label %3

3:                                                ; preds = %1
  %4 = tail call ptr @databaseName(ptr noundef nonnull %0)
  %5 = tail call i32 @sqlite3Strlen30(ptr noundef %4)
  %6 = sext i32 %5 to i64
  %7 = getelementptr i8, ptr %4, i64 %6
  %.015 = getelementptr i8, ptr %7, i64 1
  %.not16 = icmp eq ptr %.015, null
  br i1 %.not16, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %8 = load i8, ptr %.015, align 1, !tbaa !5
  %.not1421 = icmp eq i8 %8, 0
  br i1 %.not1421, label %.critedge, label %.lr.ph23

.lr.ph:                                           ; preds = %.lr.ph23
  %9 = load i8, ptr %.0, align 1, !tbaa !5
  %.not14 = icmp eq i8 %9, 0
  br i1 %.not14, label %.critedge, label %.lr.ph23, !llvm.loop !8

.lr.ph23:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.01822 = phi ptr [ %.0, %.lr.ph ], [ %.015, %.lr.ph.preheader ]
  %10 = tail call i32 @sqlite3Strlen30(ptr noundef nonnull %.01822)
  %11 = sext i32 %10 to i64
  %12 = getelementptr i8, ptr %.01822, i64 %11
  %13 = getelementptr i8, ptr %12, i64 1
  %14 = tail call i32 @sqlite3Strlen30(ptr noundef nonnull %13)
  %15 = sext i32 %14 to i64
  %16 = getelementptr i8, ptr %13, i64 %15
  %.0 = getelementptr i8, ptr %16, i64 1
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %.critedge, label %.lr.ph, !llvm.loop !8

.critedge:                                        ; preds = %.lr.ph23, %.lr.ph, %.lr.ph.preheader, %3
  %.pn.lcssa = phi ptr [ %7, %3 ], [ %7, %.lr.ph.preheader ], [ %16, %.lr.ph ], [ %16, %.lr.ph23 ]
  %17 = getelementptr i8, ptr %.pn.lcssa, i64 2
  br label %18

18:                                               ; preds = %1, %.critedge
  %.012 = phi ptr [ %17, %.critedge ], [ null, %1 ]
  ret ptr %.012
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass