; LLVM IR from pixelsdb/mini-pixels :: pixels-core/lib/encoding/RunLenIntEncoder.ll (ZN16RunLenIntEncoder5writeEl)

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

%class.RunLenIntEncoder = type { i32, i32, i32, i32, i8, i8, i64, i64, i32, i8, i32, i32, i32, ptr, i32, i32, i32, i32, i32, i64, ptr, ptr, ptr, ptr, %class.EncodingUtils, %"class.std::shared_ptr" }
%class.EncodingUtils = type { ptr, ptr }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

@_ZN9Constants9MAX_SCOPEE = external global i32, align 4
@_ZN9Constants10MIN_REPEATE = external global i32, align 4
@_ZN9Constants23MAX_SHORT_REPEAT_LENGTHE = external global i32, align 4

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #1

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16RunLenIntEncoder5writeEl(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %1) #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %9 = load i32, ptr %8, align 4, !tbaa !11
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %2
  %12 = load i64, ptr %4, align 8, !tbaa !9
  call void @_ZN16RunLenIntEncoder18initializeLiteralsEl(ptr noundef nonnull align 8 dereferenceable(168) %7, i64 noundef %12)
  br label %221

13:                                               ; preds = %2
  %14 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %46

17:                                               ; preds = %13
  %18 = load i64, ptr %4, align 8, !tbaa !9
  %19 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %20 = load ptr, ptr %19, align 8, !tbaa !20
  %21 = getelementptr inbounds i64, ptr %20, i64 0
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = sub nsw i64 %18, %22
  %24 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 6
  store i64 %23, ptr %24, align 8, !tbaa !21
  %25 = load i64, ptr %4, align 8, !tbaa !9
  %26 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %27 = load ptr, ptr %26, align 8, !tbaa !20
  %28 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !11
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 4, !tbaa !11
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds i64, ptr %27, i64 %31
  store i64 %25, ptr %32, align 8, !tbaa !9
  %33 = load i64, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %35 = load ptr, ptr %34, align 8, !tbaa !20
  %36 = getelementptr inbounds i64, ptr %35, i64 0
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = icmp eq i64 %33, %37
  br i1 %38, label %39, label %42

39:                                               ; preds = %17
  %40 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  store i32 2, ptr %40, align 8, !tbaa !22
  %41 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  store i32 0, ptr %41, align 4, !tbaa !23
  br label %45

42:                                               ; preds = %17
  %43 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  store i32 0, ptr %43, align 8, !tbaa !22
  %44 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  store i32 2, ptr %44, align 4, !tbaa !23
  br label %45

45:                                               ; preds = %42, %39
  br label %220

46:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %47 = load i64, ptr %4, align 8, !tbaa !9
  %48 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %49 = load ptr, ptr %48, align 8, !tbaa !20
  %50 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = sub nsw i32 %51, 1
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i64, ptr %49, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !9
  %56 = sub nsw i64 %47, %55
  store i64 %56, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 6
  %58 = load i64, ptr %57, align 8, !tbaa !21
  %59 = icmp eq i64 %58, 0
  br i1 %59, label %60, label %141

60:                                               ; preds = %46
  %61 = load i64, ptr %5, align 8, !tbaa !9
  %62 = icmp eq i64 %61, 0
  br i1 %62, label %63, label %141

63:                                               ; preds = %60
  %64 = load i64, ptr %4, align 8, !tbaa !9
  %65 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %66 = load ptr, ptr %65, align 8, !tbaa !20
  %67 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %67, align 4, !tbaa !11
  %70 = sext i32 %68 to i64
  %71 = getelementptr inbounds i64, ptr %66, i64 %70
  store i64 %64, ptr %71, align 8, !tbaa !9
  %72 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  %73 = load i32, ptr %72, align 4, !tbaa !23
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %75, label %77

75:                                               ; preds = %63
  %76 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  store i32 2, ptr %76, align 8, !tbaa !22
  br label %77

77:                                               ; preds = %75, %63
  %78 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %79 = load i32, ptr %78, align 8, !tbaa !22
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %78, align 8, !tbaa !22
  %81 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %82 = load i32, ptr %81, align 8, !tbaa !22
  %83 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %84 = icmp sge i32 %82, %83
  br i1 %84, label %85, label %134

85:                                               ; preds = %77
  %86 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  %87 = load i32, ptr %86, align 4, !tbaa !23
  %88 = icmp sgt i32 %87, 0
  br i1 %88, label %89, label %134

89:                                               ; preds = %85
  %90 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %91 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %92 = load i32, ptr %91, align 4, !tbaa !11
  %93 = sub nsw i32 %92, %90
  store i32 %93, ptr %91, align 4, !tbaa !11
  %94 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %95 = sub nsw i32 %94, 1
  %96 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  %97 = load i32, ptr %96, align 4, !tbaa !23
  %98 = sub nsw i32 %97, %95
  store i32 %98, ptr %96, align 4, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %99 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %100 = sext i32 %99 to i64
  %101 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %100, i64 8)
  %102 = extractvalue { i64, i1 } %101, 1
  %103 = extractvalue { i64, i1 } %101, 0
  %104 = select i1 %102, i64 -1, i64 %103
  %105 = call noalias noundef nonnull ptr @_Znam(i64 noundef %104) #8
  store ptr %105, ptr %6, align 8, !tbaa !5
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %108 = load ptr, ptr %107, align 8, !tbaa !20
  %109 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %110 = load i32, ptr %109, align 4, !tbaa !11
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i64, ptr %108, i64 %111
  %113 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %114 = sext i32 %113 to i64
  %115 = mul i64 %114, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %106, ptr align 8 %112, i64 %115, i1 false)
  call void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  %116 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %117 = load ptr, ptr %116, align 8, !tbaa !20
  %118 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %119 = load i32, ptr %118, align 4, !tbaa !11
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i64, ptr %117, i64 %120
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %124 = sext i32 %123 to i64
  %125 = mul i64 %124, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %121, ptr align 8 %122, i64 %125, i1 false)
  %126 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %127 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %128 = load i32, ptr %127, align 4, !tbaa !11
  %129 = add nsw i32 %128, %126
  store i32 %129, ptr %127, align 4, !tbaa !11
  %130 = load ptr, ptr %6, align 8, !tbaa !5
  %131 = icmp eq ptr %130, null
  br i1 %131, label %133, label %132

132:                                              ; preds = %89
  call void @_ZdaPv(ptr noundef %130) #9
  br label %133

133:                                              ; preds = %132, %89
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br label %134

134:                                              ; preds = %133, %85, %77
  %135 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %136 = load i32, ptr %135, align 8, !tbaa !22
  %137 = load i32, ptr @_ZN9Constants9MAX_SCOPEE, align 4, !tbaa !24
  %138 = icmp eq i32 %136, %137
  br i1 %138, label %139, label %140

139:                                              ; preds = %134
  call void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  br label %140

140:                                              ; preds = %139, %134
  br label %219

141:                                              ; preds = %60, %46
  %142 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %143 = load i32, ptr %142, align 8, !tbaa !22
  %144 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %145 = icmp sge i32 %143, %144
  br i1 %145, label %146, label %157

146:                                              ; preds = %141
  %147 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %148 = load i32, ptr %147, align 8, !tbaa !22
  %149 = load i32, ptr @_ZN9Constants23MAX_SHORT_REPEAT_LENGTHE, align 4, !tbaa !24
  %150 = icmp sle i32 %148, %149
  br i1 %150, label %151, label %153

151:                                              ; preds = %146
  %152 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 0
  store i32 0, ptr %152, align 8, !tbaa !25
  call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  br label %156

153:                                              ; preds = %146
  %154 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 0
  store i32 3, ptr %154, align 8, !tbaa !25
  %155 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 9
  store i8 1, ptr %155, align 4, !tbaa !26
  call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  br label %156

156:                                              ; preds = %153, %151
  br label %157

157:                                              ; preds = %156, %141
  %158 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %159 = load i32, ptr %158, align 8, !tbaa !22
  %160 = icmp sgt i32 %159, 0
  br i1 %160, label %161, label %183

161:                                              ; preds = %157
  %162 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %163 = load i32, ptr %162, align 8, !tbaa !22
  %164 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !24
  %165 = icmp slt i32 %163, %164
  br i1 %165, label %166, label %183

166:                                              ; preds = %161
  %167 = load i64, ptr %4, align 8, !tbaa !9
  %168 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %169 = load ptr, ptr %168, align 8, !tbaa !20
  %170 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %171 = load i32, ptr %170, align 4, !tbaa !11
  %172 = sub nsw i32 %171, 1
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds i64, ptr %169, i64 %173
  %175 = load i64, ptr %174, align 8, !tbaa !9
  %176 = icmp ne i64 %167, %175
  br i1 %176, label %177, label %182

177:                                              ; preds = %166
  %178 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  %179 = load i32, ptr %178, align 8, !tbaa !22
  %180 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  store i32 %179, ptr %180, align 4, !tbaa !23
  %181 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 2
  store i32 0, ptr %181, align 8, !tbaa !22
  br label %182

182:                                              ; preds = %177, %166
  br label %183

183:                                              ; preds = %182, %161, %157
  %184 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %185 = load i32, ptr %184, align 4, !tbaa !11
  %186 = icmp eq i32 %185, 0
  br i1 %186, label %187, label %189

187:                                              ; preds = %183
  %188 = load i64, ptr %4, align 8, !tbaa !9
  call void @_ZN16RunLenIntEncoder18initializeLiteralsEl(ptr noundef nonnull align 8 dereferenceable(168) %7, i64 noundef %188)
  br label %218

189:                                              ; preds = %183
  %190 = load i64, ptr %4, align 8, !tbaa !9
  %191 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %192 = load ptr, ptr %191, align 8, !tbaa !20
  %193 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %194 = load i32, ptr %193, align 4, !tbaa !11
  %195 = sub nsw i32 %194, 1
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds i64, ptr %192, i64 %196
  %198 = load i64, ptr %197, align 8, !tbaa !9
  %199 = sub nsw i64 %190, %198
  %200 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 6
  store i64 %199, ptr %200, align 8, !tbaa !21
  %201 = load i64, ptr %4, align 8, !tbaa !9
  %202 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 20
  %203 = load ptr, ptr %202, align 8, !tbaa !20
  %204 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 1
  %205 = load i32, ptr %204, align 4, !tbaa !11
  %206 = add nsw i32 %205, 1
  store i32 %206, ptr %204, align 4, !tbaa !11
  %207 = sext i32 %205 to i64
  %208 = getelementptr inbounds i64, ptr %203, i64 %207
  store i64 %201, ptr %208, align 8, !tbaa !9
  %209 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  %210 = load i32, ptr %209, align 4, !tbaa !23
  %211 = add nsw i32 %210, 1
  store i32 %211, ptr %209, align 4, !tbaa !23
  %212 = getelementptr inbounds %class.RunLenIntEncoder, ptr %7, i32 0, i32 3
  %213 = load i32, ptr %212, align 4, !tbaa !23
  %214 = load i32, ptr @_ZN9Constants9MAX_SCOPEE, align 4, !tbaa !24
  %215 = icmp eq i32 %213, %214
  br i1 %215, label %216, label %217

216:                                              ; preds = %189
  call void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %7)
  br label %217

217:                                              ; preds = %216, %189
  br label %218

218:                                              ; preds = %217, %187
  br label %219

219:                                              ; preds = %218, %140
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %220

220:                                              ; preds = %219, %45
  br label %221

221:                                              ; preds = %220, %11
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN16RunLenIntEncoder18initializeLiteralsEl(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef) #5 align 2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { builtin allocsize(0) }
attributes #9 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !14, i64 4}
!12 = !{!"_ZTS16RunLenIntEncoder", !13, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !15, i64 16, !15, i64 17, !10, i64 24, !10, i64 32, !14, i64 40, !15, i64 44, !14, i64 48, !14, i64 52, !14, i64 56, !6, i64 64, !14, i64 72, !14, i64 76, !14, i64 80, !14, i64 84, !14, i64 88, !10, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !16, i64 136, !17, i64 152}
!13 = !{!"_ZTSN16RunLenIntEncoder12EncodingTypeE", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTS13EncodingUtils", !6, i64 0, !6, i64 8}
!17 = !{!"_ZTSSt10shared_ptrI10ByteBufferE", !18, i64 0}
!18 = !{!"_ZTSSt12__shared_ptrI10ByteBufferLN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !19, i64 8}
!19 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!20 = !{!12, !6, i64 104}
!21 = !{!12, !10, i64 24}
!22 = !{!12, !14, i64 8}
!23 = !{!12, !14, i64 12}
!24 = !{!14, !14, i64 0}
!25 = !{!12, !13, i64 0}
!26 = !{!12, !15, i64 44}


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

@_ZN9Constants9MAX_SCOPEE = external local_unnamed_addr global i32, align 4
@_ZN9Constants10MIN_REPEATE = external local_unnamed_addr global i32, align 4
@_ZN9Constants23MAX_SHORT_REPEAT_LENGTHE = external local_unnamed_addr global i32, align 4

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16RunLenIntEncoder5writeEl(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %1) local_unnamed_addr #2 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %4, label %19 [
    i32 0, label %5
    i32 1, label %6
  ]

5:                                                ; preds = %2
  tail call void @_ZN16RunLenIntEncoder18initializeLiteralsEl(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %1)
  br label %104

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 104
  %8 = load ptr, ptr %7, align 8, !tbaa !18
  %9 = load i64, ptr %8, align 8, !tbaa !19
  %10 = sub nsw i64 %1, %9
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %10, ptr %11, align 8, !tbaa !20
  store i32 2, ptr %3, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %8, i64 8
  store i64 %1, ptr %12, align 8, !tbaa !19
  %13 = load i64, ptr %8, align 8, !tbaa !19
  %14 = icmp eq i64 %13, %1
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = getelementptr inbounds i8, ptr %0, i64 12
  br i1 %14, label %17, label %18

17:                                               ; preds = %6
  store i32 2, ptr %15, align 8, !tbaa !21
  store i32 0, ptr %16, align 4, !tbaa !22
  br label %104

18:                                               ; preds = %6
  store i32 0, ptr %15, align 8, !tbaa !21
  store i32 2, ptr %16, align 4, !tbaa !22
  br label %104

19:                                               ; preds = %2
  %20 = getelementptr inbounds i8, ptr %0, i64 104
  %21 = load ptr, ptr %20, align 8, !tbaa !18
  %22 = sext i32 %4 to i64
  %23 = getelementptr i64, ptr %21, i64 %22
  %24 = getelementptr i8, ptr %23, i64 -8
  %25 = load i64, ptr %24, align 8, !tbaa !19
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = load i64, ptr %26, align 8, !tbaa !20
  %28 = icmp eq i64 %27, 0
  %29 = icmp eq i64 %25, %1
  %or.cond = select i1 %28, i1 %29, i1 false
  br i1 %or.cond, label %30, label %65

30:                                               ; preds = %19
  %31 = add nsw i32 %4, 1
  store i32 %31, ptr %3, align 4, !tbaa !5
  store i64 %1, ptr %23, align 8, !tbaa !19
  %32 = getelementptr inbounds i8, ptr %0, i64 12
  %33 = load i32, ptr %32, align 4
  %34 = icmp sgt i32 %33, 0
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  br i1 %34, label %38, label %.thread

.thread:                                          ; preds = %30
  %36 = load i32, ptr %35, align 8, !tbaa !21
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %35, align 8, !tbaa !21
  br label %60

38:                                               ; preds = %30
  store i32 3, ptr %35, align 8, !tbaa !21
  %39 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !23
  %.not21 = icmp slt i32 %39, 4
  br i1 %.not21, label %40, label %60

40:                                               ; preds = %38
  %41 = sub nsw i32 %31, %39
  store i32 %41, ptr %3, align 4, !tbaa !5
  %.neg28 = add nuw i32 %33, 1
  %42 = sub i32 %.neg28, %39
  store i32 %42, ptr %32, align 4, !tbaa !22
  %43 = sext i32 %39 to i64
  %44 = icmp slt i32 %39, 0
  %45 = shl nsw i64 %43, 3
  %46 = select i1 %44, i64 -1, i64 %45
  %47 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %46) #5
  %48 = sext i32 %41 to i64
  %49 = getelementptr inbounds i64, ptr %21, i64 %48
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %47, ptr align 8 %49, i64 %45, i1 false)
  tail call void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  tail call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  %50 = load ptr, ptr %20, align 8, !tbaa !18
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i64, ptr %50, i64 %52
  %54 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !23
  %55 = sext i32 %54 to i64
  %56 = shl nsw i64 %55, 3
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 8 %53, ptr nonnull align 8 %47, i64 %56, i1 false)
  %57 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !23
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = add nsw i32 %58, %57
  store i32 %59, ptr %3, align 4, !tbaa !5
  tail call void @_ZdaPv(ptr noundef nonnull %47) #6
  %.pre29 = load i32, ptr %35, align 8, !tbaa !21
  br label %60

60:                                               ; preds = %.thread, %40, %38
  %61 = phi i32 [ %37, %.thread ], [ %.pre29, %40 ], [ 3, %38 ]
  %62 = load i32, ptr @_ZN9Constants9MAX_SCOPEE, align 4, !tbaa !23
  %63 = icmp eq i32 %61, %62
  br i1 %63, label %64, label %104

64:                                               ; preds = %60
  tail call void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  tail call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  br label %104

65:                                               ; preds = %19
  %66 = getelementptr inbounds i8, ptr %0, i64 8
  %67 = load i32, ptr %66, align 8, !tbaa !21
  %68 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4, !tbaa !23
  %.not = icmp slt i32 %67, %68
  br i1 %.not, label %74, label %69

69:                                               ; preds = %65
  %70 = load i32, ptr @_ZN9Constants23MAX_SHORT_REPEAT_LENGTHE, align 4, !tbaa !23
  %.not19 = icmp sgt i32 %67, %70
  br i1 %.not19, label %72, label %71

71:                                               ; preds = %69
  store i32 0, ptr %0, align 8, !tbaa !24
  br label %.sink.split

72:                                               ; preds = %69
  store i32 3, ptr %0, align 8, !tbaa !24
  %73 = getelementptr inbounds i8, ptr %0, i64 44
  store i8 1, ptr %73, align 4, !tbaa !25
  br label %.sink.split

.sink.split:                                      ; preds = %72, %71
  tail call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  br label %74

74:                                               ; preds = %.sink.split, %65
  %75 = load i32, ptr %66, align 8, !tbaa !21
  %76 = icmp sgt i32 %75, 0
  %77 = load i32, ptr @_ZN9Constants10MIN_REPEATE, align 4
  %78 = icmp slt i32 %75, %77
  %or.cond25 = select i1 %76, i1 %78, i1 false
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br i1 %or.cond25, label %79, label %87

79:                                               ; preds = %74
  %80 = load ptr, ptr %20, align 8, !tbaa !18
  %81 = sext i32 %.pre to i64
  %82 = getelementptr i64, ptr %80, i64 %81
  %83 = getelementptr i8, ptr %82, i64 -8
  %84 = load i64, ptr %83, align 8, !tbaa !19
  %.not20 = icmp eq i64 %84, %1
  br i1 %.not20, label %87, label %85

85:                                               ; preds = %79
  %86 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %75, ptr %86, align 4, !tbaa !22
  store i32 0, ptr %66, align 8, !tbaa !21
  br label %87

87:                                               ; preds = %79, %85, %74
  %88 = icmp eq i32 %.pre, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %87
  tail call void @_ZN16RunLenIntEncoder18initializeLiteralsEl(ptr noundef nonnull align 8 dereferenceable(168) %0, i64 noundef %1)
  br label %104

90:                                               ; preds = %87
  %91 = load ptr, ptr %20, align 8, !tbaa !18
  %92 = sext i32 %.pre to i64
  %93 = getelementptr i64, ptr %91, i64 %92
  %94 = getelementptr i8, ptr %93, i64 -8
  %95 = load i64, ptr %94, align 8, !tbaa !19
  %96 = sub nsw i64 %1, %95
  store i64 %96, ptr %26, align 8, !tbaa !20
  %97 = add nsw i32 %.pre, 1
  store i32 %97, ptr %3, align 4, !tbaa !5
  store i64 %1, ptr %93, align 8, !tbaa !19
  %98 = getelementptr inbounds i8, ptr %0, i64 12
  %99 = load i32, ptr %98, align 4, !tbaa !22
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %98, align 4, !tbaa !22
  %101 = load i32, ptr @_ZN9Constants9MAX_SCOPEE, align 4, !tbaa !23
  %102 = icmp eq i32 %100, %101
  br i1 %102, label %103, label %104

103:                                              ; preds = %90
  tail call void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  tail call void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  br label %104

104:                                              ; preds = %64, %60, %90, %103, %89, %18, %17, %5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16RunLenIntEncoder17determineEncodingEv(ptr noundef nonnull align 8 dereferenceable(168)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN16RunLenIntEncoder11writeValuesEv(ptr noundef nonnull align 8 dereferenceable(168)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN16RunLenIntEncoder18initializeLiteralsEl(ptr noundef nonnull align 8 dereferenceable(168), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress 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

attributes #0 = { 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 #1 = { 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 #2 = { 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { 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, !10, i64 4}
!6 = !{!"_ZTS16RunLenIntEncoder", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 17, !12, i64 24, !12, i64 32, !10, i64 40, !11, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !13, i64 64, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !12, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !14, i64 136, !15, i64 152}
!7 = !{!"_ZTSN16RunLenIntEncoder12EncodingTypeE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"_ZTS13EncodingUtils", !13, i64 0, !13, i64 8}
!15 = !{!"_ZTSSt10shared_ptrI10ByteBufferE", !16, i64 0}
!16 = !{!"_ZTSSt12__shared_ptrI10ByteBufferLN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0, !17, i64 8}
!17 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !13, i64 0}
!18 = !{!6, !13, i64 104}
!19 = !{!12, !12, i64 0}
!20 = !{!6, !12, i64 24}
!21 = !{!6, !10, i64 8}
!22 = !{!6, !10, i64 12}
!23 = !{!10, !10, i64 0}
!24 = !{!6, !7, i64 0}
!25 = !{!6, !11, i64 44}


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