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

; 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.flock = type { i16, i16, i64, i64, i32 }
%struct.logdb_log_entry_t = type { i16 }
%struct.logdb_trailer_t = type { i32 }
%struct.logdb_log_t = type { i32, ptr, ptr }
%struct.logdb_log_header_t = type { [4 x i8], i16 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @logdb_log_index_from_offset(i64 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 uwtable
declare hidden ptr @logdb_log_read(i32 noundef, i32 noundef) #0

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

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

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

; Function Attrs: nounwind
declare i32 @getpid() #2

declare i32 @fcntl(i32 noundef, i32 noundef, ...) #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @logdb_log_close_merge(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.flock, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca %struct.logdb_log_entry_t, align 2
  %15 = alloca %struct.logdb_trailer_t, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %23

18:                                               ; preds = %2
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.logdb_log_t, ptr %19, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !11
  %22 = icmp ne ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %18, %2
  store i32 -1, ptr %3, align 4
  br label %142

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #5
  %25 = getelementptr inbounds %struct.flock, ptr %6, i32 0, i32 0
  store i16 1, ptr %25, align 8, !tbaa !13
  %26 = getelementptr inbounds %struct.flock, ptr %6, i32 0, i32 1
  store i16 0, ptr %26, align 2, !tbaa !17
  %27 = getelementptr inbounds %struct.flock, ptr %6, i32 0, i32 2
  store i64 0, ptr %27, align 8, !tbaa !18
  %28 = getelementptr inbounds %struct.flock, ptr %6, i32 0, i32 3
  store i64 0, ptr %28, align 8, !tbaa !19
  %29 = call i32 @getpid() #5
  %30 = getelementptr inbounds %struct.flock, ptr %6, i32 0, i32 4
  store i32 %29, ptr %30, align 8, !tbaa !20
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.logdb_log_t, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 8, !tbaa !21
  %34 = call i32 (i32, i32, ...) @fcntl(i32 noundef %33, i32 noundef 7, ptr noundef %6)
  %35 = icmp eq i32 %34, -1
  br i1 %35, label %36, label %37

36:                                               ; preds = %24
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %141

37:                                               ; preds = %24
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.logdb_log_t, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !21
  %41 = call i64 @lseek(i32 noundef %40, i64 noundef 0, i32 noundef 0) #5
  %42 = icmp eq i64 %41, -1
  br i1 %42, label %43, label %44

43:                                               ; preds = %37
  br label %135

44:                                               ; preds = %37
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.logdb_log_t, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !21
  %48 = call ptr @logdb_log_read(i32 noundef %47, i32 noundef 1)
  store ptr %48, ptr %8, align 8, !tbaa !5
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = icmp ne ptr %49, null
  br i1 %50, label %52, label %51

51:                                               ; preds = %44
  br label %135

52:                                               ; preds = %44
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.logdb_log_t, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !21
  %56 = call i64 @lseek(i32 noundef %55, i64 noundef 0, i32 noundef 2) #5
  store i64 %56, ptr %9, align 8, !tbaa !22
  %57 = load i64, ptr %9, align 8, !tbaa !22
  %58 = icmp eq i64 %57, -1
  br i1 %58, label %59, label %60

59:                                               ; preds = %52
  br label %135

60:                                               ; preds = %52
  %61 = load i64, ptr %9, align 8, !tbaa !22
  %62 = call i32 @logdb_log_index_from_offset(i64 noundef %61)
  store i32 %62, ptr %10, align 4, !tbaa !9
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = call i64 @logdb_connection_offset(i32 noundef %63)
  store i64 %64, ptr %11, align 8, !tbaa !22
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.logdb_log_header_t, ptr %65, i64 1
  store ptr %66, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %98, %60
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = load i32, ptr %10, align 4, !tbaa !9
  %70 = icmp ule i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  store i32 3, ptr %7, align 4
  br label %101

72:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 2, ptr %14) #5
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = load i32, ptr %13, align 4, !tbaa !9
  %76 = sub i32 %74, %75
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds %struct.logdb_log_entry_t, ptr %73, i64 %77
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %14, ptr align 2 %78, i64 2, i1 false), !tbaa.struct !23
  %79 = getelementptr inbounds %struct.logdb_log_entry_t, ptr %14, i32 0, i32 0
  %80 = load i16, ptr %79, align 2, !tbaa !25
  %81 = zext i16 %80 to i32
  %82 = sub nsw i32 65536, %81
  %83 = sext i32 %82 to i64
  %84 = load i64, ptr %11, align 8, !tbaa !22
  %85 = sub nsw i64 %84, %83
  store i64 %85, ptr %11, align 8, !tbaa !22
  %86 = getelementptr inbounds %struct.logdb_log_entry_t, ptr %14, i32 0, i32 0
  %87 = load i16, ptr %86, align 2, !tbaa !25
  %88 = zext i16 %87 to i32
  %89 = icmp eq i32 %88, 0
  br i1 %89, label %90, label %93

90:                                               ; preds = %72
  %91 = load i64, ptr %9, align 8, !tbaa !22
  %92 = sub i64 %91, 2
  store i64 %92, ptr %9, align 8, !tbaa !22
  br label %94

93:                                               ; preds = %72
  store i32 3, ptr %7, align 4
  br label %95

94:                                               ; preds = %90
  store i32 0, ptr %7, align 4
  br label %95

95:                                               ; preds = %94, %93
  call void @llvm.lifetime.end.p0(i64 2, ptr %14) #5
  %96 = load i32, ptr %7, align 4
  switch i32 %96, label %101 [
    i32 0, label %97
  ]

97:                                               ; preds = %95
  br label %98

98:                                               ; preds = %97
  %99 = load i32, ptr %13, align 4, !tbaa !9
  %100 = add i32 %99, 1
  store i32 %100, ptr %13, align 4, !tbaa !9
  br label %67, !llvm.loop !27

101:                                              ; preds = %95, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %5, align 4, !tbaa !9
  %104 = load i64, ptr %11, align 8, !tbaa !22
  %105 = call i32 @ftruncate(i32 noundef %103, i64 noundef %104) #5
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %108

107:                                              ; preds = %102
  br label %135

108:                                              ; preds = %102
  %109 = load i32, ptr %5, align 4, !tbaa !9
  %110 = call i64 @lseek(i32 noundef %109, i64 noundef 0, i32 noundef 2) #5
  %111 = icmp eq i64 %110, -1
  br i1 %111, label %112, label %113

112:                                              ; preds = %108
  br label %135

113:                                              ; preds = %108
  %114 = load i64, ptr %9, align 8, !tbaa !22
  %115 = add i64 %114, 4
  %116 = trunc i64 %115 to i32
  %117 = getelementptr inbounds %struct.logdb_trailer_t, ptr %15, i32 0, i32 0
  store i32 %116, ptr %117, align 4, !tbaa !29
  %118 = load i32, ptr %5, align 4, !tbaa !9
  %119 = load ptr, ptr %8, align 8, !tbaa !5
  %120 = load i64, ptr %9, align 8, !tbaa !22
  %121 = call i64 @logdb_io_write(i32 noundef %118, ptr noundef %119, i64 noundef %120)
  %122 = icmp ne i64 %121, 0
  br i1 %122, label %127, label %123

123:                                              ; preds = %113
  %124 = load i32, ptr %5, align 4, !tbaa !9
  %125 = call i64 @logdb_io_write(i32 noundef %124, ptr noundef %15, i64 noundef 4)
  %126 = icmp ne i64 %125, 0
  br i1 %126, label %127, label %128

127:                                              ; preds = %123, %113
  br label %135

128:                                              ; preds = %123
  %129 = load ptr, ptr %4, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.logdb_log_t, ptr %129, i32 0, i32 1
  %131 = load ptr, ptr %130, align 8, !tbaa !11
  %132 = call i32 @unlink(ptr noundef %131) #5
  %133 = load ptr, ptr %4, align 8, !tbaa !5
  %134 = call i32 @logdb_log_close(ptr noundef %133)
  store i32 %134, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %141

135:                                              ; preds = %127, %112, %107, %59, %51, %43
  %136 = getelementptr inbounds %struct.flock, ptr %6, i32 0, i32 0
  store i16 2, ptr %136, align 8, !tbaa !13
  %137 = load ptr, ptr %4, align 8, !tbaa !5
  %138 = getelementptr inbounds %struct.logdb_log_t, ptr %137, i32 0, i32 0
  %139 = load i32, ptr %138, align 8, !tbaa !21
  %140 = call i32 (i32, i32, ...) @fcntl(i32 noundef %139, i32 noundef 6, ptr noundef %6)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %141

141:                                              ; preds = %135, %128, %36
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #5
  br label %142

142:                                              ; preds = %141, %23
  %143 = load i32, ptr %3, align 4
  ret i32 %143
}

declare i64 @logdb_connection_offset(i32 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

declare i64 @logdb_io_write(i32 noundef, ptr noundef, i64 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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 8}
!12 = !{!"", !10, i64 0, !6, i64 8, !7, i64 16}
!13 = !{!14, !15, i64 0}
!14 = !{!"flock", !15, i64 0, !15, i64 2, !16, i64 8, !16, i64 16, !10, i64 24}
!15 = !{!"short", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!14, !15, i64 2}
!18 = !{!14, !16, i64 8}
!19 = !{!14, !16, i64 16}
!20 = !{!14, !10, i64 24}
!21 = !{!12, !10, i64 0}
!22 = !{!16, !16, i64 0}
!23 = !{i64 0, i64 2, !24}
!24 = !{!15, !15, i64 0}
!25 = !{!26, !15, i64 0}
!26 = !{!"", !15, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = !{!30, !10, i64 0}
!30 = !{!"", !10, i64 0}


; 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.flock = type { i16, i16, i64, i64, i32 }
%struct.logdb_trailer_t = type { i32 }
%struct.logdb_log_entry_t = type { i16 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @logdb_log_index_from_offset(i64 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 uwtable
declare hidden ptr @logdb_log_read(i32 noundef, i32 noundef) local_unnamed_addr #0

; 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
declare i64 @lseek(i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @unlink(ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @getpid() local_unnamed_addr #2

declare i32 @fcntl(i32 noundef, i32 noundef, ...) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @logdb_log_close_merge(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.flock, align 8
  %4 = alloca %struct.logdb_trailer_t, align 4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %58, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not42 = icmp eq ptr %7, null
  br i1 %.not42, label %58, label %8

8:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  store i16 1, ptr %3, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %3, i64 2
  store i16 0, ptr %9, align 2, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  %11 = tail call i32 @getpid() #6
  %12 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %11, ptr %12, align 8, !tbaa !16
  %13 = load i32, ptr %0, align 8, !tbaa !17
  %14 = call i32 (i32, i32, ...) @fcntl(i32 noundef %13, i32 noundef 7, ptr noundef nonnull %3) #6
  %15 = icmp eq i32 %14, -1
  br i1 %15, label %57, label %16

16:                                               ; preds = %8
  %17 = load i32, ptr %0, align 8, !tbaa !17
  %18 = call i64 @lseek(i32 noundef %17, i64 noundef 0, i32 noundef 0) #6
  %19 = icmp eq i64 %18, -1
  br i1 %19, label %54, label %20

20:                                               ; preds = %16
  %21 = load i32, ptr %0, align 8, !tbaa !17
  %22 = call ptr @logdb_log_read(i32 noundef %21, i32 noundef 1)
  %.not43 = icmp eq ptr %22, null
  br i1 %.not43, label %54, label %23

23:                                               ; preds = %20
  %24 = load i32, ptr %0, align 8, !tbaa !17
  %25 = call i64 @lseek(i32 noundef %24, i64 noundef 0, i32 noundef 2) #6
  %26 = icmp eq i64 %25, -1
  br i1 %26, label %54, label %27

27:                                               ; preds = %23
  %28 = call i32 @logdb_log_index_from_offset(i64 noundef %25)
  %29 = call i64 @logdb_connection_offset(i32 noundef %28) #6
  %30 = getelementptr inbounds i8, ptr %22, i64 6
  %.not4448 = icmp eq i32 %28, 0
  br i1 %.not4448, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %27, %37
  %.03251 = phi i32 [ %39, %37 ], [ 1, %27 ]
  %.03450 = phi i64 [ %35, %37 ], [ %29, %27 ]
  %.03649 = phi i64 [ %38, %37 ], [ %25, %27 ]
  %31 = sub i32 %28, %.03251
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds %struct.logdb_log_entry_t, ptr %30, i64 %32
  %.sroa.0.0.copyload = load i16, ptr %33, align 2, !tbaa !18
  %34 = zext i16 %.sroa.0.0.copyload to i64
  %.neg = or disjoint i64 %34, -65536
  %35 = add i64 %.neg, %.03450
  %36 = icmp eq i16 %.sroa.0.0.copyload, 0
  br i1 %36, label %37, label %._crit_edge

37:                                               ; preds = %.lr.ph
  %38 = add i64 %.03649, -2
  %39 = add i32 %.03251, 1
  %.not44 = icmp ugt i32 %39, %28
  br i1 %.not44, label %._crit_edge, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %37, %27
  %.036.lcssa = phi i64 [ %25, %27 ], [ %38, %37 ], [ %.03649, %.lr.ph ]
  %.135 = phi i64 [ %29, %27 ], [ %35, %37 ], [ %35, %.lr.ph ]
  %40 = call i32 @ftruncate(i32 noundef %1, i64 noundef %.135) #6
  %.not45 = icmp eq i32 %40, 0
  br i1 %.not45, label %41, label %54

41:                                               ; preds = %._crit_edge
  %42 = call i64 @lseek(i32 noundef %1, i64 noundef 0, i32 noundef 2) #6
  %43 = icmp eq i64 %42, -1
  br i1 %43, label %54, label %44

44:                                               ; preds = %41
  %45 = trunc i64 %.036.lcssa to i32
  %46 = add i32 %45, 4
  store i32 %46, ptr %4, align 4, !tbaa !21
  %47 = call i64 @logdb_io_write(i32 noundef %1, ptr noundef nonnull %22, i64 noundef %.036.lcssa) #6
  %.not46 = icmp eq i64 %47, 0
  br i1 %.not46, label %48, label %54

48:                                               ; preds = %44
  %49 = call i64 @logdb_io_write(i32 noundef %1, ptr noundef nonnull %4, i64 noundef 4) #6
  %.not47 = icmp eq i64 %49, 0
  br i1 %.not47, label %50, label %54

50:                                               ; preds = %48
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = call i32 @unlink(ptr noundef %51) #6
  %53 = call i32 @logdb_log_close(ptr noundef nonnull %0)
  br label %57

54:                                               ; preds = %44, %48, %41, %._crit_edge, %23, %20, %16
  store i16 2, ptr %3, align 8, !tbaa !11
  %55 = load i32, ptr %0, align 8, !tbaa !17
  %56 = call i32 (i32, i32, ...) @fcntl(i32 noundef %55, i32 noundef 6, ptr noundef nonnull %3) #6
  br label %57

57:                                               ; preds = %8, %54, %50
  %.0 = phi i32 [ -1, %54 ], [ %53, %50 ], [ -1, %8 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  br label %58

58:                                               ; preds = %2, %5, %57
  %.1 = phi i32 [ %.0, %57 ], [ -1, %5 ], [ -1, %2 ]
  ret i32 %.1
}

declare i64 @logdb_connection_offset(i32 noundef) local_unnamed_addr #4

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

declare i64 @logdb_io_write(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass