; LLVM IR from vczh/herodb :: Kernel/Source/Utility/Log.ll (ZN2vl8database12log_internal9LogReader8NextItemEv)

; 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.vl::database::IdObject.15" = type { i64 }
%"struct.vl::database::IdObject.16" = type { i64 }
%"struct.vl::database::IdObject" = type { i32 }
%"class.vl::database::log_internal::LogReader" = type { %"class.vl::Object", %"class.vl::database::ILogReader", ptr, ptr, %"struct.vl::database::IdObject", ptr, ptr, %"struct.vl::database::IdObject.17", %"struct.vl::database::IdObject.16", %"class.vl::Ptr.38" }
%"class.vl::Object" = type { ptr }
%"class.vl::database::ILogReader" = type { %"class.vl::database::ILogAccessor" }
%"class.vl::database::ILogAccessor" = type { %"class.vl::Interface" }
%"class.vl::Interface" = type { ptr }
%"struct.vl::database::IdObject.17" = type { i64 }
%"class.vl::Ptr.38" = type { ptr, ptr, ptr, ptr }

@_ZTIN2vl5ErrorE = external dso_local constant { ptr, ptr }, align 8
@.str.7 = external hidden unnamed_addr constant [98 x i32], align 4
@.str.8 = external hidden unnamed_addr constant [89 x i32], align 4
@.str.9 = external hidden unnamed_addr constant [92 x i32], align 4

; 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) #0

declare i32 @__gxx_personality_v0(...)

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

declare noundef ptr @_ZN2vl8database13BufferManager8LockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEE(ptr noundef nonnull align 8 dereferenceable(168), i32, i64) #2

declare noundef zeroext i1 @_ZN2vl8database13BufferManager10UnlockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEEPvNS0_15PersistanceTypeE(ptr noundef nonnull align 8 dereferenceable(168), i32, i64, ptr noundef, i32 noundef) #2

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

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #2

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl8database8IdObjectImLl2EE7IsValidEv(ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl8database8IdObjectImLl1EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 align 2

declare noundef zeroext i1 @_ZN2vl8database13BufferManager13DecodePointerENS0_8IdObjectImLl2EEERNS2_ImLl1EEERm(ptr noundef nonnull align 8 dereferenceable(168), i64, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

declare void @_ZN2vl6stream12MemoryStreamC1El(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) unnamed_addr #2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl8database12log_internal9LogReader8NextItemEv(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca %"struct.vl::database::IdObject.15", align 8
  %7 = alloca i64, align 8
  %8 = alloca %"struct.vl::database::IdObject.16", align 8
  %9 = alloca ptr, align 8
  %10 = alloca %"struct.vl::database::IdObject", align 4
  %11 = alloca %"struct.vl::database::IdObject.15", align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca %"struct.vl::database::IdObject", align 4
  %17 = alloca %"struct.vl::database::IdObject.15", align 8
  %18 = alloca i32, align 4
  %19 = alloca %"struct.vl::database::IdObject.16", align 8
  %20 = alloca %"struct.vl::database::IdObject", align 4
  %21 = alloca %"struct.vl::database::IdObject.15", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %22 = load ptr, ptr %3, align 8
  %23 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 8
  %24 = call noundef zeroext i1 @_ZNK2vl8database8IdObjectImLl2EE7IsValidEv(ptr noundef nonnull align 8 dereferenceable(8) %23)
  br i1 %24, label %26, label %25

25:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %167

26:                                               ; preds = %1
  %27 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 56) #7
  invoke void @_ZN2vl6stream12MemoryStreamC1El(ptr noundef nonnull align 8 dereferenceable(48) %27, i64 noundef 65536)
          to label %28 unwind label %41

28:                                               ; preds = %26
  %29 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 9
  %30 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl3PtrINS_6stream12MemoryStreamEEaSEPS2_(ptr noundef nonnull align 8 dereferenceable(32) %29, ptr noundef %27)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  call void @_ZN2vl8database8IdObjectImLl1EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  br label %31

31:                                               ; preds = %28
  %32 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 3
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %34, i64 8, i1 false), !tbaa.struct !19
  %35 = getelementptr inbounds %"struct.vl::database::IdObject.16", ptr %8, i32 0, i32 0
  %36 = load i64, ptr %35, align 8
  %37 = call noundef zeroext i1 @_ZN2vl8database13BufferManager13DecodePointerENS0_8IdObjectImLl2EEERNS2_ImLl1EEERm(ptr noundef nonnull align 8 dereferenceable(168) %33, i64 %36, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  br i1 %37, label %49, label %38

38:                                               ; preds = %31
  %39 = call ptr @__cxa_allocate_exception(i64 8) #8
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef @.str.7)
          to label %40 unwind label %45

40:                                               ; preds = %38
  call void @__cxa_throw(ptr %39, ptr @_ZTIN2vl5ErrorE, ptr null) #9
  unreachable

41:                                               ; preds = %26
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %4, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %5, align 4
  call void @_ZdlPvm(ptr noundef %27, i64 noundef 56) #10
  br label %169

45:                                               ; preds = %38
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %4, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %5, align 4
  call void @__cxa_free_exception(ptr %39) #8
  br label %166

49:                                               ; preds = %31
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %52 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %54, i64 4, i1 false), !tbaa.struct !21
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %6, i64 8, i1 false), !tbaa.struct !19
  %55 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %10, i32 0, i32 0
  %56 = load i32, ptr %55, align 4
  %57 = getelementptr inbounds %"struct.vl::database::IdObject.15", ptr %11, i32 0, i32 0
  %58 = load i64, ptr %57, align 8
  %59 = call noundef ptr @_ZN2vl8database13BufferManager8LockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEE(ptr noundef nonnull align 8 dereferenceable(168) %53, i32 %56, i64 %58)
  store ptr %59, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load i64, ptr %7, align 8, !tbaa !20
  %62 = getelementptr inbounds i8, ptr %60, i64 %61
  store ptr %62, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #8
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds i64, ptr %63, i64 0
  %65 = load i64, ptr %64, align 8, !tbaa !20
  store i64 %65, ptr %13, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #8
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = getelementptr inbounds i64, ptr %66, i64 1
  store ptr %67, ptr %14, align 8, !tbaa !5
  br label %68

68:                                               ; preds = %158, %51
  br label %69

69:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %70 = load ptr, ptr %14, align 8, !tbaa !5
  %71 = getelementptr inbounds i64, ptr %70, i64 0
  %72 = load i64, ptr %71, align 8, !tbaa !20
  store i64 %72, ptr %15, align 8, !tbaa !20
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  %74 = getelementptr inbounds i64, ptr %73, i64 1
  %75 = load i64, ptr %74, align 8, !tbaa !20
  %76 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 8
  %77 = getelementptr inbounds %"struct.vl::database::IdObject.16", ptr %76, i32 0, i32 0
  store i64 %75, ptr %77, align 8, !tbaa !23
  %78 = load i64, ptr %15, align 8, !tbaa !20
  %79 = load i64, ptr %13, align 8, !tbaa !20
  %80 = icmp ugt i64 %78, %79
  br i1 %80, label %81, label %83

81:                                               ; preds = %69
  %82 = load i64, ptr %13, align 8, !tbaa !20
  store i64 %82, ptr %15, align 8, !tbaa !20
  br label %83

83:                                               ; preds = %81, %69
  %84 = load i64, ptr %15, align 8, !tbaa !20
  %85 = icmp ugt i64 %84, 0
  br i1 %85, label %86, label %96

86:                                               ; preds = %83
  %87 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 9
  %88 = call noundef ptr @_ZNK2vl3PtrINS_6stream12MemoryStreamEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %87)
  %89 = load ptr, ptr %14, align 8, !tbaa !5
  %90 = getelementptr inbounds i64, ptr %89, i64 2
  %91 = load i64, ptr %15, align 8, !tbaa !20
  %92 = load ptr, ptr %88, align 8, !tbaa !24
  %93 = getelementptr inbounds ptr, ptr %92, i64 15
  %94 = load ptr, ptr %93, align 8
  %95 = call noundef i64 %94(ptr noundef nonnull align 8 dereferenceable(48) %88, ptr noundef %90, i64 noundef %91)
  br label %96

96:                                               ; preds = %86, %83
  %97 = load i64, ptr %15, align 8, !tbaa !20
  %98 = load i64, ptr %13, align 8, !tbaa !20
  %99 = sub i64 %98, %97
  store i64 %99, ptr %13, align 8, !tbaa !20
  br label %100

100:                                              ; preds = %96
  %101 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 3
  %102 = load ptr, ptr %101, align 8, !tbaa !9
  %103 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 8 %103, i64 4, i1 false), !tbaa.struct !21
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 8 %6, i64 8, i1 false), !tbaa.struct !19
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  %105 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %16, i32 0, i32 0
  %106 = load i32, ptr %105, align 4
  %107 = getelementptr inbounds %"struct.vl::database::IdObject.15", ptr %17, i32 0, i32 0
  %108 = load i64, ptr %107, align 8
  %109 = call noundef zeroext i1 @_ZN2vl8database13BufferManager10UnlockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEEPvNS0_15PersistanceTypeE(ptr noundef nonnull align 8 dereferenceable(168) %102, i32 %106, i64 %108, ptr noundef %104, i32 noundef 0)
  br i1 %109, label %117, label %110

110:                                              ; preds = %100
  %111 = call ptr @__cxa_allocate_exception(i64 8) #8
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %111, ptr noundef @.str.8)
          to label %112 unwind label %113

112:                                              ; preds = %110
  call void @__cxa_throw(ptr %111, ptr @_ZTIN2vl5ErrorE, ptr null) #9
  unreachable

113:                                              ; preds = %110
  %114 = landingpad { ptr, i32 }
          cleanup
  %115 = extractvalue { ptr, i32 } %114, 0
  store ptr %115, ptr %4, align 8
  %116 = extractvalue { ptr, i32 } %114, 1
  store i32 %116, ptr %5, align 4
  call void @__cxa_free_exception(ptr %111) #8
  br label %159

117:                                              ; preds = %100
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  %120 = load i64, ptr %13, align 8, !tbaa !20
  %121 = icmp eq i64 %120, 0
  br i1 %121, label %125, label %122

122:                                              ; preds = %119
  %123 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 8
  %124 = call noundef zeroext i1 @_ZNK2vl8database8IdObjectImLl2EE7IsValidEv(ptr noundef nonnull align 8 dereferenceable(8) %123)
  br i1 %124, label %126, label %125

125:                                              ; preds = %122, %119
  store i32 5, ptr %18, align 4
  br label %156

126:                                              ; preds = %122
  br label %127

127:                                              ; preds = %126
  %128 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 3
  %129 = load ptr, ptr %128, align 8, !tbaa !9
  %130 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 8 %130, i64 8, i1 false), !tbaa.struct !19
  %131 = getelementptr inbounds %"struct.vl::database::IdObject.16", ptr %19, i32 0, i32 0
  %132 = load i64, ptr %131, align 8
  %133 = call noundef zeroext i1 @_ZN2vl8database13BufferManager13DecodePointerENS0_8IdObjectImLl2EEERNS2_ImLl1EEERm(ptr noundef nonnull align 8 dereferenceable(168) %129, i64 %132, ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  br i1 %133, label %141, label %134

134:                                              ; preds = %127
  %135 = call ptr @__cxa_allocate_exception(i64 8) #8
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %135, ptr noundef @.str.9)
          to label %136 unwind label %137

136:                                              ; preds = %134
  call void @__cxa_throw(ptr %135, ptr @_ZTIN2vl5ErrorE, ptr null) #9
  unreachable

137:                                              ; preds = %134
  %138 = landingpad { ptr, i32 }
          cleanup
  %139 = extractvalue { ptr, i32 } %138, 0
  store ptr %139, ptr %4, align 8
  %140 = extractvalue { ptr, i32 } %138, 1
  store i32 %140, ptr %5, align 4
  call void @__cxa_free_exception(ptr %135) #8
  br label %159

141:                                              ; preds = %127
  br label %142

142:                                              ; preds = %141
  br label %143

143:                                              ; preds = %142
  %144 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 3
  %145 = load ptr, ptr %144, align 8, !tbaa !9
  %146 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 8 %146, i64 4, i1 false), !tbaa.struct !21
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %21, ptr align 8 %6, i64 8, i1 false), !tbaa.struct !19
  %147 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %20, i32 0, i32 0
  %148 = load i32, ptr %147, align 4
  %149 = getelementptr inbounds %"struct.vl::database::IdObject.15", ptr %21, i32 0, i32 0
  %150 = load i64, ptr %149, align 8
  %151 = call noundef ptr @_ZN2vl8database13BufferManager8LockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEE(ptr noundef nonnull align 8 dereferenceable(168) %145, i32 %148, i64 %150)
  store ptr %151, ptr %9, align 8, !tbaa !5
  %152 = load ptr, ptr %9, align 8, !tbaa !5
  %153 = load i64, ptr %7, align 8, !tbaa !20
  %154 = getelementptr inbounds i8, ptr %152, i64 %153
  store ptr %154, ptr %12, align 8, !tbaa !5
  %155 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %155, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %18, align 4
  br label %156

156:                                              ; preds = %143, %125
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  %157 = load i32, ptr %18, align 4
  switch i32 %157, label %174 [
    i32 0, label %158
    i32 5, label %160
  ]

158:                                              ; preds = %156
  br label %68, !llvm.loop !26

159:                                              ; preds = %137, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  br label %166

160:                                              ; preds = %156
  %161 = getelementptr inbounds %"class.vl::database::log_internal::LogReader", ptr %22, i32 0, i32 9
  %162 = call noundef ptr @_ZNK2vl3PtrINS_6stream12MemoryStreamEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %161)
  %163 = load ptr, ptr %162, align 8, !tbaa !24
  %164 = getelementptr inbounds ptr, ptr %163, i64 12
  %165 = load ptr, ptr %164, align 8
  call void %165(ptr noundef nonnull align 8 dereferenceable(48) %162, i64 noundef 0)
  store i1 true, ptr %2, align 1
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  br label %167

166:                                              ; preds = %159, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  br label %169

167:                                              ; preds = %160, %25
  %168 = load i1, ptr %2, align 1
  ret i1 %168

169:                                              ; preds = %166, %41
  %170 = load ptr, ptr %4, align 8
  %171 = load i32, ptr %5, align 4
  %172 = insertvalue { ptr, i32 } poison, ptr %170, 0
  %173 = insertvalue { ptr, i32 } %172, i32 %171, 1
  resume { ptr, i32 } %173

174:                                              ; preds = %156
  unreachable
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #6

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl3PtrINS_6stream12MemoryStreamEEaSEPS2_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #5 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2vl3PtrINS_6stream12MemoryStreamEEptEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 #4 = { nobuiltin 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 #5 = { mustprogress 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 #6 = { nobuiltin allocsize(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 #7 = { builtin allocsize(0) }
attributes #8 = { nounwind }
attributes #9 = { noreturn }
attributes #10 = { builtin 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++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"_ZTSN2vl8database12log_internal9LogReaderE", !11, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !6, i64 40, !6, i64 48, !15, i64 56, !17, i64 64, !18, i64 72}
!11 = !{!"_ZTSN2vl6ObjectE"}
!12 = !{!"_ZTSN2vl8database10ILogReaderE"}
!13 = !{!"_ZTSN2vl8database8IdObjectIiLl0EEE", !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_ZTSN2vl8database8IdObjectImLl3EEE", !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN2vl8database8IdObjectImLl2EEE", !16, i64 0}
!18 = !{!"_ZTSN2vl3PtrINS_6stream12MemoryStreamEEE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{i64 0, i64 8, !20}
!20 = !{!16, !16, i64 0}
!21 = !{i64 0, i64 4, !22}
!22 = !{!14, !14, i64 0}
!23 = !{!10, !16, i64 64}
!24 = !{!25, !25, i64 0}
!25 = !{!"vtable pointer", !8, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


; 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.vl::database::IdObject.15" = type { i64 }

@_ZTIN2vl5ErrorE = external dso_local constant { ptr, ptr }, align 8
@.str.7 = external hidden unnamed_addr constant [98 x i32], align 4
@.str.8 = external hidden unnamed_addr constant [89 x i32], align 4
@.str.9 = external hidden unnamed_addr constant [92 x i32], align 4

declare i32 @__gxx_personality_v0(...)

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

declare noundef ptr @_ZN2vl8database13BufferManager8LockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEE(ptr noundef nonnull align 8 dereferenceable(168), i32, i64) local_unnamed_addr #1

declare noundef zeroext i1 @_ZN2vl8database13BufferManager10UnlockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEEPvNS0_15PersistanceTypeE(ptr noundef nonnull align 8 dereferenceable(168), i32, i64, ptr noundef, i32 noundef) local_unnamed_addr #1

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

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #1

declare void @__cxa_free_exception(ptr) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK2vl8database8IdObjectImLl2EE7IsValidEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl8database8IdObjectImLl1EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 align 2

declare noundef zeroext i1 @_ZN2vl8database13BufferManager13DecodePointerENS0_8IdObjectImLl2EEERNS2_ImLl1EEERm(ptr noundef nonnull align 8 dereferenceable(168), i64, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

declare void @_ZN2vl6stream12MemoryStreamC1El(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef) unnamed_addr #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl8database12log_internal9LogReader8NextItemEv(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"struct.vl::database::IdObject.15", align 8
  %3 = alloca i64, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  %5 = tail call noundef zeroext i1 @_ZNK2vl8database8IdObjectImLl2EE7IsValidEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %5, label %6, label %72

6:                                                ; preds = %1
  %7 = tail call noalias noundef nonnull dereferenceable(56) ptr @_Znwm(i64 noundef 56) #7
  invoke void @_ZN2vl6stream12MemoryStreamC1El(ptr noundef nonnull align 8 dereferenceable(48) %7, i64 noundef 65536)
          to label %8 unwind label %17

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  %10 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl3PtrINS_6stream12MemoryStreamEEaSEPS2_(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  call void @_ZN2vl8database8IdObjectImLl1EEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %.sroa.023.0.copyload = load i64, ptr %4, align 8, !tbaa !18
  %13 = call noundef zeroext i1 @_ZN2vl8database13BufferManager13DecodePointerENS0_8IdObjectImLl2EEERNS2_ImLl1EEERm(ptr noundef nonnull align 8 dereferenceable(168) %12, i64 %.sroa.023.0.copyload, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br i1 %13, label %21, label %14

14:                                               ; preds = %8
  %15 = call ptr @__cxa_allocate_exception(i64 8) #8
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull @.str.7)
          to label %16 unwind label %19

16:                                               ; preds = %14
  call void @__cxa_throw(ptr nonnull %15, ptr nonnull @_ZTIN2vl5ErrorE, ptr null) #9
  unreachable

17:                                               ; preds = %6
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %7, i64 noundef 56) #10
  br label %73

19:                                               ; preds = %14
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %71

21:                                               ; preds = %8
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  %.sroa.019.0.copyload = load i32, ptr %23, align 8, !tbaa !19
  %.sroa.018.0.copyload = load i64, ptr %2, align 8, !tbaa !18
  %24 = call noundef ptr @_ZN2vl8database13BufferManager8LockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEE(ptr noundef nonnull align 8 dereferenceable(168) %22, i32 %.sroa.019.0.copyload, i64 %.sroa.018.0.copyload)
  %25 = load i64, ptr %3, align 8, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %24, i64 %25
  %27 = load i64, ptr %26, align 8, !tbaa !18
  %28 = getelementptr inbounds i8, ptr %26, i64 8
  br label %29

29:                                               ; preds = %61, %21
  %.038 = phi i64 [ %27, %21 ], [ %41, %61 ]
  %.036 = phi ptr [ %28, %21 ], [ %65, %61 ]
  %.033 = phi ptr [ %24, %21 ], [ %63, %61 ]
  %30 = load i64, ptr %.036, align 8, !tbaa !18
  %31 = getelementptr inbounds i8, ptr %.036, i64 8
  %32 = load i64, ptr %31, align 8, !tbaa !18
  store i64 %32, ptr %4, align 8, !tbaa !20
  %spec.select = call i64 @llvm.umin.i64(i64 %30, i64 %.038)
  %.not = icmp eq i64 %spec.select, 0
  br i1 %.not, label %40, label %33

33:                                               ; preds = %29
  %34 = call noundef ptr @_ZNK2vl3PtrINS_6stream12MemoryStreamEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %35 = getelementptr inbounds i8, ptr %.036, i64 16
  %36 = load ptr, ptr %34, align 8, !tbaa !21
  %37 = getelementptr inbounds i8, ptr %36, i64 120
  %38 = load ptr, ptr %37, align 8
  %39 = call noundef i64 %38(ptr noundef nonnull align 8 dereferenceable(48) %34, ptr noundef nonnull %35, i64 noundef %spec.select)
  br label %40

40:                                               ; preds = %33, %29
  %41 = sub i64 %.038, %spec.select
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %.sroa.04.0.copyload = load i32, ptr %23, align 8, !tbaa !19
  %.sroa.03.0.copyload = load i64, ptr %2, align 8, !tbaa !18
  %43 = call noundef zeroext i1 @_ZN2vl8database13BufferManager10UnlockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEEPvNS0_15PersistanceTypeE(ptr noundef nonnull align 8 dereferenceable(168) %42, i32 %.sroa.04.0.copyload, i64 %.sroa.03.0.copyload, ptr noundef %.033, i32 noundef 0)
  br i1 %43, label %49, label %44

44:                                               ; preds = %40
  %45 = call ptr @__cxa_allocate_exception(i64 8) #8
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %45, ptr noundef nonnull @.str.8)
          to label %46 unwind label %47

46:                                               ; preds = %44
  call void @__cxa_throw(ptr nonnull %45, ptr nonnull @_ZTIN2vl5ErrorE, ptr null) #9
  unreachable

47:                                               ; preds = %44
  %48 = landingpad { ptr, i32 }
          cleanup
  br label %71

49:                                               ; preds = %40
  %50 = icmp eq i64 %41, 0
  br i1 %50, label %66, label %51

51:                                               ; preds = %49
  %52 = call noundef zeroext i1 @_ZNK2vl8database8IdObjectImLl2EE7IsValidEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  br i1 %52, label %53, label %66

53:                                               ; preds = %51
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %.sroa.02.0.copyload = load i64, ptr %4, align 8, !tbaa !18
  %55 = call noundef zeroext i1 @_ZN2vl8database13BufferManager13DecodePointerENS0_8IdObjectImLl2EEERNS2_ImLl1EEERm(ptr noundef nonnull align 8 dereferenceable(168) %54, i64 %.sroa.02.0.copyload, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br i1 %55, label %61, label %56

56:                                               ; preds = %53
  %57 = call ptr @__cxa_allocate_exception(i64 8) #8
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %57, ptr noundef nonnull @.str.9)
          to label %58 unwind label %59

58:                                               ; preds = %56
  call void @__cxa_throw(ptr nonnull %57, ptr nonnull @_ZTIN2vl5ErrorE, ptr null) #9
  unreachable

59:                                               ; preds = %56
  %60 = landingpad { ptr, i32 }
          cleanup
  br label %71

61:                                               ; preds = %53
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %.sroa.01.0.copyload = load i32, ptr %23, align 8, !tbaa !19
  %.sroa.0.0.copyload = load i64, ptr %2, align 8, !tbaa !18
  %63 = call noundef ptr @_ZN2vl8database13BufferManager8LockPageENS0_8IdObjectIiLl0EEENS2_ImLl1EEE(ptr noundef nonnull align 8 dereferenceable(168) %62, i32 %.sroa.01.0.copyload, i64 %.sroa.0.0.copyload)
  %64 = load i64, ptr %3, align 8, !tbaa !18
  %65 = getelementptr inbounds i8, ptr %63, i64 %64
  br label %29

66:                                               ; preds = %51, %49
  %67 = call noundef ptr @_ZNK2vl3PtrINS_6stream12MemoryStreamEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %9)
  %68 = load ptr, ptr %67, align 8, !tbaa !21
  %69 = getelementptr inbounds i8, ptr %68, i64 96
  %70 = load ptr, ptr %69, align 8
  call void %70(ptr noundef nonnull align 8 dereferenceable(48) %67, i64 noundef 0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  br label %72

71:                                               ; preds = %47, %59, %19
  %.sink = phi ptr [ %45, %47 ], [ %57, %59 ], [ %15, %19 ]
  %.pn.pn = phi { ptr, i32 } [ %48, %47 ], [ %60, %59 ], [ %20, %19 ]
  call void @__cxa_free_exception(ptr %.sink) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  br label %73

72:                                               ; preds = %1, %66
  ret i1 %5

73:                                               ; preds = %71, %17
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %71 ], [ %18, %17 ]
  resume { ptr, i32 } %.pn.pn.pn
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl3PtrINS_6stream12MemoryStreamEEaSEPS2_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2vl3PtrINS_6stream12MemoryStreamEEptEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #6

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 = { mustprogress 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 = { nobuiltin 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 = { mustprogress 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 #5 = { nobuiltin allocsize(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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { nounwind }
attributes #9 = { noreturn }
attributes #10 = { builtin 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, !9, i64 24}
!6 = !{!"_ZTSN2vl8database12log_internal9LogReaderE", !7, i64 0, !8, i64 8, !9, i64 16, !9, i64 24, !12, i64 32, !9, i64 40, !9, i64 48, !14, i64 56, !16, i64 64, !17, i64 72}
!7 = !{!"_ZTSN2vl6ObjectE"}
!8 = !{!"_ZTSN2vl8database10ILogReaderE"}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN2vl8database8IdObjectIiLl0EEE", !13, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = !{!"_ZTSN2vl8database8IdObjectImLl3EEE", !15, i64 0}
!15 = !{!"long", !10, i64 0}
!16 = !{!"_ZTSN2vl8database8IdObjectImLl2EEE", !15, i64 0}
!17 = !{!"_ZTSN2vl3PtrINS_6stream12MemoryStreamEEE", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24}
!18 = !{!15, !15, i64 0}
!19 = !{!13, !13, i64 0}
!20 = !{!6, !15, i64 64}
!21 = !{!22, !22, i64 0}
!22 = !{!"vtable pointer", !11, i64 0}


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