; LLVM IR from nbosb/simdal :: deps/sqlite/src (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.29 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.31 = 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

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

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

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

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

15:                                               ; preds = %12, %2
  %16 = load i32, ptr %5, align 4, !tbaa !9
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %22

18:                                               ; preds = %15
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = call i32 @idxPopulateStat1(ptr noundef %19, ptr noundef %20)
  store i32 %21, ptr %5, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %18, %15
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.sqlite3expert, ptr %23, i32 0, i32 11
  %25 = getelementptr inbounds %struct.IdxHash, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  store ptr %26, ptr %6, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %49, %22
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %53

30:                                               ; preds = %27
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.sqlite3expert, ptr %31, i32 0, i32 12
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.IdxHashEntry, ptr %34, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.IdxHashEntry, ptr %37, i32 0, i32 2
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  %40 = icmp ne ptr %39, null
  %41 = zext i1 %40 to i64
  %42 = select i1 %40, ptr @.str.30, ptr @.str.31
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.IdxHashEntry, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = call ptr (ptr, ptr, ptr, ...) @idxAppendText(ptr noundef %5, ptr noundef %33, ptr noundef @.str.29, ptr noundef %36, ptr noundef %42, ptr noundef %45)
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.sqlite3expert, ptr %47, i32 0, i32 12
  store ptr %46, ptr %48, align 8, !tbaa !14
  br label %49

49:                                               ; preds = %30
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.IdxHashEntry, ptr %50, i32 0, i32 4
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  store ptr %52, ptr %6, align 8, !tbaa !5
  br label %27, !llvm.loop !19

53:                                               ; preds = %27
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = icmp eq i32 %54, 0
  br i1 %55, label %56, label %60

56:                                               ; preds = %53
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = call i32 @idxFindIndexes(ptr noundef %57, ptr noundef %58)
  store i32 %59, ptr %5, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %56, %53
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %66

63:                                               ; preds = %60
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.sqlite3expert, ptr %64, i32 0, i32 8
  store i32 1, ptr %65, align 8, !tbaa !21
  br label %66

66:                                               ; preds = %63, %60
  %67 = load i32, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %67
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @idxPopulateStat1(ptr noundef, ptr 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 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.29 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.31 = 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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @idxAppendText(ptr noundef, ptr noundef, 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 #1 {
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  %4 = tail call i32 @idxProcessTriggers(ptr noundef %0, ptr noundef %1)
  store i32 %4, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %.thread

6:                                                ; preds = %2
  %7 = tail call i32 @idxCreateCandidates(ptr noundef %0)
  store i32 %7, ptr %3, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %.thread

9:                                                ; preds = %6
  %10 = tail call i32 @idxPopulateStat1(ptr noundef %0, ptr noundef %1)
  store i32 %10, ptr %3, align 4, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %2, %9, %6
  %11 = phi i32 [ %4, %2 ], [ %10, %9 ], [ %7, %6 ]
  %12 = getelementptr inbounds i8, ptr %0, i64 88
  %.018 = load ptr, ptr %12, align 8, !tbaa !9
  %.not19 = icmp eq ptr %.018, null
  br i1 %.not19, label %._crit_edge, label %.lr.ph

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

14:                                               ; preds = %.lr.ph, %14
  %15 = phi ptr [ %.pre, %.lr.ph ], [ %21, %14 ]
  %.020 = phi ptr [ %.018, %.lr.ph ], [ %.0, %14 ]
  %16 = getelementptr inbounds i8, ptr %.020, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %.020, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %.not16 = icmp eq ptr %19, null
  %20 = select i1 %.not16, ptr @.str.31, ptr @.str.30
  %21 = call ptr (ptr, ptr, ptr, ...) @idxAppendText(ptr noundef nonnull %3, ptr noundef %15, ptr noundef nonnull @.str.29, ptr noundef %17, ptr noundef nonnull %20, ptr noundef %19)
  store ptr %21, ptr %13, align 8, !tbaa !11
  %22 = getelementptr inbounds i8, ptr %.020, i64 32
  %.0 = load ptr, ptr %22, align 8, !tbaa !9
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %._crit_edge.loopexit, label %14, !llvm.loop !17

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.thread
  %23 = phi i32 [ %.pre21, %._crit_edge.loopexit ], [ %11, %.thread ]
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %.thread17

25:                                               ; preds = %._crit_edge
  %26 = call i32 @idxFindIndexes(ptr noundef nonnull %0, ptr noundef %1)
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %.thread17

28:                                               ; preds = %25
  %29 = getelementptr inbounds i8, ptr %0, i64 64
  store i32 1, ptr %29, align 8, !tbaa !19
  br label %.thread17

.thread17:                                        ; preds = %._crit_edge, %28, %25
  %30 = phi i32 [ 0, %28 ], [ %26, %25 ], [ %23, %._crit_edge ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  ret i32 %30
}

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @idxPopulateStat1(ptr noundef, ptr noundef) local_unnamed_addr #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 = { 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