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

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

@sqlite3PendingByte = external global i32, align 4

; 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

declare ptr @sqlite3PcacheDirtyList(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3PagerGet(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @sqlite3PagerUnref(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3PagerSync(ptr noundef, ptr noundef) #2

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

17:                                               ; preds = %3
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Pager, ptr %18, i32 0, i32 26
  %20 = load i32, ptr %19, align 8, !tbaa !11
  store i32 %20, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %166

21:                                               ; preds = %3
  %22 = call i32 @sqlite3FaultSim(i32 noundef 400)
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  store i32 10, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %166

25:                                               ; preds = %21
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Pager, ptr %26, i32 0, i32 14
  %28 = load i8, ptr %27, align 1, !tbaa !15
  %29 = zext i8 %28 to i32
  %30 = icmp slt i32 %29, 3
  br i1 %30, label %31, label %32

31:                                               ; preds = %25
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %166

32:                                               ; preds = %25
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = call i32 @pagerFlushOnCommit(ptr noundef %33, i32 noundef 1)
  %35 = icmp eq i32 0, %34
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.Pager, ptr %37, i32 0, i32 36
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  call void @sqlite3BackupRestart(ptr noundef %39)
  br label %152

40:                                               ; preds = %32
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.Pager, ptr %41, i32 0, i32 60
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %77

45:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Pager, ptr %46, i32 0, i32 59
  %48 = load ptr, ptr %47, align 8, !tbaa !18
  %49 = call ptr @sqlite3PcacheDirtyList(ptr noundef %48)
  store ptr %49, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %58

52:                                               ; preds = %45
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = call i32 @sqlite3PagerGet(ptr noundef %53, i32 noundef 1, ptr noundef %11, i32 noundef 0)
  store i32 %54, ptr %8, align 4, !tbaa !9
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %55, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.PgHdr, ptr %56, i32 0, i32 3
  store ptr null, ptr %57, align 8, !tbaa !19
  br label %58

58:                                               ; preds = %52, %45
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = icmp ne ptr %59, null
  br i1 %60, label %61, label %68

61:                                               ; preds = %58
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.Pager, ptr %64, i32 0, i32 22
  %66 = load i32, ptr %65, align 8, !tbaa !21
  %67 = call i32 @pagerWalFrames(ptr noundef %62, ptr noundef %63, i32 noundef %66, i32 noundef 1)
  store i32 %67, ptr %8, align 4, !tbaa !9
  br label %68

68:                                               ; preds = %61, %58
  %69 = load ptr, ptr %11, align 8, !tbaa !5
  call void @sqlite3PagerUnref(ptr noundef %69)
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = icmp eq i32 %70, 0
  br i1 %71, label %72, label %76

72:                                               ; preds = %68
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.Pager, ptr %73, i32 0, i32 59
  %75 = load ptr, ptr %74, align 8, !tbaa !18
  call void @sqlite3PcacheCleanAll(ptr noundef %75)
  br label %76

76:                                               ; preds = %72, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %151

77:                                               ; preds = %40
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = call i32 @pager_incr_changecounter(ptr noundef %78, i32 noundef 0)
  store i32 %79, ptr %8, align 4, !tbaa !9
  %80 = load i32, ptr %8, align 4, !tbaa !9
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %83

82:                                               ; preds = %77
  br label %153

83:                                               ; preds = %77
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = call i32 @writeMasterJournal(ptr noundef %84, ptr noundef %85)
  store i32 %86, ptr %8, align 4, !tbaa !9
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %83
  br label %153

90:                                               ; preds = %83
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = call i32 @syncJournal(ptr noundef %91, i32 noundef 0)
  store i32 %92, ptr %8, align 4, !tbaa !9
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %90
  br label %153

96:                                               ; preds = %90
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.Pager, ptr %98, i32 0, i32 59
  %100 = load ptr, ptr %99, align 8, !tbaa !18
  %101 = call ptr @sqlite3PcacheDirtyList(ptr noundef %100)
  %102 = call i32 @pager_write_pagelist(ptr noundef %97, ptr noundef %101)
  store i32 %102, ptr %8, align 4, !tbaa !9
  %103 = load i32, ptr %8, align 4, !tbaa !9
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %105, label %106

105:                                              ; preds = %96
  br label %153

106:                                              ; preds = %96
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.Pager, ptr %107, i32 0, i32 59
  %109 = load ptr, ptr %108, align 8, !tbaa !18
  call void @sqlite3PcacheCleanAll(ptr noundef %109)
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.Pager, ptr %110, i32 0, i32 22
  %112 = load i32, ptr %111, align 8, !tbaa !21
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.Pager, ptr %113, i32 0, i32 24
  %115 = load i32, ptr %114, align 8, !tbaa !22
  %116 = icmp ugt i32 %112, %115
  br i1 %116, label %117, label %143

117:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.Pager, ptr %118, i32 0, i32 22
  %120 = load i32, ptr %119, align 8, !tbaa !21
  %121 = load ptr, ptr %5, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.Pager, ptr %121, i32 0, i32 22
  %123 = load i32, ptr %122, align 8, !tbaa !21
  %124 = load i32, ptr @sqlite3PendingByte, align 4, !tbaa !9
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.Pager, ptr %125, i32 0, i32 48
  %127 = load i32, ptr %126, align 4, !tbaa !23
  %128 = sdiv i32 %124, %127
  %129 = add nsw i32 %128, 1
  %130 = icmp eq i32 %123, %129
  %131 = zext i1 %130 to i32
  %132 = sub i32 %120, %131
  store i32 %132, ptr %12, align 4, !tbaa !9
  %133 = load ptr, ptr %5, align 8, !tbaa !5
  %134 = load i32, ptr %12, align 4, !tbaa !9
  %135 = call i32 @pager_truncate(ptr noundef %133, i32 noundef %134)
  store i32 %135, ptr %8, align 4, !tbaa !9
  %136 = load i32, ptr %8, align 4, !tbaa !9
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %139

138:                                              ; preds = %117
  store i32 2, ptr %9, align 4
  br label %140

139:                                              ; preds = %117
  store i32 0, ptr %9, align 4
  br label %140

140:                                              ; preds = %139, %138
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %141 = load i32, ptr %9, align 4
  switch i32 %141, label %166 [
    i32 0, label %142
    i32 2, label %153
  ]

142:                                              ; preds = %140
  br label %143

143:                                              ; preds = %142, %106
  %144 = load i32, ptr %7, align 4, !tbaa !9
  %145 = icmp ne i32 %144, 0
  br i1 %145, label %150, label %146

146:                                              ; preds = %143
  %147 = load ptr, ptr %5, align 8, !tbaa !5
  %148 = load ptr, ptr %6, align 8, !tbaa !5
  %149 = call i32 @sqlite3PagerSync(ptr noundef %147, ptr noundef %148)
  store i32 %149, ptr %8, align 4, !tbaa !9
  br label %150

150:                                              ; preds = %146, %143
  br label %151

151:                                              ; preds = %150, %76
  br label %152

152:                                              ; preds = %151, %36
  br label %153

153:                                              ; preds = %152, %140, %105, %95, %89, %82
  %154 = load i32, ptr %8, align 4, !tbaa !9
  %155 = icmp eq i32 %154, 0
  br i1 %155, label %156, label %164

156:                                              ; preds = %153
  %157 = load ptr, ptr %5, align 8, !tbaa !5
  %158 = getelementptr inbounds %struct.Pager, ptr %157, i32 0, i32 60
  %159 = load ptr, ptr %158, align 8, !tbaa !17
  %160 = icmp ne ptr %159, null
  br i1 %160, label %164, label %161

161:                                              ; preds = %156
  %162 = load ptr, ptr %5, align 8, !tbaa !5
  %163 = getelementptr inbounds %struct.Pager, ptr %162, i32 0, i32 14
  store i8 5, ptr %163, align 1, !tbaa !15
  br label %164

164:                                              ; preds = %161, %156, %153
  %165 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %165, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %166

166:                                              ; preds = %164, %140, %31, %24, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %167 = load i32, ptr %4, align 4
  ret i32 %167
}

declare i32 @sqlite3FaultSim(i32 noundef) #1

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

declare void @sqlite3BackupRestart(ptr noundef) #1

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

declare void @sqlite3PcacheCleanAll(ptr noundef) #1

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

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

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #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, !10, i64 48}
!12 = !{!"Pager", !6, i64 0, !7, i64 8, !7, i64 9, !7, i64 10, !7, i64 11, !7, i64 12, !7, i64 13, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 17, !7, i64 18, !7, i64 19, !7, i64 20, !7, i64 21, !7, i64 22, !7, i64 23, !7, i64 24, !7, i64 25, !7, i64 26, !7, i64 27, !7, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !13, i64 96, !13, i64 104, !6, i64 112, !6, i64 120, !10, i64 128, !10, i64 132, !7, i64 136, !10, i64 152, !13, i64 160, !6, i64 168, !14, i64 176, !14, i64 178, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !13, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !7, i64 240, !6, i64 256, !6, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !6, i64 296}
!13 = !{!"long long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !7, i64 21}
!16 = !{!12, !6, i64 112}
!17 = !{!12, !6, i64 288}
!18 = !{!12, !6, i64 280}
!19 = !{!20, !6, i64 24}
!20 = !{!"PgHdr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !14, i64 44, !14, i64 46, !6, i64 48, !6, i64 56, !6, i64 64}
!21 = !{!12, !10, i64 32}
!22 = !{!12, !10, i64 40}
!23 = !{!12, !10, i64 188}


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

@sqlite3PendingByte = external local_unnamed_addr global i32, align 4

; 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

declare ptr @sqlite3PcacheDirtyList(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3PagerGet(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @sqlite3PagerSync(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local i32 @sqlite3PagerCommitPhaseOne(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca ptr, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %.thread

7:                                                ; preds = %3
  %8 = tail call i32 @sqlite3FaultSim(i32 noundef 400) #3
  %.not54 = icmp eq i32 %8, 0
  br i1 %.not54, label %9, label %.thread

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 21
  %11 = load i8, ptr %10, align 1, !tbaa !13
  %12 = icmp ult i8 %11, 3
  br i1 %12, label %.thread, label %13

13:                                               ; preds = %9
  %14 = tail call i32 @pagerFlushOnCommit(ptr noundef nonnull %0, i32 noundef 1)
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %0, i64 112
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  tail call void @sqlite3BackupRestart(ptr noundef %18) #3
  br label %.thread67

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %0, i64 288
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %.not55 = icmp eq ptr %21, null
  br i1 %.not55, label %40, label %22

22:                                               ; preds = %19
  %23 = getelementptr inbounds i8, ptr %0, i64 280
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = tail call ptr @sqlite3PcacheDirtyList(ptr noundef %24) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  store ptr null, ptr %4, align 8, !tbaa !17
  %26 = icmp eq ptr %25, null
  br i1 %26, label %27, label %31

27:                                               ; preds = %22
  %28 = call i32 @sqlite3PagerGet(ptr noundef nonnull %0, i32 noundef 1, ptr noundef nonnull %4, i32 noundef 0)
  %29 = load ptr, ptr %4, align 8, !tbaa !17
  %30 = getelementptr inbounds i8, ptr %29, i64 24
  store ptr null, ptr %30, align 8, !tbaa !18
  br label %31

31:                                               ; preds = %27, %22
  %.043 = phi ptr [ %29, %27 ], [ %25, %22 ]
  %32 = getelementptr inbounds i8, ptr %0, i64 32
  %33 = load i32, ptr %32, align 8, !tbaa !20
  %34 = call i32 @pagerWalFrames(ptr noundef nonnull %0, ptr noundef nonnull %.043, i32 noundef %33, i32 noundef 1)
  %35 = load ptr, ptr %4, align 8, !tbaa !17
  call void @sqlite3PagerUnref(ptr noundef %35)
  %36 = icmp eq i32 %34, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %31
  %38 = load ptr, ptr %23, align 8, !tbaa !16
  call void @sqlite3PcacheCleanAll(ptr noundef %38) #3
  br label %39

39:                                               ; preds = %37, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  br label %70

40:                                               ; preds = %19
  %41 = tail call i32 @pager_incr_changecounter(ptr noundef nonnull %0, i32 noundef 0)
  %.not56 = icmp eq i32 %41, 0
  br i1 %.not56, label %42, label %.thread

42:                                               ; preds = %40
  %43 = tail call i32 @writeMasterJournal(ptr noundef nonnull %0, ptr noundef %1)
  %.not57 = icmp eq i32 %43, 0
  br i1 %.not57, label %44, label %.thread

44:                                               ; preds = %42
  %45 = tail call i32 @syncJournal(ptr noundef nonnull %0, i32 noundef 0)
  %.not58 = icmp eq i32 %45, 0
  br i1 %.not58, label %46, label %.thread

46:                                               ; preds = %44
  %47 = getelementptr inbounds i8, ptr %0, i64 280
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = tail call ptr @sqlite3PcacheDirtyList(ptr noundef %48) #3
  %50 = tail call i32 @pager_write_pagelist(ptr noundef nonnull %0, ptr noundef %49)
  %.not59 = icmp eq i32 %50, 0
  br i1 %.not59, label %51, label %.thread

51:                                               ; preds = %46
  %52 = load ptr, ptr %47, align 8, !tbaa !16
  tail call void @sqlite3PcacheCleanAll(ptr noundef %52) #3
  %53 = getelementptr inbounds i8, ptr %0, i64 32
  %54 = load i32, ptr %53, align 8, !tbaa !20
  %55 = getelementptr inbounds i8, ptr %0, i64 40
  %56 = load i32, ptr %55, align 8, !tbaa !21
  %57 = icmp ugt i32 %54, %56
  br i1 %57, label %58, label %67

58:                                               ; preds = %51
  %59 = load i32, ptr @sqlite3PendingByte, align 4, !tbaa !22
  %60 = getelementptr inbounds i8, ptr %0, i64 188
  %61 = load i32, ptr %60, align 4, !tbaa !23
  %62 = sdiv i32 %59, %61
  %63 = add nsw i32 %62, 1
  %64 = icmp eq i32 %54, %63
  %.neg = sext i1 %64 to i32
  %65 = add i32 %54, %.neg
  %66 = tail call i32 @pager_truncate(ptr noundef nonnull %0, i32 noundef %65)
  %.not60 = icmp eq i32 %66, 0
  br i1 %.not60, label %67, label %.thread

67:                                               ; preds = %58, %51
  %.not61 = icmp eq i32 %2, 0
  br i1 %.not61, label %68, label %.thread67

68:                                               ; preds = %67
  %69 = tail call i32 @sqlite3PagerSync(ptr noundef nonnull %0, ptr noundef %1)
  br label %70

70:                                               ; preds = %68, %39
  %.3 = phi i32 [ %34, %39 ], [ %69, %68 ]
  %71 = icmp eq i32 %.3, 0
  br i1 %71, label %.thread67, label %.thread

.thread67:                                        ; preds = %67, %16, %70
  %72 = getelementptr inbounds i8, ptr %0, i64 288
  %73 = load ptr, ptr %72, align 8, !tbaa !15
  %.not63 = icmp eq ptr %73, null
  br i1 %.not63, label %74, label %.thread

74:                                               ; preds = %.thread67
  store i8 5, ptr %10, align 1, !tbaa !13
  br label %.thread

.thread:                                          ; preds = %58, %46, %44, %42, %40, %70, %.thread67, %74, %9, %7, %3
  %.0 = phi i32 [ %6, %3 ], [ 10, %7 ], [ 0, %9 ], [ 0, %74 ], [ 0, %.thread67 ], [ %.3, %70 ], [ %66, %58 ], [ %50, %46 ], [ %45, %44 ], [ %43, %42 ], [ %41, %40 ]
  ret i32 %.0
}

declare i32 @sqlite3FaultSim(i32 noundef) local_unnamed_addr #1

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

declare void @sqlite3BackupRestart(ptr noundef) local_unnamed_addr #1

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

declare void @sqlite3PcacheCleanAll(ptr noundef) local_unnamed_addr #1

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

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #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, !10, i64 48}
!6 = !{!"Pager", !7, i64 0, !8, i64 8, !8, i64 9, !8, i64 10, !8, i64 11, !8, i64 12, !8, i64 13, !8, i64 14, !8, i64 15, !8, i64 16, !8, i64 17, !8, i64 18, !8, i64 19, !8, i64 20, !8, i64 21, !8, i64 22, !8, i64 23, !8, i64 24, !8, i64 25, !8, i64 26, !8, i64 27, !8, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !11, i64 96, !11, i64 104, !7, i64 112, !7, i64 120, !10, i64 128, !10, i64 132, !8, i64 136, !10, i64 152, !11, i64 160, !7, i64 168, !12, i64 176, !12, i64 178, !10, i64 180, !10, i64 184, !10, i64 188, !10, i64 192, !11, i64 200, !7, i64 208, !7, i64 216, !7, i64 224, !7, i64 232, !8, i64 240, !7, i64 256, !7, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296}
!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 = !{!"short", !8, i64 0}
!13 = !{!6, !8, i64 21}
!14 = !{!6, !7, i64 112}
!15 = !{!6, !7, i64 288}
!16 = !{!6, !7, i64 280}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !7, i64 24}
!19 = !{!"PgHdr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !12, i64 44, !12, i64 46, !7, i64 48, !7, i64 56, !7, i64 64}
!20 = !{!6, !10, i64 32}
!21 = !{!6, !10, i64 40}
!22 = !{!10, !10, i64 0}
!23 = !{!6, !10, i64 188}


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