; LLVM IR from ElsevierSoftwareX/SOFTX-D-20-00016 :: GameplayFootball/src/libs/sqlite3 (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"

%struct.sqlite3 = type { ptr, i32, ptr, i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i32, i32, ptr, i64, i32, i32, i32, ptr, [11 x i32], %struct.sqlite3InitInfo, i32, ptr, ptr, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %union.anon, %struct.Lookaside, ptr, ptr, ptr, ptr, i32, %struct.Hash, ptr, ptr, i32, ptr, %struct.FuncDefHash, %struct.Hash, %struct.BusyHandler, i32, [2 x %struct.Db], ptr, i32, i32, i8, i64, ptr }
%struct.sqlite3InitInfo = type { i32, i32, i8, i8 }
%union.anon = type { double }
%struct.Lookaside = type { i16, i8, i8, i32, i32, ptr, ptr, ptr }
%struct.FuncDefHash = type { [23 x ptr] }
%struct.Hash = type { i32, i32, ptr, ptr }
%struct.BusyHandler = type { ptr, ptr, i32 }
%struct.Db = type { ptr, ptr, i8, i8, ptr }
%struct.sqlite3_backup = type { ptr, ptr, i32, i32, i32, ptr, ptr, i32, i32, i32, i32, ptr }
%struct.Btree = type { ptr, ptr, i8, i8, i8, i32, i32, ptr, ptr, %struct.BtLock }
%struct.BtLock = type { ptr, i32, i8, ptr }

@.str.4 = external hidden unnamed_addr constant [40 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 void @sqlite3_mutex_enter(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_mutex_leave(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_backup_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.sqlite3, ptr %10, i32 0, i32 20
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  call void @sqlite3_mutex_enter(ptr noundef %12)
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.sqlite3, ptr %13, i32 0, i32 20
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  call void @sqlite3_mutex_enter(ptr noundef %15)
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp eq ptr %16, %17
  br i1 %18, label %19, label %21

19:                                               ; preds = %4
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, i32, ptr, ...) @sqlite3Error(ptr noundef %20, i32 noundef 1, ptr noundef @.str.4)
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %28

21:                                               ; preds = %4
  %22 = call ptr @sqlite3_malloc(i32 noundef 72)
  store ptr %22, ptr %9, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %27, label %25

25:                                               ; preds = %21
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  call void (ptr, i32, ptr, ...) @sqlite3Error(ptr noundef %26, i32 noundef 7, ptr noundef null)
  br label %27

27:                                               ; preds = %25, %21
  br label %28

28:                                               ; preds = %27, %19
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %67

31:                                               ; preds = %28
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %32, i8 0, i64 72, i1 false)
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = call ptr @findBtree(ptr noundef %33, ptr noundef %34, ptr noundef %35)
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.sqlite3_backup, ptr %37, i32 0, i32 6
  store ptr %36, ptr %38, align 8, !tbaa !19
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call ptr @findBtree(ptr noundef %39, ptr noundef %40, ptr noundef %41)
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.sqlite3_backup, ptr %43, i32 0, i32 1
  store ptr %42, ptr %44, align 8, !tbaa !21
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.sqlite3_backup, ptr %46, i32 0, i32 0
  store ptr %45, ptr %47, align 8, !tbaa !22
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.sqlite3_backup, ptr %49, i32 0, i32 5
  store ptr %48, ptr %50, align 8, !tbaa !23
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.sqlite3_backup, ptr %51, i32 0, i32 4
  store i32 1, ptr %52, align 8, !tbaa !24
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.sqlite3_backup, ptr %53, i32 0, i32 10
  store i32 0, ptr %54, align 4, !tbaa !25
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.sqlite3_backup, ptr %55, i32 0, i32 6
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  %58 = icmp eq ptr null, %57
  br i1 %58, label %64, label %59

59:                                               ; preds = %31
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.sqlite3_backup, ptr %60, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !21
  %63 = icmp eq ptr null, %62
  br i1 %63, label %64, label %66

64:                                               ; preds = %59, %31
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  call void @sqlite3_free(ptr noundef %65)
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %64, %59
  br label %67

67:                                               ; preds = %66, %28
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %77

70:                                               ; preds = %67
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.sqlite3_backup, ptr %71, i32 0, i32 6
  %73 = load ptr, ptr %72, align 8, !tbaa !19
  %74 = getelementptr inbounds %struct.Btree, ptr %73, i32 0, i32 6
  %75 = load i32, ptr %74, align 8, !tbaa !26
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %74, align 8, !tbaa !26
  br label %77

77:                                               ; preds = %70, %67
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.sqlite3, ptr %78, i32 0, i32 20
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  call void @sqlite3_mutex_leave(ptr noundef %80)
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.sqlite3, ptr %81, i32 0, i32 20
  %83 = load ptr, ptr %82, align 8, !tbaa !9
  call void @sqlite3_mutex_leave(ptr noundef %83)
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret ptr %84
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @findBtree(ptr noundef, 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !6, i64 88}
!10 = !{!"sqlite3", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !7, i64 41, !7, i64 42, !7, i64 43, !7, i64 44, !7, i64 45, !11, i64 48, !11, i64 52, !6, i64 56, !12, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !6, i64 88, !7, i64 96, !13, i64 140, !11, i64 152, !6, i64 160, !6, i64 168, !11, i64 176, !11, i64 180, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !6, i64 312, !6, i64 320, !7, i64 328, !14, i64 336, !6, i64 376, !6, i64 384, !6, i64 392, !6, i64 400, !11, i64 408, !16, i64 416, !6, i64 440, !6, i64 448, !11, i64 456, !6, i64 464, !17, i64 472, !16, i64 656, !18, i64 680, !11, i64 704, !7, i64 712, !6, i64 776, !11, i64 784, !11, i64 788, !7, i64 792, !12, i64 800, !6, i64 808}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"sqlite3InitInfo", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 9}
!14 = !{!"Lookaside", !15, i64 0, !7, i64 2, !7, i64 3, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!"short", !7, i64 0}
!16 = !{!"Hash", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!17 = !{!"FuncDefHash", !7, i64 0}
!18 = !{!"BusyHandler", !6, i64 0, !6, i64 8, !11, i64 16}
!19 = !{!20, !6, i64 40}
!20 = !{!"sqlite3_backup", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !6, i64 64}
!21 = !{!20, !6, i64 8}
!22 = !{!20, !6, i64 0}
!23 = !{!20, !6, i64 32}
!24 = !{!20, !11, i64 24}
!25 = !{!20, !11, i64 60}
!26 = !{!27, !11, i64 24}
!27 = !{!"Btree", !6, i64 0, !6, i64 8, !7, i64 16, !7, i64 17, !7, i64 18, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !28, i64 48}
!28 = !{!"BtLock", !6, i64 0, !11, i64 8, !7, i64 12, !6, i64 16}


; 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.4 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_mutex_enter(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_mutex_leave(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @sqlite3_malloc(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_backup_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %2, i64 88
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  tail call void @sqlite3_mutex_enter(ptr noundef %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void @sqlite3_mutex_enter(ptr noundef %8)
  %9 = icmp eq ptr %2, %0
  br i1 %9, label %10, label %11

10:                                               ; preds = %4
  tail call void (ptr, i32, ptr, ...) @sqlite3Error(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull @.str.4)
  br label %.thread40

11:                                               ; preds = %4
  %12 = tail call ptr @sqlite3_malloc(i32 noundef 72)
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %14

13:                                               ; preds = %11
  tail call void (ptr, i32, ptr, ...) @sqlite3Error(ptr noundef nonnull %0, i32 noundef 7, ptr noundef null)
  br label %.thread40

14:                                               ; preds = %11
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %12, i8 0, i64 72, i1 false)
  %15 = tail call ptr @findBtree(ptr noundef nonnull %0, ptr noundef nonnull %2, ptr noundef %3)
  %16 = getelementptr inbounds i8, ptr %12, i64 40
  store ptr %15, ptr %16, align 8, !tbaa !18
  %17 = tail call ptr @findBtree(ptr noundef nonnull %0, ptr noundef nonnull %0, ptr noundef %1)
  %18 = getelementptr inbounds i8, ptr %12, i64 8
  store ptr %17, ptr %18, align 8, !tbaa !20
  store ptr %0, ptr %12, align 8, !tbaa !21
  %19 = getelementptr inbounds i8, ptr %12, i64 32
  store ptr %2, ptr %19, align 8, !tbaa !22
  %20 = getelementptr inbounds i8, ptr %12, i64 24
  store i32 1, ptr %20, align 8, !tbaa !23
  %21 = getelementptr inbounds i8, ptr %12, i64 60
  store i32 0, ptr %21, align 4, !tbaa !24
  %22 = load ptr, ptr %16, align 8, !tbaa !18
  %23 = icmp eq ptr %22, null
  %24 = icmp eq ptr %17, null
  %or.cond = select i1 %23, i1 true, i1 %24
  br i1 %or.cond, label %25, label %26

25:                                               ; preds = %14
  tail call void @sqlite3_free(ptr noundef nonnull %12)
  br label %.thread40

26:                                               ; preds = %14
  %27 = getelementptr inbounds i8, ptr %22, i64 24
  %28 = load i32, ptr %27, align 8, !tbaa !25
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %27, align 8, !tbaa !25
  br label %.thread40

.thread40:                                        ; preds = %13, %10, %25, %26
  %.143 = phi ptr [ %12, %26 ], [ null, %25 ], [ null, %10 ], [ null, %13 ]
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void @sqlite3_mutex_leave(ptr noundef %30)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  tail call void @sqlite3_mutex_leave(ptr noundef %31)
  ret ptr %.143
}

; Function Attrs: nounwind uwtable
declare hidden void @sqlite3Error(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !7, i64 88}
!6 = !{!"sqlite3", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !8, i64 40, !8, i64 41, !8, i64 42, !8, i64 43, !8, i64 44, !8, i64 45, !10, i64 48, !10, i64 52, !7, i64 56, !11, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !7, i64 88, !8, i64 96, !12, i64 140, !10, i64 152, !7, i64 160, !7, i64 168, !10, i64 176, !10, i64 180, !7, i64 184, !7, i64 192, !7, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !7, i64 240, !7, i64 248, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !8, i64 328, !13, i64 336, !7, i64 376, !7, i64 384, !7, i64 392, !7, i64 400, !10, i64 408, !15, i64 416, !7, i64 440, !7, i64 448, !10, i64 456, !7, i64 464, !16, i64 472, !15, i64 656, !17, i64 680, !10, i64 704, !8, i64 712, !7, i64 776, !10, i64 784, !10, i64 788, !8, i64 792, !11, i64 800, !7, i64 808}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!"sqlite3InitInfo", !10, i64 0, !10, i64 4, !8, i64 8, !8, i64 9}
!13 = !{!"Lookaside", !14, i64 0, !8, i64 2, !8, i64 3, !10, i64 4, !10, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!14 = !{!"short", !8, i64 0}
!15 = !{!"Hash", !10, i64 0, !10, i64 4, !7, i64 8, !7, i64 16}
!16 = !{!"FuncDefHash", !8, i64 0}
!17 = !{!"BusyHandler", !7, i64 0, !7, i64 8, !10, i64 16}
!18 = !{!19, !7, i64 40}
!19 = !{!"sqlite3_backup", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !7, i64 64}
!20 = !{!19, !7, i64 8}
!21 = !{!19, !7, i64 0}
!22 = !{!19, !7, i64 32}
!23 = !{!19, !10, i64 24}
!24 = !{!19, !10, i64 60}
!25 = !{!26, !10, i64 24}
!26 = !{!"Btree", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 17, !8, i64 18, !10, i64 20, !10, i64 24, !7, i64 32, !7, i64 40, !27, i64 48}
!27 = !{!"BtLock", !7, i64 0, !10, i64 8, !8, i64 12, !7, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass