; 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] }

@.str.27 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [99 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 hidden i32 @idxPrintfPrepareStmt(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ...) #1

declare i32 @sqlite3_step(ptr noundef) #2

declare ptr @sqlite3_column_text(ptr noundef, i32 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_expert_new(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
  %7 = alloca ptr, align 8
  %8 = 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) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %9 = call ptr @idxMalloc(ptr noundef %5, i32 noundef 8288)
  store ptr %9, ptr %6, align 8, !tbaa !5
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %21

12:                                               ; preds = %2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.sqlite3expert, ptr %14, i32 0, i32 1
  store ptr %13, ptr %15, align 8, !tbaa !11
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.sqlite3expert, ptr %16, i32 0, i32 0
  store i32 100, ptr %17, align 8, !tbaa !14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.sqlite3expert, ptr %18, i32 0, i32 3
  %20 = call i32 @sqlite3_open(ptr noundef @.str.27, ptr noundef %19)
  store i32 %20, ptr %5, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %12, %2
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %36

24:                                               ; preds = %21
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.sqlite3expert, ptr %25, i32 0, i32 2
  %27 = call i32 @sqlite3_open(ptr noundef @.str.27, ptr noundef %26)
  store i32 %27, ptr %5, align 4, !tbaa !9
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %35

30:                                               ; preds = %24
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.sqlite3expert, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = call i32 (ptr, i32, ...) @sqlite3_db_config(ptr noundef %33, i32 noundef 1008, i32 noundef 1, ptr noundef null)
  br label %35

35:                                               ; preds = %30, %24
  br label %36

36:                                               ; preds = %35, %21
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %65

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.sqlite3expert, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = call i32 (ptr, ptr, ptr, ptr, ...) @idxPrintfPrepareStmt(ptr noundef %42, ptr noundef %7, ptr noundef %43, ptr noundef @.str.28)
  store i32 %44, ptr %5, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %54, %39
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 0
  br i1 %47, label %48, label %52

48:                                               ; preds = %45
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = call i32 @sqlite3_step(ptr noundef %49)
  %51 = icmp eq i32 100, %50
  br label %52

52:                                               ; preds = %48, %45
  %53 = phi i1 [ false, %45 ], [ %51, %48 ]
  br i1 %53, label %54, label %63

54:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = call ptr @sqlite3_column_text(ptr noundef %55, i32 noundef 0)
  store ptr %56, ptr %8, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.sqlite3expert, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !15
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = call i32 @sqlite3_exec(ptr noundef %59, ptr noundef %60, ptr noundef null, ptr noundef null, ptr noundef %61)
  store i32 %62, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %45, !llvm.loop !16

63:                                               ; preds = %52
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  call void @idxFinalize(ptr noundef %5, ptr noundef %64)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %65

65:                                               ; preds = %63, %36
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %72

68:                                               ; preds = %65
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call i32 @idxCreateVtabSchema(ptr noundef %69, ptr noundef %70)
  store i32 %71, ptr %5, align 4, !tbaa !9
  br label %72

72:                                               ; preds = %68, %65
  %73 = load i32, ptr %5, align 4, !tbaa !9
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %81

75:                                               ; preds = %72
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.sqlite3expert, ptr %76, i32 0, i32 3
  %78 = load ptr, ptr %77, align 8, !tbaa !18
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = call i32 @sqlite3_set_authorizer(ptr noundef %78, ptr noundef @idxAuthCallback, ptr noundef %79)
  br label %81

81:                                               ; preds = %75, %72
  %82 = load i32, ptr %5, align 4, !tbaa !9
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %86

84:                                               ; preds = %81
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  call void @sqlite3_expert_destroy(ptr noundef %85)
  store ptr null, ptr %6, align 8, !tbaa !5
  br label %86

86:                                               ; preds = %84, %81
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret ptr %87
}

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

declare i32 @sqlite3_open(ptr noundef, ptr noundef) #2

declare i32 @sqlite3_db_config(ptr noundef, i32 noundef, ...) #2

declare i32 @sqlite3_exec(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

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

declare i32 @sqlite3_set_authorizer(ptr noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_expert_destroy(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 = { "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 8}
!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, !10, i64 0}
!15 = !{!12, !6, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !6, i64 24}


; 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.27 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [99 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 hidden i32 @idxPrintfPrepareStmt(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare i32 @sqlite3_step(ptr noundef) local_unnamed_addr #2

declare ptr @sqlite3_column_text(ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_expert_new(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  store i32 0, ptr %3, align 4, !tbaa !5
  %5 = call ptr @idxMalloc(ptr noundef nonnull %3, i32 noundef 8288)
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %8, label %.thread24

8:                                                ; preds = %2
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %0, ptr %9, align 8, !tbaa !9
  store i32 100, ptr %5, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  %11 = call i32 @sqlite3_open(ptr noundef nonnull @.str.27, ptr noundef nonnull %10) #3
  store i32 %11, ptr %3, align 4, !tbaa !5
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %.thread24

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %5, i64 16
  %15 = call i32 @sqlite3_open(ptr noundef nonnull @.str.27, ptr noundef nonnull %14) #3
  store i32 %15, ptr %3, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %.thread24

17:                                               ; preds = %13
  %18 = load ptr, ptr %14, align 8, !tbaa !14
  %19 = call i32 (ptr, i32, ...) @sqlite3_db_config(ptr noundef %18, i32 noundef 1008, i32 noundef 1, ptr noundef null) #3
  %.pr = load i32, ptr %3, align 4, !tbaa !5
  %20 = icmp eq i32 %.pr, 0
  br i1 %20, label %21, label %.thread24

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %22 = load ptr, ptr %9, align 8, !tbaa !9
  %23 = call i32 (ptr, ptr, ptr, ptr, ...) @idxPrintfPrepareStmt(ptr noundef %22, ptr noundef nonnull %4, ptr noundef %1, ptr noundef nonnull @.str.28)
  store i32 %23, ptr %3, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %.lr.ph, label %.thread17

.lr.ph:                                           ; preds = %21, %28
  %25 = load ptr, ptr %4, align 8, !tbaa !15
  %26 = call i32 @sqlite3_step(ptr noundef %25) #3
  %27 = icmp eq i32 %26, 100
  br i1 %27, label %28, label %.thread17

28:                                               ; preds = %.lr.ph
  %29 = load ptr, ptr %4, align 8, !tbaa !15
  %30 = call ptr @sqlite3_column_text(ptr noundef %29, i32 noundef 0) #3
  %31 = load ptr, ptr %14, align 8, !tbaa !14
  %32 = call i32 @sqlite3_exec(ptr noundef %31, ptr noundef %30, ptr noundef null, ptr noundef null, ptr noundef %1) #3
  store i32 %32, ptr %3, align 4, !tbaa !5
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %.lr.ph, label %.thread17, !llvm.loop !16

.thread17:                                        ; preds = %28, %.lr.ph, %21
  %34 = load ptr, ptr %4, align 8, !tbaa !15
  call void @idxFinalize(ptr noundef nonnull %3, ptr noundef %34)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  %.pr18.pr = load i32, ptr %3, align 4, !tbaa !5
  %35 = icmp eq i32 %.pr18.pr, 0
  br i1 %35, label %36, label %.thread24

36:                                               ; preds = %.thread17
  %37 = call i32 @idxCreateVtabSchema(ptr noundef nonnull %5, ptr noundef %1)
  store i32 %37, ptr %3, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %.thread21, label %.thread24

.thread21:                                        ; preds = %36
  %39 = load ptr, ptr %10, align 8, !tbaa !18
  %40 = call i32 @sqlite3_set_authorizer(ptr noundef %39, ptr noundef nonnull @idxAuthCallback, ptr noundef nonnull %5) #3
  %.pr23.pr.pr = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %.pr23.pr.pr, 0
  br i1 %.not, label %41, label %.thread24

.thread24:                                        ; preds = %2, %8, %13, %.thread17, %17, %36, %.thread21
  call void @sqlite3_expert_destroy(ptr noundef %5)
  br label %41

41:                                               ; preds = %.thread24, %.thread21
  %.0 = phi ptr [ null, %.thread24 ], [ %5, %.thread21 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  ret ptr %.0
}

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

declare i32 @sqlite3_open(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @sqlite3_db_config(ptr noundef, i32 noundef, ...) local_unnamed_addr #2

declare i32 @sqlite3_exec(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @sqlite3_set_authorizer(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_expert_destroy(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 = { "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, !11, i64 8}
!10 = !{!"sqlite3expert", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !6, i64 64, !11, i64 72, !6, i64 80, !12, i64 88, !11, i64 8280}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"IdxHash", !11, i64 0, !7, i64 8}
!13 = !{!10, !6, i64 0}
!14 = !{!10, !11, i64 16}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !11, i64 24}


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