; LLVM IR from ibr-ds/STANlite :: Enclave/sqlite (wal)

; 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.Wal = type { ptr, ptr, ptr, i32, i64, i32, i32, ptr, i32, i16, i8, i8, i8, i8, i8, i8, i8, i8, %struct.WalIndexHdr, i32, i32, ptr, i32 }
%struct.WalIndexHdr = type { i32, i32, i32, i8, i8, i16, i32, i32, [2 x i32], [2 x i32], [2 x i32] }
%struct.sqlite3_file = type { ptr }
%struct.sqlite3_io_methods = type { i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.WalCkptInfo = type { i32, [5 x i32], [8 x i8], i32, i32 }

; 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 i32 @sqlite3WalCheckpoint(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9) #1 {
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  store ptr %0, ptr %12, align 8, !tbaa !5
  store ptr %1, ptr %13, align 8, !tbaa !5
  store i32 %2, ptr %14, align 4, !tbaa !9
  store ptr %3, ptr %15, align 8, !tbaa !5
  store ptr %4, ptr %16, align 8, !tbaa !5
  store i32 %5, ptr %17, align 4, !tbaa !9
  store i32 %6, ptr %18, align 4, !tbaa !9
  store ptr %7, ptr %19, align 8, !tbaa !5
  store ptr %8, ptr %20, align 8, !tbaa !5
  store ptr %9, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  store i32 0, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  %27 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %27, ptr %24, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %28 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %28, ptr %25, align 8, !tbaa !5
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.Wal, ptr %29, i32 0, i32 14
  %31 = load i8, ptr %30, align 2, !tbaa !11
  %32 = icmp ne i8 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %10
  store i32 8, ptr %11, align 4
  store i32 1, ptr %26, align 4
  br label %159

34:                                               ; preds = %10
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  %36 = call i32 @walLockExclusive(ptr noundef %35, i32 noundef 1, i32 noundef 1)
  store i32 %36, ptr %22, align 4, !tbaa !9
  %37 = load i32, ptr %22, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %34
  %40 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %40, ptr %11, align 4
  store i32 1, ptr %26, align 4
  br label %159

41:                                               ; preds = %34
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.Wal, ptr %42, i32 0, i32 13
  store i8 1, ptr %43, align 1, !tbaa !16
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %62

46:                                               ; preds = %41
  %47 = load ptr, ptr %12, align 8, !tbaa !5
  %48 = load ptr, ptr %15, align 8, !tbaa !5
  %49 = load ptr, ptr %16, align 8, !tbaa !5
  %50 = call i32 @walBusyLock(ptr noundef %47, ptr noundef %48, ptr noundef %49, i32 noundef 0, i32 noundef 1)
  store i32 %50, ptr %22, align 4, !tbaa !9
  %51 = load i32, ptr %22, align 4, !tbaa !9
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %53, label %56

53:                                               ; preds = %46
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.Wal, ptr %54, i32 0, i32 12
  store i8 1, ptr %55, align 8, !tbaa !17
  br label %61

56:                                               ; preds = %46
  %57 = load i32, ptr %22, align 4, !tbaa !9
  %58 = icmp eq i32 %57, 5
  br i1 %58, label %59, label %60

59:                                               ; preds = %56
  store i32 0, ptr %24, align 4, !tbaa !9
  store ptr null, ptr %25, align 8, !tbaa !5
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %59, %56
  br label %61

61:                                               ; preds = %60, %53
  br label %62

62:                                               ; preds = %61, %41
  %63 = load i32, ptr %22, align 4, !tbaa !9
  %64 = icmp eq i32 %63, 0
  br i1 %64, label %65, label %85

65:                                               ; preds = %62
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = call i32 @walIndexReadHdr(ptr noundef %66, ptr noundef %23)
  store i32 %67, ptr %22, align 4, !tbaa !9
  %68 = load i32, ptr %23, align 4, !tbaa !9
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %84

70:                                               ; preds = %65
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.Wal, ptr %71, i32 0, i32 1
  %73 = load ptr, ptr %72, align 8, !tbaa !18
  %74 = getelementptr inbounds %struct.sqlite3_file, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  %76 = getelementptr inbounds %struct.sqlite3_io_methods, ptr %75, i32 0, i32 0
  %77 = load i32, ptr %76, align 8, !tbaa !21
  %78 = icmp sge i32 %77, 3
  br i1 %78, label %79, label %84

79:                                               ; preds = %70
  %80 = load ptr, ptr %12, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.Wal, ptr %80, i32 0, i32 1
  %82 = load ptr, ptr %81, align 8, !tbaa !18
  %83 = call i32 @sqlite3OsUnfetch(ptr noundef %82, i64 noundef 0, ptr noundef null)
  br label %84

84:                                               ; preds = %79, %70, %65
  br label %85

85:                                               ; preds = %84, %62
  %86 = load i32, ptr %22, align 4, !tbaa !9
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %136

88:                                               ; preds = %85
  %89 = load ptr, ptr %12, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.Wal, ptr %89, i32 0, i32 18
  %91 = getelementptr inbounds %struct.WalIndexHdr, ptr %90, i32 0, i32 6
  %92 = load i32, ptr %91, align 8, !tbaa !23
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %101

94:                                               ; preds = %88
  %95 = load ptr, ptr %12, align 8, !tbaa !5
  %96 = call i32 @walPagesize(ptr noundef %95)
  %97 = load i32, ptr %18, align 4, !tbaa !9
  %98 = icmp ne i32 %96, %97
  br i1 %98, label %99, label %101

99:                                               ; preds = %94
  %100 = call i32 @sqlite3CorruptError(i32 noundef 3356)
  store i32 %100, ptr %22, align 4, !tbaa !9
  br label %110

101:                                              ; preds = %94, %88
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = load ptr, ptr %13, align 8, !tbaa !5
  %104 = load i32, ptr %24, align 4, !tbaa !9
  %105 = load ptr, ptr %25, align 8, !tbaa !5
  %106 = load ptr, ptr %16, align 8, !tbaa !5
  %107 = load i32, ptr %17, align 4, !tbaa !9
  %108 = load ptr, ptr %19, align 8, !tbaa !5
  %109 = call i32 @walCheckpoint(ptr noundef %102, ptr noundef %103, i32 noundef %104, ptr noundef %105, ptr noundef %106, i32 noundef %107, ptr noundef %108)
  store i32 %109, ptr %22, align 4, !tbaa !9
  br label %110

110:                                              ; preds = %101, %99
  %111 = load i32, ptr %22, align 4, !tbaa !9
  %112 = icmp eq i32 %111, 0
  br i1 %112, label %116, label %113

113:                                              ; preds = %110
  %114 = load i32, ptr %22, align 4, !tbaa !9
  %115 = icmp eq i32 %114, 5
  br i1 %115, label %116, label %135

116:                                              ; preds = %113, %110
  %117 = load ptr, ptr %20, align 8, !tbaa !5
  %118 = icmp ne ptr %117, null
  br i1 %118, label %119, label %125

119:                                              ; preds = %116
  %120 = load ptr, ptr %12, align 8, !tbaa !5
  %121 = getelementptr inbounds %struct.Wal, ptr %120, i32 0, i32 18
  %122 = getelementptr inbounds %struct.WalIndexHdr, ptr %121, i32 0, i32 6
  %123 = load i32, ptr %122, align 8, !tbaa !23
  %124 = load ptr, ptr %20, align 8, !tbaa !5
  store i32 %123, ptr %124, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %119, %116
  %126 = load ptr, ptr %21, align 8, !tbaa !5
  %127 = icmp ne ptr %126, null
  br i1 %127, label %128, label %134

128:                                              ; preds = %125
  %129 = load ptr, ptr %12, align 8, !tbaa !5
  %130 = call ptr @walCkptInfo(ptr noundef %129)
  %131 = getelementptr inbounds %struct.WalCkptInfo, ptr %130, i32 0, i32 0
  %132 = load volatile i32, ptr %131, align 4, !tbaa !24
  %133 = load ptr, ptr %21, align 8, !tbaa !5
  store i32 %132, ptr %133, align 4, !tbaa !9
  br label %134

134:                                              ; preds = %128, %125
  br label %135

135:                                              ; preds = %134, %113
  br label %136

136:                                              ; preds = %135, %85
  %137 = load i32, ptr %23, align 4, !tbaa !9
  %138 = icmp ne i32 %137, 0
  br i1 %138, label %139, label %142

139:                                              ; preds = %136
  %140 = load ptr, ptr %12, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.Wal, ptr %140, i32 0, i32 18
  call void @llvm.memset.p0.i64(ptr align 8 %141, i8 0, i64 48, i1 false)
  br label %142

142:                                              ; preds = %139, %136
  %143 = load ptr, ptr %12, align 8, !tbaa !5
  %144 = call i32 @sqlite3WalEndWriteTransaction(ptr noundef %143)
  %145 = load ptr, ptr %12, align 8, !tbaa !5
  call void @walUnlockExclusive(ptr noundef %145, i32 noundef 1, i32 noundef 1)
  %146 = load ptr, ptr %12, align 8, !tbaa !5
  %147 = getelementptr inbounds %struct.Wal, ptr %146, i32 0, i32 13
  store i8 0, ptr %147, align 1, !tbaa !16
  %148 = load i32, ptr %22, align 4, !tbaa !9
  %149 = icmp eq i32 %148, 0
  br i1 %149, label %150, label %155

150:                                              ; preds = %142
  %151 = load i32, ptr %14, align 4, !tbaa !9
  %152 = load i32, ptr %24, align 4, !tbaa !9
  %153 = icmp ne i32 %151, %152
  br i1 %153, label %154, label %155

154:                                              ; preds = %150
  br label %157

155:                                              ; preds = %150, %142
  %156 = load i32, ptr %22, align 4, !tbaa !9
  br label %157

157:                                              ; preds = %155, %154
  %158 = phi i32 [ 5, %154 ], [ %156, %155 ]
  store i32 %158, ptr %11, align 4
  store i32 1, ptr %26, align 4
  br label %159

159:                                              ; preds = %157, %39, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  %160 = load i32, ptr %11, align 4
  ret i32 %160
}

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

declare i32 @sqlite3CorruptError(i32 noundef) #2

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

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

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

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

declare i32 @sqlite3OsUnfetch(ptr noundef, i64 noundef, ptr noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @walCkptInfo(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) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !7, i64 66}
!12 = !{!"Wal", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !13, i64 32, !10, i64 40, !10, i64 44, !6, i64 48, !10, i64 56, !14, i64 60, !7, i64 62, !7, i64 63, !7, i64 64, !7, i64 65, !7, i64 66, !7, i64 67, !7, i64 68, !7, i64 69, !15, i64 72, !10, i64 120, !10, i64 124, !6, i64 128, !10, i64 136}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!"WalIndexHdr", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12, !7, i64 13, !14, i64 14, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !7, i64 40}
!16 = !{!12, !7, i64 65}
!17 = !{!12, !7, i64 64}
!18 = !{!12, !6, i64 8}
!19 = !{!20, !6, i64 0}
!20 = !{!"sqlite3_file", !6, i64 0}
!21 = !{!22, !10, i64 0}
!22 = !{!"sqlite3_io_methods", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144}
!23 = !{!12, !10, i64 88}
!24 = !{!25, !10, i64 0}
!25 = !{!"WalCkptInfo", !10, i64 0, !7, i64 4, !7, i64 24, !10, i64 32, !10, i64 36}


; 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: 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 i32 @sqlite3WalCheckpoint(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, ptr noundef %7, ptr noundef writeonly %8, ptr noundef writeonly %9) local_unnamed_addr #1 {
  %11 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 66
  %13 = load i8, ptr %12, align 2, !tbaa !9
  %.not = icmp eq i8 %13, 0
  br i1 %.not, label %14, label %59

14:                                               ; preds = %10
  %15 = tail call i32 @walLockExclusive(ptr noundef nonnull %0, i32 noundef 1, i32 noundef 1)
  %.not57 = icmp eq i32 %15, 0
  br i1 %.not57, label %16, label %59

16:                                               ; preds = %14
  %17 = getelementptr inbounds i8, ptr %0, i64 65
  store i8 1, ptr %17, align 1, !tbaa !15
  %.not58 = icmp eq i32 %2, 0
  br i1 %.not58, label %.thread, label %18

18:                                               ; preds = %16
  %19 = tail call i32 @walBusyLock(ptr noundef nonnull %0, ptr noundef %3, ptr noundef %4, i32 noundef 0, i32 noundef 1)
  switch i32 %19, label %32 [
    i32 0, label %20
    i32 5, label %.thread
  ]

20:                                               ; preds = %18
  %21 = getelementptr inbounds i8, ptr %0, i64 64
  store i8 1, ptr %21, align 8, !tbaa !16
  br label %.thread

.thread:                                          ; preds = %18, %16, %20
  %.073 = phi ptr [ %3, %16 ], [ %3, %20 ], [ null, %18 ]
  %.04670 = phi i32 [ 0, %16 ], [ %2, %20 ], [ 0, %18 ]
  %22 = call i32 @walIndexReadHdr(ptr noundef nonnull %0, ptr noundef nonnull %11)
  %23 = load i32, ptr %11, align 4, !tbaa !5
  %.not59 = icmp eq i32 %23, 0
  br i1 %.not59, label %32, label %24

24:                                               ; preds = %.thread
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = load ptr, ptr %26, align 8, !tbaa !18
  %28 = load i32, ptr %27, align 8, !tbaa !20
  %29 = icmp sgt i32 %28, 2
  br i1 %29, label %30, label %32

30:                                               ; preds = %24
  %31 = call i32 @sqlite3OsUnfetch(ptr noundef nonnull %26, i64 noundef 0, ptr noundef null) #4
  br label %32

32:                                               ; preds = %18, %.thread, %24, %30
  %.072 = phi ptr [ %.073, %30 ], [ %.073, %24 ], [ %.073, %.thread ], [ %3, %18 ]
  %.04669 = phi i32 [ %.04670, %30 ], [ %.04670, %24 ], [ %.04670, %.thread ], [ %2, %18 ]
  %.1 = phi i32 [ %22, %30 ], [ %22, %24 ], [ %22, %.thread ], [ %19, %18 ]
  %33 = icmp eq i32 %.1, 0
  br i1 %33, label %34, label %51

34:                                               ; preds = %32
  %35 = getelementptr inbounds i8, ptr %0, i64 88
  %36 = load i32, ptr %35, align 8, !tbaa !22
  %.not60 = icmp eq i32 %36, 0
  br i1 %.not60, label %41, label %37

37:                                               ; preds = %34
  %38 = call i32 @walPagesize(ptr noundef nonnull %0)
  %.not61 = icmp eq i32 %38, %6
  br i1 %.not61, label %41, label %39

39:                                               ; preds = %37
  %40 = call i32 @sqlite3CorruptError(i32 noundef 3356) #4
  br label %43

41:                                               ; preds = %37, %34
  %42 = call i32 @walCheckpoint(ptr noundef nonnull %0, ptr noundef %1, i32 noundef %.04669, ptr noundef %.072, ptr noundef %4, i32 noundef %5, ptr noundef %7)
  br label %43

43:                                               ; preds = %41, %39
  %.2 = phi i32 [ %40, %39 ], [ %42, %41 ]
  switch i32 %.2, label %51 [
    i32 5, label %44
    i32 0, label %44
  ]

44:                                               ; preds = %43, %43
  %.not62 = icmp eq ptr %8, null
  br i1 %.not62, label %47, label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %35, align 8, !tbaa !22
  store i32 %46, ptr %8, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %45, %44
  %.not63 = icmp eq ptr %9, null
  br i1 %.not63, label %51, label %48

48:                                               ; preds = %47
  %49 = call ptr @walCkptInfo(ptr noundef nonnull %0)
  %50 = load volatile i32, ptr %49, align 4, !tbaa !23
  store i32 %50, ptr %9, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %43, %48, %47, %32
  %.3 = phi i32 [ %.2, %48 ], [ %.2, %47 ], [ %.2, %43 ], [ %.1, %32 ]
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %.not64 = icmp eq i32 %52, 0
  br i1 %.not64, label %55, label %53

53:                                               ; preds = %51
  %54 = getelementptr inbounds i8, ptr %0, i64 72
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %54, i8 0, i64 48, i1 false)
  br label %55

55:                                               ; preds = %53, %51
  %56 = call i32 @sqlite3WalEndWriteTransaction(ptr noundef nonnull %0)
  call void @walUnlockExclusive(ptr noundef nonnull %0, i32 noundef 1, i32 noundef 1)
  store i8 0, ptr %17, align 1, !tbaa !15
  %57 = icmp ne i32 %.3, 0
  %.not65 = icmp eq i32 %.04669, %2
  %or.cond = or i1 %.not65, %57
  %58 = select i1 %or.cond, i32 %.3, i32 5
  br label %59

59:                                               ; preds = %14, %10, %55
  %.048 = phi i32 [ %58, %55 ], [ 8, %10 ], [ %15, %14 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #4
  ret i32 %.048
}

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

declare i32 @sqlite3CorruptError(i32 noundef) local_unnamed_addr #2

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

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

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

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

declare i32 @sqlite3OsUnfetch(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

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

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

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

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

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !7, i64 66}
!10 = !{!"Wal", !11, i64 0, !11, i64 8, !11, i64 16, !6, i64 24, !12, i64 32, !6, i64 40, !6, i64 44, !11, i64 48, !6, i64 56, !13, i64 60, !7, i64 62, !7, i64 63, !7, i64 64, !7, i64 65, !7, i64 66, !7, i64 67, !7, i64 68, !7, i64 69, !14, i64 72, !6, i64 120, !6, i64 124, !11, i64 128, !6, i64 136}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"WalIndexHdr", !6, i64 0, !6, i64 4, !6, i64 8, !7, i64 12, !7, i64 13, !13, i64 14, !6, i64 16, !6, i64 20, !7, i64 24, !7, i64 32, !7, i64 40}
!15 = !{!10, !7, i64 65}
!16 = !{!10, !7, i64 64}
!17 = !{!10, !11, i64 8}
!18 = !{!19, !11, i64 0}
!19 = !{!"sqlite3_file", !11, i64 0}
!20 = !{!21, !6, i64 0}
!21 = !{!"sqlite3_io_methods", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !11, i64 144}
!22 = !{!10, !6, i64 88}
!23 = !{!24, !6, i64 0}
!24 = !{!"WalCkptInfo", !6, i64 0, !7, i64 4, !7, i64 24, !6, i64 32, !6, i64 36}


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