; LLVM IR from chkn/logdb :: src (logdb_lease)

; 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.logdb_log_entry_t = type { i16 }
%struct.logdb_connection_t = type { i16, %union.pthread_rwlock_t, i32, i32, ptr, i32 }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%struct.logdb_log_t = type { i32, ptr, ptr }
%struct.logdb_lease_t = type { ptr, i32, i64, i32, i32 }

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare i32 @pthread_rwlock_unlock(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @logdb_lease_acquire_write(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.logdb_log_entry_t, align 2
  %11 = alloca i32, align 4
  %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
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = icmp ugt i32 %13, 65536
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  br label %130

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call i32 @logdb_lease_acquire_prelude(ptr noundef %17, ptr noundef %18)
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i32 -1, ptr %4, align 4
  br label %130

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %23

23:                                               ; preds = %113, %104, %22
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.logdb_connection_t, ptr %24, i32 0, i32 4
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %struct.logdb_log_t, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !14
  %29 = call i64 @lseek(i32 noundef %28, i64 noundef 0, i32 noundef 2) #4
  store i64 %29, ptr %8, align 8, !tbaa !16
  %30 = load i64, ptr %8, align 8, !tbaa !16
  %31 = icmp eq i64 %30, -1
  br i1 %31, label %32, label %36

32:                                               ; preds = %23
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.logdb_connection_t, ptr %33, i32 0, i32 1
  %35 = call i32 @pthread_rwlock_unlock(ptr noundef %34) #4
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %129

36:                                               ; preds = %23
  %37 = load i64, ptr %8, align 8, !tbaa !16
  %38 = call i32 @logdb_log_index_from_offset(i64 noundef %37)
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = sub i32 %38, %39
  store i32 %40, ptr %9, align 4, !tbaa !9
  store i64 -1, ptr %8, align 8, !tbaa !16
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %63, %36
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = add i32 %42, -1
  store i32 %43, ptr %9, align 4, !tbaa !9
  %44 = icmp ne i32 %42, 0
  br i1 %44, label %45, label %49

45:                                               ; preds = %41
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = add i32 %46, 1
  store i32 %47, ptr %11, align 4, !tbaa !9
  %48 = icmp ult i32 %46, 4
  br label %49

49:                                               ; preds = %45, %41
  %50 = phi i1 [ false, %41 ], [ %48, %45 ]
  br i1 %50, label %51, label %64

51:                                               ; preds = %49
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.logdb_connection_t, ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = call i32 @logdb_lease_read_entry_space(ptr noundef %54, ptr noundef %10, i32 noundef %55, i32 noundef %56)
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %63

59:                                               ; preds = %51
  %60 = getelementptr inbounds %struct.logdb_log_entry_t, ptr %10, i32 0, i32 0
  %61 = load i16, ptr %60, align 2, !tbaa !18
  %62 = zext i16 %61 to i64
  store i64 %62, ptr %8, align 8, !tbaa !16
  br label %64

63:                                               ; preds = %51
  store i64 -1, ptr %8, align 8, !tbaa !16
  br label %41, !llvm.loop !20

64:                                               ; preds = %59, %49
  %65 = load i64, ptr %8, align 8, !tbaa !16
  %66 = icmp slt i64 %65, 0
  br i1 %66, label %67, label %97

67:                                               ; preds = %64
  %68 = getelementptr inbounds %struct.logdb_log_entry_t, ptr %10, i32 0, i32 0
  store i16 0, ptr %68, align 2, !tbaa !18
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.logdb_connection_t, ptr %69, i32 0, i32 4
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = getelementptr inbounds %struct.logdb_log_t, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %72, align 8, !tbaa !14
  %74 = call i64 @write(i32 noundef %73, ptr noundef %10, i64 noundef 2)
  %75 = icmp ult i64 %74, 2
  br i1 %75, label %76, label %80

76:                                               ; preds = %67
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.logdb_connection_t, ptr %77, i32 0, i32 1
  %79 = call i32 @pthread_rwlock_unlock(ptr noundef %78) #4
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %129

80:                                               ; preds = %67
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.logdb_connection_t, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !11
  %84 = getelementptr inbounds %struct.logdb_log_t, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %84, align 8, !tbaa !14
  %86 = call i64 @lseek(i32 noundef %85, i64 noundef 0, i32 noundef 1) #4
  store i64 %86, ptr %8, align 8, !tbaa !16
  %87 = load i64, ptr %8, align 8, !tbaa !16
  %88 = icmp slt i64 %87, 0
  br i1 %88, label %89, label %93

89:                                               ; preds = %80
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.logdb_connection_t, ptr %90, i32 0, i32 1
  %92 = call i32 @pthread_rwlock_unlock(ptr noundef %91) #4
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %129

93:                                               ; preds = %80
  %94 = load i64, ptr %8, align 8, !tbaa !16
  %95 = call i32 @logdb_log_index_from_offset(i64 noundef %94)
  %96 = sub i32 %95, 1
  store i32 %96, ptr %9, align 4, !tbaa !9
  store i64 0, ptr %8, align 8, !tbaa !16
  store i32 1, ptr %11, align 4, !tbaa !9
  br label %97

97:                                               ; preds = %93, %64
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.logdb_connection_t, ptr %98, i32 0, i32 4
  %100 = load ptr, ptr %99, align 8, !tbaa !11
  %101 = load i32, ptr %9, align 4, !tbaa !9
  %102 = call i32 @logdb_log_lock(ptr noundef %100, i32 noundef %101, i32 noundef 2)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %105

104:                                              ; preds = %97
  br label %23

105:                                              ; preds = %97
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.logdb_connection_t, ptr %106, i32 0, i32 4
  %108 = load ptr, ptr %107, align 8, !tbaa !11
  %109 = load i32, ptr %9, align 4, !tbaa !9
  %110 = load i32, ptr %7, align 4, !tbaa !9
  %111 = call i32 @logdb_lease_read_entry_space(ptr noundef %108, ptr noundef %10, i32 noundef %109, i32 noundef %110)
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %114, label %113

113:                                              ; preds = %105
  br label %23

114:                                              ; preds = %105
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.logdb_lease_t, ptr %116, i32 0, i32 0
  store ptr %115, ptr %117, align 8, !tbaa !22
  %118 = load i32, ptr %9, align 4, !tbaa !9
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = getelementptr inbounds %struct.logdb_lease_t, ptr %119, i32 0, i32 1
  store i32 %118, ptr %120, align 8, !tbaa !24
  %121 = load i64, ptr %8, align 8, !tbaa !16
  %122 = load ptr, ptr %5, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.logdb_lease_t, ptr %122, i32 0, i32 2
  store i64 %121, ptr %123, align 8, !tbaa !25
  %124 = load i32, ptr %7, align 4, !tbaa !9
  %125 = load ptr, ptr %5, align 8, !tbaa !5
  %126 = getelementptr inbounds %struct.logdb_lease_t, ptr %125, i32 0, i32 3
  store i32 %124, ptr %126, align 8, !tbaa !26
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.logdb_lease_t, ptr %127, i32 0, i32 4
  store i32 2, ptr %128, align 4, !tbaa !27
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %129

129:                                              ; preds = %114, %89, %76, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %130

130:                                              ; preds = %129, %21, %15
  %131 = load i32, ptr %4, align 4
  ret i32 %131
}

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) #2

declare i32 @logdb_log_index_from_offset(i64 noundef) #3

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

declare i64 @write(i32 noundef, ptr noundef, i64 noundef) #3

declare i32 @logdb_log_lock(ptr noundef, i32 noundef, i32 noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "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 = { "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 #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, !6, i64 72}
!12 = !{!"", !13, i64 0, !7, i64 8, !10, i64 64, !10, i64 68, !6, i64 72, !10, i64 80}
!13 = !{!"short", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !6, i64 8, !7, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!19, !13, i64 0}
!19 = !{!"", !13, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!23, !6, i64 0}
!23 = !{!"", !6, i64 0, !10, i64 8, !17, i64 16, !10, i64 24, !10, i64 28}
!24 = !{!23, !10, i64 8}
!25 = !{!23, !17, i64 16}
!26 = !{!23, !10, i64 24}
!27 = !{!23, !10, i64 28}


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

%struct.logdb_log_entry_t = type { i16 }

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind
declare i32 @pthread_rwlock_unlock(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @logdb_lease_acquire_write(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.logdb_log_entry_t, align 2
  %5 = icmp ugt i32 %2, 65536
  br i1 %5, label %74, label %6

6:                                                ; preds = %3
  %7 = tail call i32 @logdb_lease_acquire_prelude(ptr noundef %0, ptr noundef %1)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %8, label %74

8:                                                ; preds = %6
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %4) #5
  %9 = getelementptr inbounds i8, ptr %1, i64 72
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = load i32, ptr %10, align 8, !tbaa !12
  %12 = tail call i64 @lseek(i32 noundef %11, i64 noundef 0, i32 noundef 2) #5
  %13 = icmp eq i64 %12, -1
  br i1 %13, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.backedge, %8
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = call i32 @pthread_rwlock_unlock(ptr noundef nonnull %14) #5
  br label %73

.lr.ph:                                           ; preds = %8, %.backedge
  %16 = phi i64 [ %63, %.backedge ], [ %12, %8 ]
  %.052.neg = phi i32 [ %.3.neg, %.backedge ], [ 0, %8 ]
  %17 = call i32 @logdb_log_index_from_offset(i64 noundef %16) #5
  %18 = add i32 %.052.neg, %17
  %19 = add i32 %18, -1
  %.not44 = icmp eq i32 %18, 0
  br i1 %.not44, label %.critedge.thread, label %20

20:                                               ; preds = %.lr.ph
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = call i32 @logdb_lease_read_entry_space(ptr noundef %21, ptr noundef nonnull %4, i32 noundef %19, i32 noundef %2)
  %.not45 = icmp eq i32 %22, 0
  br i1 %.not45, label %23, label %.critedge, !llvm.loop !14

23:                                               ; preds = %20
  %24 = add i32 %18, -2
  %.not44.1 = icmp eq i32 %19, 0
  br i1 %.not44.1, label %.critedge.thread, label %25

25:                                               ; preds = %23
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = call i32 @logdb_lease_read_entry_space(ptr noundef %26, ptr noundef nonnull %4, i32 noundef %24, i32 noundef %2)
  %.not45.1 = icmp eq i32 %27, 0
  br i1 %.not45.1, label %28, label %.critedge, !llvm.loop !14

28:                                               ; preds = %25
  %29 = add i32 %18, -3
  %.not44.2 = icmp eq i32 %24, 0
  br i1 %.not44.2, label %.critedge.thread, label %30

30:                                               ; preds = %28
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = call i32 @logdb_lease_read_entry_space(ptr noundef %31, ptr noundef nonnull %4, i32 noundef %29, i32 noundef %2)
  %.not45.2 = icmp eq i32 %32, 0
  br i1 %.not45.2, label %33, label %.critedge, !llvm.loop !14

33:                                               ; preds = %30
  %.not44.3 = icmp eq i32 %29, 0
  br i1 %.not44.3, label %.critedge.thread, label %34

34:                                               ; preds = %33
  %35 = add i32 %18, -4
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = call i32 @logdb_lease_read_entry_space(ptr noundef %36, ptr noundef nonnull %4, i32 noundef %35, i32 noundef %2)
  %.not45.3 = icmp eq i32 %37, 0
  br i1 %.not45.3, label %.critedge.thread, label %.critedge, !llvm.loop !14

.critedge:                                        ; preds = %34, %30, %25, %20
  %.lcssa54.neg = phi i32 [ -1, %20 ], [ -2, %25 ], [ -3, %30 ], [ -4, %34 ]
  %.lcssa53 = phi i32 [ %19, %20 ], [ %24, %25 ], [ %29, %30 ], [ %35, %34 ]
  %38 = load i16, ptr %4, align 2, !tbaa !16
  %39 = zext i16 %38 to i64
  br label %58

.critedge.thread:                                 ; preds = %34, %33, %28, %23, %.lr.ph
  store i16 0, ptr %4, align 2, !tbaa !16
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load i32, ptr %40, align 8, !tbaa !12
  %42 = call i64 @write(i32 noundef %41, ptr noundef nonnull %4, i64 noundef 2) #5
  %43 = icmp ult i64 %42, 2
  br i1 %43, label %44, label %47

44:                                               ; preds = %.critedge.thread
  %45 = getelementptr inbounds i8, ptr %1, i64 8
  %46 = call i32 @pthread_rwlock_unlock(ptr noundef nonnull %45) #5
  br label %73

47:                                               ; preds = %.critedge.thread
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load i32, ptr %48, align 8, !tbaa !12
  %50 = call i64 @lseek(i32 noundef %49, i64 noundef 0, i32 noundef 1) #5
  %51 = icmp slt i64 %50, 0
  br i1 %51, label %52, label %55

52:                                               ; preds = %47
  %53 = getelementptr inbounds i8, ptr %1, i64 8
  %54 = call i32 @pthread_rwlock_unlock(ptr noundef nonnull %53) #5
  br label %73

55:                                               ; preds = %47
  %56 = call i32 @logdb_log_index_from_offset(i64 noundef %50) #5
  %57 = add i32 %56, -1
  br label %58

58:                                               ; preds = %.critedge, %55
  %.238 = phi i64 [ 0, %55 ], [ %39, %.critedge ]
  %.135 = phi i32 [ %57, %55 ], [ %.lcssa53, %.critedge ]
  %.3.neg = phi i32 [ -1, %55 ], [ %.lcssa54.neg, %.critedge ]
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = call i32 @logdb_log_lock(ptr noundef %59, i32 noundef %.135, i32 noundef 2) #5
  %.not46 = icmp eq i32 %60, 0
  br i1 %.not46, label %65, label %.backedge

.backedge:                                        ; preds = %58, %65
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load i32, ptr %61, align 8, !tbaa !12
  %63 = call i64 @lseek(i32 noundef %62, i64 noundef 0, i32 noundef 2) #5
  %64 = icmp eq i64 %63, -1
  br i1 %64, label %._crit_edge, label %.lr.ph

65:                                               ; preds = %58
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = call i32 @logdb_lease_read_entry_space(ptr noundef %66, ptr noundef nonnull %4, i32 noundef %.135, i32 noundef %2)
  %.not47 = icmp eq i32 %67, 0
  br i1 %.not47, label %.backedge, label %68

68:                                               ; preds = %65
  store ptr %1, ptr %0, align 8, !tbaa !18
  %69 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %.135, ptr %69, align 8, !tbaa !21
  %70 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %.238, ptr %70, align 8, !tbaa !22
  %71 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %2, ptr %71, align 8, !tbaa !23
  %72 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 2, ptr %72, align 4, !tbaa !24
  br label %73

73:                                               ; preds = %68, %52, %44, %._crit_edge
  %.039 = phi i32 [ -1, %._crit_edge ], [ -1, %44 ], [ -1, %52 ], [ 0, %68 ]
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %4) #5
  br label %74

74:                                               ; preds = %6, %3, %73
  %.140 = phi i32 [ %.039, %73 ], [ -1, %3 ], [ -1, %6 ]
  ret i32 %.140
}

; Function Attrs: nounwind
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @logdb_log_index_from_offset(i64 noundef) local_unnamed_addr #3

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

; Function Attrs: nofree
declare noundef i64 @write(i32 noundef, ptr nocapture noundef readonly, i64 noundef) local_unnamed_addr #4

declare i32 @logdb_log_lock(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "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 = { "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 #4 = { nofree "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 #5 = { 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, !11, i64 72}
!6 = !{!"", !7, i64 0, !8, i64 8, !10, i64 64, !10, i64 68, !11, i64 72, !10, i64 80}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!13, !10, i64 0}
!13 = !{!"", !10, i64 0, !11, i64 8, !8, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !7, i64 0}
!17 = !{!"", !7, i64 0}
!18 = !{!19, !11, i64 0}
!19 = !{!"", !11, i64 0, !10, i64 8, !20, i64 16, !10, i64 24, !10, i64 28}
!20 = !{!"long", !8, i64 0}
!21 = !{!19, !10, i64 8}
!22 = !{!19, !20, i64 16}
!23 = !{!19, !10, i64 24}
!24 = !{!19, !10, i64 28}


; Effective O3 passes: ADCEPass,BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass