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

@.str.24 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.25 = 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
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.24, 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.24, 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 %69

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  %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.25)
  store i32 %44, ptr %5, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %66, %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 %67

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 %8, align 8, !tbaa !5
  %58 = icmp ne ptr %57, null
  br i1 %58, label %59, label %66

59:                                               ; preds = %54
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.sqlite3expert, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !15
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @sqlite3_exec(ptr noundef %62, ptr noundef %63, ptr noundef null, ptr noundef null, ptr noundef %64)
  store i32 %65, ptr %5, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %59, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %45, !llvm.loop !16

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

69:                                               ; preds = %67, %36
  %70 = load i32, ptr %5, align 4, !tbaa !9
  %71 = icmp eq i32 %70, 0
  br i1 %71, label %72, label %76

72:                                               ; preds = %69
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = call i32 @idxCreateVtabSchema(ptr noundef %73, ptr noundef %74)
  store i32 %75, ptr %5, align 4, !tbaa !9
  br label %76

76:                                               ; preds = %72, %69
  %77 = load i32, ptr %5, align 4, !tbaa !9
  %78 = icmp eq i32 %77, 0
  br i1 %78, label %79, label %85

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

85:                                               ; preds = %79, %76
  %86 = load i32, ptr %5, align 4, !tbaa !9
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %90

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

90:                                               ; preds = %88, %85
  %91 = 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 %91
}

; 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

; 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

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

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

; 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.24 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.25 = 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
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 %.thread28

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.24, 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 %.thread28

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %5, i64 16
  %15 = call i32 @sqlite3_open(ptr noundef nonnull @.str.24, 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 %.thread28

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 %.thread28

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  store ptr null, ptr %4, align 8, !tbaa !15
  %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.25)
  store i32 %23, ptr %3, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %.lr.ph, label %.thread20

.lr.ph:                                           ; preds = %21, %34
  %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 %.thread20

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
  %.not19 = icmp eq ptr %30, null
  br i1 %.not19, label %._crit_edge, label %31

._crit_edge:                                      ; preds = %28
  %.pr21.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %34

31:                                               ; preds = %28
  %32 = load ptr, ptr %14, align 8, !tbaa !14
  %33 = call i32 @sqlite3_exec(ptr noundef %32, ptr noundef nonnull %30, ptr noundef null, ptr noundef null, ptr noundef %1) #3
  store i32 %33, ptr %3, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %._crit_edge, %31
  %.pr21 = phi i32 [ %.pr21.pre, %._crit_edge ], [ %33, %31 ]
  %35 = icmp eq i32 %.pr21, 0
  br i1 %35, label %.lr.ph, label %.thread20, !llvm.loop !16

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

38:                                               ; preds = %.thread20
  %39 = call i32 @idxCreateVtabSchema(ptr noundef nonnull %5, ptr noundef %1)
  store i32 %39, ptr %3, align 4, !tbaa !5
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %.thread25, label %.thread28

.thread25:                                        ; preds = %38
  %41 = load ptr, ptr %10, align 8, !tbaa !18
  %42 = call i32 @sqlite3_set_authorizer(ptr noundef %41, ptr noundef nonnull @idxAuthCallback, ptr noundef nonnull %5) #3
  %.pr27.pr.pr = load i32, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %.pr27.pr.pr, 0
  br i1 %.not, label %43, label %.thread28

.thread28:                                        ; preds = %2, %8, %13, %.thread20, %17, %38, %.thread25
  call void @sqlite3_expert_destroy(ptr noundef %5)
  br label %43

43:                                               ; preds = %.thread28, %.thread25
  %.0 = phi ptr [ null, %.thread28 ], [ %5, %.thread25 ]
  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

; 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

declare i32 @sqlite3_exec(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr 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
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: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass