; 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.Vdbe = type { ptr, ptr, ptr, i32, i32, ptr, i32, i32, ptr, ptr, ptr, ptr, i16, i16, ptr, i8, i8, i16, ptr, ptr, i32, i32, ptr, i32, i32, i32, ptr, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, i32, i64, %struct.BtreeMutexArray, [3 x i32], ptr, ptr, i64, i64, i32, ptr, i32, i32, ptr }
%struct.BtreeMutexArray = type { i32, [11 x ptr] }

; 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_bind_parameter_name(ptr noundef %0, i32 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 i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %8, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %6, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %21, label %11

11:                                               ; preds = %2
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 1
  br i1 %13, label %21, label %14

14:                                               ; preds = %11
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.Vdbe, ptr %16, i32 0, i32 17
  %18 = load i16, ptr %17, align 2, !tbaa !11
  %19 = sext i16 %18 to i32
  %20 = icmp sgt i32 %15, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %14, %11, %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %32

22:                                               ; preds = %14
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @createVarMap(ptr noundef %23)
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Vdbe, ptr %24, i32 0, i32 19
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = sub nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds ptr, ptr %26, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  store ptr %31, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %32

32:                                               ; preds = %22, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %33 = load ptr, ptr %3, align 8
  ret ptr %33
}

; Function Attrs: nounwind uwtable
declare hidden void @createVarMap(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, !13, i64 98}
!12 = !{!"Vdbe", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !6, i64 32, !10, i64 40, !10, i64 44, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80, !13, i64 82, !6, i64 88, !7, i64 96, !7, i64 97, !13, i64 98, !6, i64 104, !6, i64 112, !10, i64 120, !10, i64 124, !6, i64 128, !10, i64 136, !10, i64 140, !10, i64 144, !6, i64 152, !7, i64 160, !7, i64 161, !7, i64 162, !7, i64 163, !7, i64 164, !7, i64 165, !7, i64 166, !7, i64 167, !7, i64 168, !10, i64 172, !10, i64 176, !14, i64 184, !15, i64 192, !7, i64 288, !6, i64 304, !6, i64 312, !14, i64 320, !14, i64 328, !10, i64 336, !6, i64 344, !10, i64 352, !10, i64 356, !6, i64 360}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"BtreeMutexArray", !10, i64 0, !7, i64 8}
!16 = !{!12, !6, i64 112}


; 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"

; Function Attrs: nounwind uwtable
define dso_local ptr @sqlite3_bind_parameter_name(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp slt i32 %1, 1
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %17, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 98
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %8 = sext i16 %7 to i32
  %9 = icmp slt i32 %8, %1
  br i1 %9, label %17, label %10

10:                                               ; preds = %5
  tail call void @createVarMap(ptr noundef nonnull %0)
  %11 = getelementptr inbounds i8, ptr %0, i64 112
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = zext nneg i32 %1 to i64
  %14 = getelementptr ptr, ptr %12, i64 %13
  %15 = getelementptr i8, ptr %14, i64 -8
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  br label %17

17:                                               ; preds = %2, %5, %10
  %.0 = phi ptr [ %16, %10 ], [ null, %5 ], [ null, %2 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden void @createVarMap(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" }

!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, !11, i64 98}
!6 = !{!"Vdbe", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !7, i64 32, !10, i64 40, !10, i64 44, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !11, i64 80, !11, i64 82, !7, i64 88, !8, i64 96, !8, i64 97, !11, i64 98, !7, i64 104, !7, i64 112, !10, i64 120, !10, i64 124, !7, i64 128, !10, i64 136, !10, i64 140, !10, i64 144, !7, i64 152, !8, i64 160, !8, i64 161, !8, i64 162, !8, i64 163, !8, i64 164, !8, i64 165, !8, i64 166, !8, i64 167, !8, i64 168, !10, i64 172, !10, i64 176, !12, i64 184, !13, i64 192, !8, i64 288, !7, i64 304, !7, i64 312, !12, i64 320, !12, i64 328, !10, i64 336, !7, i64 344, !10, i64 352, !10, i64 356, !7, i64 360}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"long long", !8, i64 0}
!13 = !{!"BtreeMutexArray", !10, i64 0, !8, i64 8}
!14 = !{!6, !7, i64 112}
!15 = !{!7, !7, i64 0}


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