; 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_t = type { i32, ptr, ptr }
%struct.logdb_log_lock_t = type { i32, [128 x i32], ptr }

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i64 @logdb_log_offset(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @logdb_log_lock(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca %struct.flock, align 8
  %19 = alloca i32, align 4
  %20 = alloca i8, align 1
  %21 = alloca i32, align 4
  %22 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.logdb_log_t, ptr %23, i32 0, i32 2
  store ptr %24, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = load atomic volatile i64, ptr %25 seq_cst, align 8
  store i64 %26, ptr %10, align 8
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %27, ptr %9, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %76, %65, %3
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %37

31:                                               ; preds = %28
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = icmp ugt i32 %34, %35
  br i1 %36, label %37, label %68

37:                                               ; preds = %31, %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %38 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 528) #7
  store ptr %38, ptr %11, align 8, !tbaa !5
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %65

42:                                               ; preds = %37
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %44, i32 0, i32 0
  store i32 %43, ptr %45, align 8, !tbaa !11
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %48, ptr %47, align 8, !tbaa !13
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %50, ptr %13, align 8, !tbaa !5
  %51 = load i64, ptr %9, align 8
  %52 = load i64, ptr %13, align 8
  %53 = cmpxchg volatile ptr %49, i64 %51, i64 %52 seq_cst seq_cst, align 8
  %54 = extractvalue { i64, i1 } %53, 0
  %55 = extractvalue { i64, i1 } %53, 1
  br i1 %55, label %57, label %56

56:                                               ; preds = %42
  store i64 %54, ptr %9, align 8
  br label %57

57:                                               ; preds = %56, %42
  %58 = zext i1 %55 to i8
  store i8 %58, ptr %14, align 1, !tbaa !14
  %59 = load i8, ptr %14, align 1, !tbaa !14, !range !16, !noundef !17
  %60 = trunc i8 %59 to i1
  br i1 %60, label %63, label %61

61:                                               ; preds = %57
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %62) #6
  store i32 2, ptr %12, align 4
  br label %65

63:                                               ; preds = %57
  %64 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %64, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %65

65:                                               ; preds = %63, %61, %41
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %66 = load i32, ptr %12, align 4
  switch i32 %66, label %166 [
    i32 0, label %67
    i32 2, label %28
  ]

67:                                               ; preds = %65
  br label %68

68:                                               ; preds = %67, %31
  %69 = load i32, ptr %6, align 4, !tbaa !9
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 8, !tbaa !11
  %73 = sub i32 %69, %72
  store i32 %73, ptr %15, align 4, !tbaa !9
  %74 = load i32, ptr %15, align 4, !tbaa !9
  %75 = icmp ugt i32 %74, 127
  br i1 %75, label %76, label %82

76:                                               ; preds = %68
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %77, i32 0, i32 2
  store ptr %78, ptr %8, align 8, !tbaa !5
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load atomic volatile i64, ptr %79 seq_cst, align 8
  store i64 %80, ptr %16, align 8
  %81 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %81, ptr %9, align 8, !tbaa !5
  br label %28

82:                                               ; preds = %68
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %83, i32 0, i32 1
  %85 = load i32, ptr %15, align 4, !tbaa !9
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds [128 x i32], ptr %84, i64 0, i64 %86
  %88 = load atomic volatile i32, ptr %87 seq_cst, align 4, !tbaa !13
  store i32 %88, ptr %17, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %138, %113, %82
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = icmp eq i32 %90, 1
  br i1 %91, label %92, label %116

92:                                               ; preds = %89
  %93 = load i32, ptr %17, align 4, !tbaa !9
  %94 = icmp sge i32 %93, 0
  br i1 %94, label %95, label %116

95:                                               ; preds = %92
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %96, i32 0, i32 1
  %98 = load i32, ptr %15, align 4, !tbaa !9
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds [128 x i32], ptr %97, i64 0, i64 %99
  %101 = load i32, ptr %17, align 4, !tbaa !9
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %19, align 4, !tbaa !9
  %103 = load i32, ptr %17, align 4
  %104 = load i32, ptr %19, align 4
  %105 = cmpxchg weak volatile ptr %100, i32 %103, i32 %104 seq_cst seq_cst, align 4
  %106 = extractvalue { i32, i1 } %105, 0
  %107 = extractvalue { i32, i1 } %105, 1
  br i1 %107, label %109, label %108

108:                                              ; preds = %95
  store i32 %106, ptr %17, align 4
  br label %109

109:                                              ; preds = %108, %95
  %110 = zext i1 %107 to i8
  store i8 %110, ptr %20, align 1, !tbaa !14
  %111 = load i8, ptr %20, align 1, !tbaa !14, !range !16, !noundef !17
  %112 = trunc i8 %111 to i1
  br i1 %112, label %114, label %113

113:                                              ; preds = %109
  br label %89

114:                                              ; preds = %109
  %115 = getelementptr inbounds %struct.flock, ptr %18, i32 0, i32 0
  store i16 0, ptr %115, align 8, !tbaa !18
  br label %143

116:                                              ; preds = %92, %89
  %117 = load i32, ptr %7, align 4, !tbaa !9
  %118 = icmp eq i32 %117, 2
  br i1 %118, label %119, label %141

119:                                              ; preds = %116
  %120 = load i32, ptr %17, align 4, !tbaa !9
  %121 = icmp eq i32 %120, 0
  br i1 %121, label %122, label %141

122:                                              ; preds = %119
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.logdb_log_lock_t, ptr %123, i32 0, i32 1
  %125 = load i32, ptr %15, align 4, !tbaa !9
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds [128 x i32], ptr %124, i64 0, i64 %126
  store i32 -1, ptr %21, align 4, !tbaa !9
  %128 = load i32, ptr %17, align 4
  %129 = load i32, ptr %21, align 4
  %130 = cmpxchg weak volatile ptr %127, i32 %128, i32 %129 seq_cst seq_cst, align 4
  %131 = extractvalue { i32, i1 } %130, 0
  %132 = extractvalue { i32, i1 } %130, 1
  br i1 %132, label %134, label %133

133:                                              ; preds = %122
  store i32 %131, ptr %17, align 4
  br label %134

134:                                              ; preds = %133, %122
  %135 = zext i1 %132 to i8
  store i8 %135, ptr %22, align 1, !tbaa !14
  %136 = load i8, ptr %22, align 1, !tbaa !14, !range !16, !noundef !17
  %137 = trunc i8 %136 to i1
  br i1 %137, label %139, label %138

138:                                              ; preds = %134
  br label %89

139:                                              ; preds = %134
  %140 = getelementptr inbounds %struct.flock, ptr %18, i32 0, i32 0
  store i16 1, ptr %140, align 8, !tbaa !18
  br label %142

141:                                              ; preds = %119, %116
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %166

142:                                              ; preds = %139
  br label %143

143:                                              ; preds = %142, %114
  %144 = getelementptr inbounds %struct.flock, ptr %18, i32 0, i32 1
  store i16 0, ptr %144, align 2, !tbaa !22
  %145 = load i32, ptr %6, align 4, !tbaa !9
  %146 = call i64 @logdb_log_offset(i32 noundef %145)
  %147 = getelementptr inbounds %struct.flock, ptr %18, i32 0, i32 2
  store i64 %146, ptr %147, align 8, !tbaa !23
  %148 = getelementptr inbounds %struct.flock, ptr %18, i32 0, i32 3
  store i64 2, ptr %148, align 8, !tbaa !24
  %149 = call i32 @getpid() #6
  %150 = getelementptr inbounds %struct.flock, ptr %18, i32 0, i32 4
  store i32 %149, ptr %150, align 8, !tbaa !25
  %151 = load ptr, ptr %5, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.logdb_log_t, ptr %151, i32 0, i32 0
  %153 = load i32, ptr %152, align 8, !tbaa !26
  %154 = call i32 (i32, i32, ...) @fcntl(i32 noundef %153, i32 noundef 6, ptr noundef %18)
  %155 = icmp eq i32 %154, -1
  br i1 %155, label %156, label %165

156:                                              ; preds = %143
  %157 = call ptr @__errno_location() #8
  %158 = load i32, ptr %157, align 4, !tbaa !9
  %159 = icmp ne i32 %158, 11
  br i1 %159, label %160, label %161

160:                                              ; preds = %156
  br label %161

161:                                              ; preds = %160, %156
  %162 = load ptr, ptr %5, align 8, !tbaa !5
  %163 = load i32, ptr %6, align 4, !tbaa !9
  %164 = load i32, ptr %7, align 4, !tbaa !9
  call void @logdb_log_inproc_unlock(ptr noundef %162, i32 noundef %163, i32 noundef %164)
  store i32 -3, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %166

165:                                              ; preds = %143
  store i32 0, ptr %4, align 4
  store i32 1, ptr %12, align 4
  br label %166

166:                                              ; preds = %165, %161, %141, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %167 = load i32, ptr %4, align 4
  ret i32 %167
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

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

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 allocsize(0,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 #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 = { nounwind willreturn memory(none) "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }
attributes #8 = { nounwind willreturn memory(none) }

!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 0}
!12 = !{!"logdb_log_lock_t", !10, i64 0, !7, i64 4, !7, i64 520}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!19, !20, i64 0}
!19 = !{!"flock", !20, i64 0, !20, i64 2, !21, i64 8, !21, i64 16, !10, i64 24}
!20 = !{!"short", !7, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!19, !20, i64 2}
!23 = !{!19, !21, i64 8}
!24 = !{!19, !21, i64 16}
!25 = !{!19, !10, i64 24}
!26 = !{!27, !10, i64 0}
!27 = !{!"", !10, i64 0, !6, i64 8, !7, i64 16}


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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @logdb_log_lock(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = alloca %struct.flock, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  br label %.outer

.outer:                                           ; preds = %23, %3
  %.sink = phi ptr [ %24, %23 ], [ %5, %3 ]
  %6 = load atomic volatile i64, ptr %.sink seq_cst, align 8
  br label %7

7:                                                ; preds = %.outer, %18
  %.051.in = phi i64 [ %19, %18 ], [ %6, %.outer ]
  %.051 = inttoptr i64 %.051.in to ptr
  %.not = icmp eq i64 %.051.in, 0
  br i1 %.not, label %11, label %8

8:                                                ; preds = %7
  %9 = load i32, ptr %.051, align 8, !tbaa !5
  %10 = icmp ugt i32 %9, %1
  br i1 %10, label %11, label %.thread65

11:                                               ; preds = %8, %7
  %12 = tail call noalias dereferenceable_or_null(528) ptr @calloc(i64 noundef 1, i64 noundef 528) #5
  %.not61 = icmp eq ptr %12, null
  br i1 %.not61, label %.thread, label %13

13:                                               ; preds = %11
  store i32 %1, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %12, i64 520
  store ptr %.051, ptr %14, align 8, !tbaa !10
  %15 = ptrtoint ptr %12 to i64
  %16 = cmpxchg volatile ptr %.sink, i64 %.051.in, i64 %15 seq_cst seq_cst, align 8
  %17 = extractvalue { i64, i1 } %16, 1
  br i1 %17, label %..thread65_crit_edge, label %18

..thread65_crit_edge:                             ; preds = %13
  %.pre = load i32, ptr %12, align 8, !tbaa !5
  br label %.thread65

18:                                               ; preds = %13
  %19 = extractvalue { i64, i1 } %16, 0
  tail call void @free(ptr noundef nonnull %12) #6
  br label %7

.thread65:                                        ; preds = %8, %..thread65_crit_edge
  %20 = phi i32 [ %.pre, %..thread65_crit_edge ], [ %9, %8 ]
  %.354 = phi ptr [ %12, %..thread65_crit_edge ], [ %.051, %8 ]
  %21 = sub i32 %1, %20
  %22 = icmp ugt i32 %21, 127
  br i1 %22, label %23, label %25

23:                                               ; preds = %.thread65
  %24 = getelementptr inbounds i8, ptr %.354, i64 520
  br label %.outer

25:                                               ; preds = %.thread65
  %26 = getelementptr inbounds i8, ptr %.354, i64 4
  %27 = zext nneg i32 %21 to i64
  %28 = getelementptr inbounds [128 x i32], ptr %26, i64 0, i64 %27
  %29 = load atomic volatile i32, ptr %28 seq_cst, align 4, !tbaa !10
  %30 = icmp eq i32 %2, 1
  br i1 %30, label %.split, label %.split.us

.split.us:                                        ; preds = %25
  %31 = icmp eq i32 %2, 2
  %32 = icmp eq i32 %29, 0
  %or.cond3.us71 = select i1 %31, i1 %32, i1 false
  br i1 %or.cond3.us71, label %.backedge.us, label %.thread

33:                                               ; preds = %.backedge.us
  %34 = extractvalue { i32, i1 } %36, 0
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %.backedge.us, label %.thread

.backedge.us:                                     ; preds = %.split.us, %33
  %36 = cmpxchg weak volatile ptr %28, i32 0, i32 -1 seq_cst seq_cst, align 4
  %37 = extractvalue { i32, i1 } %36, 1
  br i1 %37, label %.split70.us, label %33

.split:                                           ; preds = %25, %39
  %.056 = phi i32 [ %43, %39 ], [ %29, %25 ]
  %38 = icmp sgt i32 %.056, -1
  br i1 %38, label %39, label %.thread

39:                                               ; preds = %.split
  %40 = add nuw nsw i32 %.056, 1
  %41 = cmpxchg weak volatile ptr %28, i32 %.056, i32 %40 seq_cst seq_cst, align 4
  %42 = extractvalue { i32, i1 } %41, 1
  %43 = extractvalue { i32, i1 } %41, 0
  br i1 %42, label %.split70.us, label %.split

.split70.us:                                      ; preds = %.backedge.us, %39
  %.us-phi = phi i16 [ 0, %39 ], [ 1, %.backedge.us ]
  store i16 %.us-phi, ptr %4, align 8, !tbaa !11
  %44 = getelementptr inbounds i8, ptr %4, i64 2
  store i16 0, ptr %44, align 2, !tbaa !15
  %45 = tail call i64 @logdb_log_offset(i32 noundef %1)
  %46 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %45, ptr %46, align 8, !tbaa !16
  %47 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 2, ptr %47, align 8, !tbaa !17
  %48 = tail call i32 @getpid() #6
  %49 = getelementptr inbounds i8, ptr %4, i64 24
  store i32 %48, ptr %49, align 8, !tbaa !18
  %50 = load i32, ptr %0, align 8, !tbaa !19
  %51 = call i32 (i32, i32, ...) @fcntl(i32 noundef %50, i32 noundef 6, ptr noundef nonnull %4) #6
  %52 = icmp eq i32 %51, -1
  br i1 %52, label %53, label %.thread

53:                                               ; preds = %.split70.us
  call void @logdb_log_inproc_unlock(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2)
  br label %.thread

.thread:                                          ; preds = %11, %33, %.split, %.split.us, %.split70.us, %53
  %.3 = phi i32 [ -3, %53 ], [ 0, %.split70.us ], [ -2, %.split.us ], [ -2, %.split ], [ -2, %33 ], [ -1, %11 ]
  ret i32 %.3
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

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

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

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

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 = { nounwind allocsize(0,1) }
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, !7, i64 0}
!6 = !{!"logdb_log_lock_t", !7, i64 0, !8, i64 4, !8, i64 520}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !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, !14, i64 8}
!17 = !{!12, !14, i64 16}
!18 = !{!12, !7, i64 24}
!19 = !{!20, !7, i64 0}
!20 = !{!"", !7, i64 0, !21, i64 8, !8, i64 16}
!21 = !{!"any pointer", !8, i64 0}


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