; LLVM IR from WayneLin92/SSeqCpp :: thirdparty/sqlite3 (shell)

; 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.sqlite3expert = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32, %struct.IdxHash, ptr }
%struct.IdxHash = type { ptr, [1023 x ptr] }
%struct.IdxHashEntry = type { ptr, ptr, ptr, ptr, ptr }

@.str.26 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [1 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @sqlite3_mprintf(ptr noundef, ...) #1

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

14:                                               ; preds = %2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i32 @idxCreateCandidates(ptr noundef %15)
  store i32 %16, ptr %6, align 4, !tbaa !9
  br label %29

17:                                               ; preds = %2
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 773
  br i1 %19, label %20, label %28

20:                                               ; preds = %17
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %26

23:                                               ; preds = %20
  %24 = call ptr (ptr, ...) @sqlite3_mprintf(ptr noundef @.str.26)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %24, ptr %25, align 8, !tbaa !5
  br label %26

26:                                               ; preds = %23, %20
  %27 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %27, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %82

28:                                               ; preds = %17
  br label %29

29:                                               ; preds = %28, %14
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %36

32:                                               ; preds = %29
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = call i32 @idxPopulateStat1(ptr noundef %33, ptr noundef %34)
  store i32 %35, ptr %6, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %32, %29
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sqlite3expert, ptr %37, i32 0, i32 11
  %39 = getelementptr inbounds %struct.IdxHash, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  store ptr %40, ptr %7, align 8, !tbaa !5
  br label %41

41:                                               ; preds = %63, %36
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %67

44:                                               ; preds = %41
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.sqlite3expert, ptr %45, i32 0, i32 12
  %47 = load ptr, ptr %46, align 8, !tbaa !14
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.IdxHashEntry, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !15
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.IdxHashEntry, ptr %51, i32 0, i32 2
  %53 = load ptr, ptr %52, align 8, !tbaa !17
  %54 = icmp ne ptr %53, null
  %55 = zext i1 %54 to i64
  %56 = select i1 %54, ptr @.str.28, ptr @.str.29
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.IdxHashEntry, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = call ptr (ptr, ptr, ptr, ...) @idxAppendText(ptr noundef %6, ptr noundef %47, ptr noundef @.str.27, ptr noundef %50, ptr noundef %56, ptr noundef %59)
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.sqlite3expert, ptr %61, i32 0, i32 12
  store ptr %60, ptr %62, align 8, !tbaa !14
  br label %63

63:                                               ; preds = %44
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.IdxHashEntry, ptr %64, i32 0, i32 4
  %66 = load ptr, ptr %65, align 8, !tbaa !18
  store ptr %66, ptr %7, align 8, !tbaa !5
  br label %41, !llvm.loop !19

67:                                               ; preds = %41
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %70, label %74

70:                                               ; preds = %67
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = call i32 @idxFindIndexes(ptr noundef %71, ptr noundef %72)
  store i32 %73, ptr %6, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %70, %67
  %75 = load i32, ptr %6, align 4, !tbaa !9
  %76 = icmp eq i32 %75, 0
  br i1 %76, label %77, label %80

77:                                               ; preds = %74
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.sqlite3expert, ptr %78, i32 0, i32 8
  store i32 1, ptr %79, align 8, !tbaa !21
  br label %80

80:                                               ; preds = %77, %74
  %81 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %81, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %82

82:                                               ; preds = %80, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %83 = load i32, ptr %3, align 4
  ret i32 %83
}

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @idxAppendText(ptr noundef, ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @idxFindIndexes(ptr noundef, ptr 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 88}
!12 = !{!"sqlite3expert", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !6, i64 72, !10, i64 80, !13, i64 88, !6, i64 8280}
!13 = !{!"IdxHash", !6, i64 0, !7, i64 8}
!14 = !{!12, !6, i64 8280}
!15 = !{!16, !6, i64 8}
!16 = !{!"IdxHashEntry", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!17 = !{!16, !6, i64 16}
!18 = !{!16, !6, i64 32}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!12, !10, i64 64}


; 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.26 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [1 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare ptr @sqlite3_mprintf(ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3_expert_analyze(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %4 = tail call i32 @idxProcessTriggers(ptr noundef %0, ptr noundef %1)
  store i32 %4, ptr %3, align 4, !tbaa !5
  switch i32 %4, label %10 [
    i32 0, label %5
    i32 773, label %7
  ]

5:                                                ; preds = %2
  %6 = tail call i32 @idxCreateCandidates(ptr noundef %0)
  store i32 %6, ptr %3, align 4, !tbaa !5
  br label %10

7:                                                ; preds = %2
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.thread, label %8

8:                                                ; preds = %7
  %9 = tail call ptr (ptr, ...) @sqlite3_mprintf(ptr noundef nonnull @.str.26) #3
  store ptr %9, ptr %1, align 8, !tbaa !9
  br label %.thread

10:                                               ; preds = %2, %5
  %11 = phi i32 [ %4, %2 ], [ %6, %5 ]
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %15

13:                                               ; preds = %10
  %14 = tail call i32 @idxPopulateStat1(ptr noundef %0, ptr noundef %1)
  store i32 %14, ptr %3, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %13, %10
  %16 = phi i32 [ %14, %13 ], [ %11, %10 ]
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  %.023 = load ptr, ptr %17, align 8, !tbaa !9
  %.not2124 = icmp eq ptr %.023, null
  br i1 %.not2124, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %15
  %18 = getelementptr inbounds i8, ptr %0, i64 8280
  %.pre = load ptr, ptr %18, align 8, !tbaa !11
  br label %19

19:                                               ; preds = %.lr.ph, %19
  %20 = phi ptr [ %.pre, %.lr.ph ], [ %26, %19 ]
  %.025 = phi ptr [ %.023, %.lr.ph ], [ %.0, %19 ]
  %21 = getelementptr inbounds i8, ptr %.025, i64 8
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %.025, i64 16
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %.not22 = icmp eq ptr %24, null
  %25 = select i1 %.not22, ptr @.str.29, ptr @.str.28
  %26 = call ptr (ptr, ptr, ptr, ...) @idxAppendText(ptr noundef nonnull %3, ptr noundef %20, ptr noundef nonnull @.str.27, ptr noundef %22, ptr noundef nonnull %25, ptr noundef %24)
  store ptr %26, ptr %18, align 8, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %.025, i64 32
  %.0 = load ptr, ptr %27, align 8, !tbaa !9
  %.not21 = icmp eq ptr %.0, null
  br i1 %.not21, label %._crit_edge.loopexit, label %19, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %19
  %.pre26 = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %15
  %28 = phi i32 [ %.pre26, %._crit_edge.loopexit ], [ %16, %15 ]
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %.thread

30:                                               ; preds = %._crit_edge
  %31 = call i32 @idxFindIndexes(ptr noundef nonnull %0, ptr noundef %1)
  %32 = icmp eq i32 %31, 0
  br i1 %32, label %33, label %.thread

33:                                               ; preds = %30
  %34 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 1, ptr %34, align 8, !tbaa !19
  br label %.thread

.thread:                                          ; preds = %._crit_edge, %30, %33, %7, %8
  %.018 = phi i32 [ %28, %._crit_edge ], [ %31, %30 ], [ 0, %33 ], [ 773, %7 ], [ 773, %8 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret i32 %.018
}

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

; Function Attrs: nounwind uwtable
declare hidden i32 @idxCreateCandidates(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden ptr @idxAppendText(ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #2

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

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 8280}
!12 = !{!"sqlite3expert", !6, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !6, i64 64, !10, i64 72, !6, i64 80, !13, i64 88, !10, i64 8280}
!13 = !{!"IdxHash", !10, i64 0, !7, i64 8}
!14 = !{!15, !10, i64 8}
!15 = !{!"IdxHashEntry", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!16 = !{!15, !10, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !6, i64 64}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass