; LLVM IR from datocms/fast_thumbhash :: ext/fast_thumbhash (fast_thumbhash)

; 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.encoded_channel = type { double, ptr, i32, double }

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.rgba_to_thumbhash = external hidden unnamed_addr constant [66 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @encode_channel(ptr dead_on_unwind noalias writable sret(%struct.encoded_channel) align 8, ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #0

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.maxnum.f64(double, double) #3

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @write_varying_factors(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(float) #3

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @rgba_to_thumbhash(i8 noundef zeroext %0, i8 noundef zeroext %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca double, align 8
  %16 = alloca i8, align 1
  %17 = alloca i8, align 1
  %18 = alloca i8, align 1
  %19 = alloca i8, align 1
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca double, align 8
  %27 = alloca double, align 8
  %28 = alloca double, align 8
  %29 = alloca double, align 8
  %30 = alloca %struct.encoded_channel, align 8
  %31 = alloca %struct.encoded_channel, align 8
  %32 = alloca %struct.encoded_channel, align 8
  %33 = alloca %struct.encoded_channel, align 8
  %34 = alloca i8, align 1
  %35 = alloca i32, align 4
  %36 = alloca i32, align 4
  %37 = alloca i8, align 1
  %38 = alloca i8, align 1
  %39 = alloca [4 x i8], align 1
  %40 = alloca i32, align 4
  store i8 %0, ptr %5, align 1, !tbaa !5
  store i8 %1, ptr %6, align 1, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !8
  store ptr %3, ptr %8, align 8, !tbaa !8
  %41 = load i8, ptr %5, align 1, !tbaa !5
  %42 = zext i8 %41 to i32
  %43 = icmp sle i32 %42, 100
  br i1 %43, label %44, label %45

44:                                               ; preds = %4
  br label %46

45:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 85, ptr noundef @__PRETTY_FUNCTION__.rgba_to_thumbhash) #7
  unreachable

46:                                               ; preds = %44
  %47 = load i8, ptr %6, align 1, !tbaa !5
  %48 = zext i8 %47 to i32
  %49 = icmp sle i32 %48, 100
  br i1 %49, label %50, label %51

50:                                               ; preds = %46
  br label %52

51:                                               ; preds = %46
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 86, ptr noundef @__PRETTY_FUNCTION__.rgba_to_thumbhash) #7
  unreachable

52:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  store double 0.000000e+00, ptr %9, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #8
  store double 0.000000e+00, ptr %10, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #8
  store double 0.000000e+00, ptr %11, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #8
  store double 0.000000e+00, ptr %12, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #8
  store i32 0, ptr %13, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  store i32 0, ptr %14, align 4, !tbaa !12
  br label %53

53:                                               ; preds = %109, %52
  %54 = load i32, ptr %13, align 4, !tbaa !12
  %55 = load i8, ptr %5, align 1, !tbaa !5
  %56 = zext i8 %55 to i32
  %57 = load i8, ptr %6, align 1, !tbaa !5
  %58 = zext i8 %57 to i32
  %59 = mul nsw i32 %56, %58
  %60 = icmp slt i32 %54, %59
  br i1 %60, label %62, label %61

61:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #8
  br label %114

62:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #8
  %63 = load ptr, ptr %7, align 8, !tbaa !8
  %64 = load i32, ptr %14, align 4, !tbaa !12
  %65 = add nsw i32 %64, 3
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %63, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !5
  %69 = uitofp i8 %68 to double
  %70 = fdiv double %69, 2.550000e+02
  store double %70, ptr %15, align 8, !tbaa !10
  %71 = load double, ptr %15, align 8, !tbaa !10
  %72 = fdiv double %71, 2.550000e+02
  %73 = load ptr, ptr %7, align 8, !tbaa !8
  %74 = load i32, ptr %14, align 4, !tbaa !12
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i8, ptr %73, i64 %75
  %77 = load i8, ptr %76, align 1, !tbaa !5
  %78 = zext i8 %77 to i32
  %79 = sitofp i32 %78 to double
  %80 = load double, ptr %9, align 8, !tbaa !10
  %81 = call double @llvm.fmuladd.f64(double %72, double %79, double %80)
  store double %81, ptr %9, align 8, !tbaa !10
  %82 = load double, ptr %15, align 8, !tbaa !10
  %83 = fdiv double %82, 2.550000e+02
  %84 = load ptr, ptr %7, align 8, !tbaa !8
  %85 = load i32, ptr %14, align 4, !tbaa !12
  %86 = add nsw i32 %85, 1
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds i8, ptr %84, i64 %87
  %89 = load i8, ptr %88, align 1, !tbaa !5
  %90 = zext i8 %89 to i32
  %91 = sitofp i32 %90 to double
  %92 = load double, ptr %10, align 8, !tbaa !10
  %93 = call double @llvm.fmuladd.f64(double %83, double %91, double %92)
  store double %93, ptr %10, align 8, !tbaa !10
  %94 = load double, ptr %15, align 8, !tbaa !10
  %95 = fdiv double %94, 2.550000e+02
  %96 = load ptr, ptr %7, align 8, !tbaa !8
  %97 = load i32, ptr %14, align 4, !tbaa !12
  %98 = add nsw i32 %97, 2
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i8, ptr %96, i64 %99
  %101 = load i8, ptr %100, align 1, !tbaa !5
  %102 = zext i8 %101 to i32
  %103 = sitofp i32 %102 to double
  %104 = load double, ptr %11, align 8, !tbaa !10
  %105 = call double @llvm.fmuladd.f64(double %95, double %103, double %104)
  store double %105, ptr %11, align 8, !tbaa !10
  %106 = load double, ptr %15, align 8, !tbaa !10
  %107 = load double, ptr %12, align 8, !tbaa !10
  %108 = fadd double %107, %106
  store double %108, ptr %12, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #8
  br label %109

109:                                              ; preds = %62
  %110 = load i32, ptr %13, align 4, !tbaa !12
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %13, align 4, !tbaa !12
  %112 = load i32, ptr %14, align 4, !tbaa !12
  %113 = add nsw i32 %112, 4
  store i32 %113, ptr %14, align 4, !tbaa !12
  br label %53, !llvm.loop !14

114:                                              ; preds = %61
  %115 = load double, ptr %12, align 8, !tbaa !10
  %116 = fcmp une double %115, 0.000000e+00
  br i1 %116, label %117, label %127

117:                                              ; preds = %114
  %118 = load double, ptr %12, align 8, !tbaa !10
  %119 = load double, ptr %9, align 8, !tbaa !10
  %120 = fdiv double %119, %118
  store double %120, ptr %9, align 8, !tbaa !10
  %121 = load double, ptr %12, align 8, !tbaa !10
  %122 = load double, ptr %10, align 8, !tbaa !10
  %123 = fdiv double %122, %121
  store double %123, ptr %10, align 8, !tbaa !10
  %124 = load double, ptr %12, align 8, !tbaa !10
  %125 = load double, ptr %11, align 8, !tbaa !10
  %126 = fdiv double %125, %124
  store double %126, ptr %11, align 8, !tbaa !10
  br label %127

127:                                              ; preds = %117, %114
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #8
  %128 = load double, ptr %12, align 8, !tbaa !10
  %129 = load i8, ptr %5, align 1, !tbaa !5
  %130 = zext i8 %129 to i32
  %131 = load i8, ptr %6, align 1, !tbaa !5
  %132 = zext i8 %131 to i32
  %133 = mul nsw i32 %130, %132
  %134 = sitofp i32 %133 to double
  %135 = fcmp olt double %128, %134
  %136 = zext i1 %135 to i8
  store i8 %136, ptr %16, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #8
  %137 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %138 = trunc i8 %137 to i1
  %139 = zext i1 %138 to i64
  %140 = select i1 %138, i32 5, i32 7
  %141 = trunc i32 %140 to i8
  store i8 %141, ptr %17, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #8
  %142 = load i8, ptr %17, align 1, !tbaa !5
  %143 = uitofp i8 %142 to double
  %144 = load i8, ptr %5, align 1, !tbaa !5
  %145 = zext i8 %144 to i32
  %146 = sitofp i32 %145 to double
  %147 = fmul double %143, %146
  %148 = load i8, ptr %5, align 1, !tbaa !5
  %149 = uitofp i8 %148 to double
  %150 = load i8, ptr %6, align 1, !tbaa !5
  %151 = uitofp i8 %150 to double
  %152 = call double @llvm.maxnum.f64(double %149, double %151)
  %153 = fdiv double %147, %152
  %154 = fptrunc double %153 to float
  %155 = call float @llvm.round.f32(float %154)
  %156 = fpext float %155 to double
  %157 = call double @llvm.maxnum.f64(double 1.000000e+00, double %156)
  %158 = fptoui double %157 to i8
  store i8 %158, ptr %18, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #8
  %159 = load i8, ptr %17, align 1, !tbaa !5
  %160 = uitofp i8 %159 to double
  %161 = load i8, ptr %6, align 1, !tbaa !5
  %162 = zext i8 %161 to i32
  %163 = sitofp i32 %162 to double
  %164 = fmul double %160, %163
  %165 = load i8, ptr %5, align 1, !tbaa !5
  %166 = uitofp i8 %165 to double
  %167 = load i8, ptr %6, align 1, !tbaa !5
  %168 = uitofp i8 %167 to double
  %169 = call double @llvm.maxnum.f64(double %166, double %168)
  %170 = fdiv double %164, %169
  %171 = fptrunc double %170 to float
  %172 = call float @llvm.round.f32(float %171)
  %173 = fpext float %172 to double
  %174 = call double @llvm.maxnum.f64(double 1.000000e+00, double %173)
  %175 = fptoui double %174 to i8
  store i8 %175, ptr %19, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #8
  %176 = load i8, ptr %5, align 1, !tbaa !5
  %177 = zext i8 %176 to i32
  %178 = load i8, ptr %6, align 1, !tbaa !5
  %179 = zext i8 %178 to i32
  %180 = mul nsw i32 %177, %179
  %181 = sext i32 %180 to i64
  %182 = mul i64 %181, 8
  %183 = call noalias ptr @malloc(i64 noundef %182) #9
  store ptr %183, ptr %20, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #8
  %184 = load i8, ptr %5, align 1, !tbaa !5
  %185 = zext i8 %184 to i32
  %186 = load i8, ptr %6, align 1, !tbaa !5
  %187 = zext i8 %186 to i32
  %188 = mul nsw i32 %185, %187
  %189 = sext i32 %188 to i64
  %190 = mul i64 %189, 8
  %191 = call noalias ptr @malloc(i64 noundef %190) #9
  store ptr %191, ptr %21, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #8
  %192 = load i8, ptr %5, align 1, !tbaa !5
  %193 = zext i8 %192 to i32
  %194 = load i8, ptr %6, align 1, !tbaa !5
  %195 = zext i8 %194 to i32
  %196 = mul nsw i32 %193, %195
  %197 = sext i32 %196 to i64
  %198 = mul i64 %197, 8
  %199 = call noalias ptr @malloc(i64 noundef %198) #9
  store ptr %199, ptr %22, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #8
  %200 = load i8, ptr %5, align 1, !tbaa !5
  %201 = zext i8 %200 to i32
  %202 = load i8, ptr %6, align 1, !tbaa !5
  %203 = zext i8 %202 to i32
  %204 = mul nsw i32 %201, %203
  %205 = sext i32 %204 to i64
  %206 = mul i64 %205, 8
  %207 = call noalias ptr @malloc(i64 noundef %206) #9
  store ptr %207, ptr %23, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #8
  store i32 0, ptr %24, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #8
  store i32 0, ptr %25, align 4, !tbaa !12
  br label %208

208:                                              ; preds = %299, %127
  %209 = load i32, ptr %24, align 4, !tbaa !12
  %210 = load i8, ptr %5, align 1, !tbaa !5
  %211 = zext i8 %210 to i32
  %212 = load i8, ptr %6, align 1, !tbaa !5
  %213 = zext i8 %212 to i32
  %214 = mul nsw i32 %211, %213
  %215 = icmp slt i32 %209, %214
  br i1 %215, label %217, label %216

216:                                              ; preds = %208
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #8
  br label %304

217:                                              ; preds = %208
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #8
  %218 = load ptr, ptr %7, align 8, !tbaa !8
  %219 = load i32, ptr %25, align 4, !tbaa !12
  %220 = add nsw i32 %219, 3
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds i8, ptr %218, i64 %221
  %223 = load i8, ptr %222, align 1, !tbaa !5
  %224 = uitofp i8 %223 to double
  %225 = fdiv double %224, 2.550000e+02
  store double %225, ptr %26, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #8
  %226 = load double, ptr %9, align 8, !tbaa !10
  %227 = load double, ptr %26, align 8, !tbaa !10
  %228 = fsub double 1.000000e+00, %227
  %229 = load double, ptr %26, align 8, !tbaa !10
  %230 = fdiv double %229, 2.550000e+02
  %231 = load ptr, ptr %7, align 8, !tbaa !8
  %232 = load i32, ptr %25, align 4, !tbaa !12
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds i8, ptr %231, i64 %233
  %235 = load i8, ptr %234, align 1, !tbaa !5
  %236 = uitofp i8 %235 to double
  %237 = fmul double %230, %236
  %238 = call double @llvm.fmuladd.f64(double %226, double %228, double %237)
  store double %238, ptr %27, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #8
  %239 = load double, ptr %10, align 8, !tbaa !10
  %240 = load double, ptr %26, align 8, !tbaa !10
  %241 = fsub double 1.000000e+00, %240
  %242 = load double, ptr %26, align 8, !tbaa !10
  %243 = fdiv double %242, 2.550000e+02
  %244 = load ptr, ptr %7, align 8, !tbaa !8
  %245 = load i32, ptr %25, align 4, !tbaa !12
  %246 = add nsw i32 %245, 1
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds i8, ptr %244, i64 %247
  %249 = load i8, ptr %248, align 1, !tbaa !5
  %250 = uitofp i8 %249 to double
  %251 = fmul double %243, %250
  %252 = call double @llvm.fmuladd.f64(double %239, double %241, double %251)
  store double %252, ptr %28, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #8
  %253 = load double, ptr %11, align 8, !tbaa !10
  %254 = load double, ptr %26, align 8, !tbaa !10
  %255 = fsub double 1.000000e+00, %254
  %256 = load double, ptr %26, align 8, !tbaa !10
  %257 = fdiv double %256, 2.550000e+02
  %258 = load ptr, ptr %7, align 8, !tbaa !8
  %259 = load i32, ptr %25, align 4, !tbaa !12
  %260 = add nsw i32 %259, 2
  %261 = sext i32 %260 to i64
  %262 = getelementptr inbounds i8, ptr %258, i64 %261
  %263 = load i8, ptr %262, align 1, !tbaa !5
  %264 = uitofp i8 %263 to double
  %265 = fmul double %257, %264
  %266 = call double @llvm.fmuladd.f64(double %253, double %255, double %265)
  store double %266, ptr %29, align 8, !tbaa !10
  %267 = load double, ptr %27, align 8, !tbaa !10
  %268 = load double, ptr %28, align 8, !tbaa !10
  %269 = fadd double %267, %268
  %270 = load double, ptr %29, align 8, !tbaa !10
  %271 = fadd double %269, %270
  %272 = fdiv double %271, 3.000000e+00
  %273 = load ptr, ptr %20, align 8, !tbaa !8
  %274 = load i32, ptr %24, align 4, !tbaa !12
  %275 = sext i32 %274 to i64
  %276 = getelementptr inbounds double, ptr %273, i64 %275
  store double %272, ptr %276, align 8, !tbaa !10
  %277 = load double, ptr %27, align 8, !tbaa !10
  %278 = load double, ptr %28, align 8, !tbaa !10
  %279 = fadd double %277, %278
  %280 = fdiv double %279, 2.000000e+00
  %281 = load double, ptr %29, align 8, !tbaa !10
  %282 = fsub double %280, %281
  %283 = load ptr, ptr %21, align 8, !tbaa !8
  %284 = load i32, ptr %24, align 4, !tbaa !12
  %285 = sext i32 %284 to i64
  %286 = getelementptr inbounds double, ptr %283, i64 %285
  store double %282, ptr %286, align 8, !tbaa !10
  %287 = load double, ptr %27, align 8, !tbaa !10
  %288 = load double, ptr %28, align 8, !tbaa !10
  %289 = fsub double %287, %288
  %290 = load ptr, ptr %22, align 8, !tbaa !8
  %291 = load i32, ptr %24, align 4, !tbaa !12
  %292 = sext i32 %291 to i64
  %293 = getelementptr inbounds double, ptr %290, i64 %292
  store double %289, ptr %293, align 8, !tbaa !10
  %294 = load double, ptr %26, align 8, !tbaa !10
  %295 = load ptr, ptr %23, align 8, !tbaa !8
  %296 = load i32, ptr %24, align 4, !tbaa !12
  %297 = sext i32 %296 to i64
  %298 = getelementptr inbounds double, ptr %295, i64 %297
  store double %294, ptr %298, align 8, !tbaa !10
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #8
  br label %299

299:                                              ; preds = %217
  %300 = load i32, ptr %24, align 4, !tbaa !12
  %301 = add nsw i32 %300, 1
  store i32 %301, ptr %24, align 4, !tbaa !12
  %302 = load i32, ptr %25, align 4, !tbaa !12
  %303 = add nsw i32 %302, 4
  store i32 %303, ptr %25, align 4, !tbaa !12
  br label %208, !llvm.loop !20

304:                                              ; preds = %216
  call void @llvm.lifetime.start.p0(i64 32, ptr %30) #8
  %305 = load ptr, ptr %20, align 8, !tbaa !8
  %306 = load i8, ptr %18, align 1, !tbaa !5
  %307 = uitofp i8 %306 to double
  %308 = call double @llvm.maxnum.f64(double 3.000000e+00, double %307)
  %309 = fptoui double %308 to i8
  %310 = load i8, ptr %19, align 1, !tbaa !5
  %311 = uitofp i8 %310 to double
  %312 = call double @llvm.maxnum.f64(double 3.000000e+00, double %311)
  %313 = fptoui double %312 to i8
  %314 = load i8, ptr %5, align 1, !tbaa !5
  %315 = load i8, ptr %6, align 1, !tbaa !5
  call void @encode_channel(ptr dead_on_unwind writable sret(%struct.encoded_channel) align 8 %30, ptr noundef %305, i8 noundef zeroext %309, i8 noundef zeroext %313, i8 noundef zeroext %314, i8 noundef zeroext %315)
  call void @llvm.lifetime.start.p0(i64 32, ptr %31) #8
  %316 = load ptr, ptr %21, align 8, !tbaa !8
  %317 = load i8, ptr %5, align 1, !tbaa !5
  %318 = load i8, ptr %6, align 1, !tbaa !5
  call void @encode_channel(ptr dead_on_unwind writable sret(%struct.encoded_channel) align 8 %31, ptr noundef %316, i8 noundef zeroext 3, i8 noundef zeroext 3, i8 noundef zeroext %317, i8 noundef zeroext %318)
  call void @llvm.lifetime.start.p0(i64 32, ptr %32) #8
  %319 = load ptr, ptr %22, align 8, !tbaa !8
  %320 = load i8, ptr %5, align 1, !tbaa !5
  %321 = load i8, ptr %6, align 1, !tbaa !5
  call void @encode_channel(ptr dead_on_unwind writable sret(%struct.encoded_channel) align 8 %32, ptr noundef %319, i8 noundef zeroext 3, i8 noundef zeroext 3, i8 noundef zeroext %320, i8 noundef zeroext %321)
  call void @llvm.lifetime.start.p0(i64 32, ptr %33) #8
  %322 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %323 = trunc i8 %322 to i1
  br i1 %323, label %324, label %328

324:                                              ; preds = %304
  %325 = load ptr, ptr %23, align 8, !tbaa !8
  %326 = load i8, ptr %5, align 1, !tbaa !5
  %327 = load i8, ptr %6, align 1, !tbaa !5
  call void @encode_channel(ptr dead_on_unwind writable sret(%struct.encoded_channel) align 8 %33, ptr noundef %325, i8 noundef zeroext 5, i8 noundef zeroext 5, i8 noundef zeroext %326, i8 noundef zeroext %327)
  br label %333

328:                                              ; preds = %304
  %329 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 0
  store double 1.000000e+00, ptr %329, align 8, !tbaa !21
  %330 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 1
  store ptr null, ptr %330, align 8, !tbaa !23
  %331 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 2
  store i32 0, ptr %331, align 8, !tbaa !24
  %332 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 3
  store double 1.000000e+00, ptr %332, align 8, !tbaa !25
  br label %333

333:                                              ; preds = %328, %324
  %334 = load ptr, ptr %20, align 8, !tbaa !8
  call void @free(ptr noundef %334) #8
  %335 = load ptr, ptr %21, align 8, !tbaa !8
  call void @free(ptr noundef %335) #8
  %336 = load ptr, ptr %22, align 8, !tbaa !8
  call void @free(ptr noundef %336) #8
  %337 = load ptr, ptr %23, align 8, !tbaa !8
  call void @free(ptr noundef %337) #8
  call void @llvm.lifetime.start.p0(i64 1, ptr %34) #8
  %338 = load i8, ptr %5, align 1, !tbaa !5
  %339 = zext i8 %338 to i32
  %340 = load i8, ptr %6, align 1, !tbaa !5
  %341 = zext i8 %340 to i32
  %342 = icmp sgt i32 %339, %341
  %343 = zext i1 %342 to i8
  store i8 %343, ptr %34, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %35) #8
  %344 = getelementptr inbounds %struct.encoded_channel, ptr %30, i32 0, i32 0
  %345 = load double, ptr %344, align 8, !tbaa !21
  %346 = fmul double 6.300000e+01, %345
  %347 = fptrunc double %346 to float
  %348 = call float @llvm.round.f32(float %347)
  %349 = fptoui float %348 to i32
  %350 = getelementptr inbounds %struct.encoded_channel, ptr %31, i32 0, i32 0
  %351 = load double, ptr %350, align 8, !tbaa !21
  %352 = call double @llvm.fmuladd.f64(double 3.150000e+01, double %351, double 3.150000e+01)
  %353 = fptrunc double %352 to float
  %354 = call float @llvm.round.f32(float %353)
  %355 = fptoui float %354 to i32
  %356 = shl i32 %355, 6
  %357 = or i32 %349, %356
  %358 = getelementptr inbounds %struct.encoded_channel, ptr %32, i32 0, i32 0
  %359 = load double, ptr %358, align 8, !tbaa !21
  %360 = call double @llvm.fmuladd.f64(double 3.150000e+01, double %359, double 3.150000e+01)
  %361 = fptrunc double %360 to float
  %362 = call float @llvm.round.f32(float %361)
  %363 = fptoui float %362 to i32
  %364 = shl i32 %363, 12
  %365 = or i32 %357, %364
  %366 = getelementptr inbounds %struct.encoded_channel, ptr %30, i32 0, i32 3
  %367 = load double, ptr %366, align 8, !tbaa !25
  %368 = fmul double 3.100000e+01, %367
  %369 = fptrunc double %368 to float
  %370 = call float @llvm.round.f32(float %369)
  %371 = fptoui float %370 to i32
  %372 = shl i32 %371, 18
  %373 = or i32 %365, %372
  %374 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %375 = trunc i8 %374 to i1
  %376 = zext i1 %375 to i32
  %377 = shl i32 %376, 23
  %378 = or i32 %373, %377
  store i32 %378, ptr %35, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %36) #8
  %379 = load i8, ptr %34, align 1, !tbaa !16, !range !18, !noundef !19
  %380 = trunc i8 %379 to i1
  br i1 %380, label %381, label %384

381:                                              ; preds = %333
  %382 = load i8, ptr %19, align 1, !tbaa !5
  %383 = zext i8 %382 to i32
  br label %387

384:                                              ; preds = %333
  %385 = load i8, ptr %18, align 1, !tbaa !5
  %386 = zext i8 %385 to i32
  br label %387

387:                                              ; preds = %384, %381
  %388 = phi i32 [ %383, %381 ], [ %386, %384 ]
  %389 = getelementptr inbounds %struct.encoded_channel, ptr %31, i32 0, i32 3
  %390 = load double, ptr %389, align 8, !tbaa !25
  %391 = fmul double 6.300000e+01, %390
  %392 = fptrunc double %391 to float
  %393 = call float @llvm.round.f32(float %392)
  %394 = fptoui float %393 to i16
  %395 = zext i16 %394 to i32
  %396 = shl i32 %395, 3
  %397 = or i32 %388, %396
  %398 = getelementptr inbounds %struct.encoded_channel, ptr %32, i32 0, i32 3
  %399 = load double, ptr %398, align 8, !tbaa !25
  %400 = fmul double 6.300000e+01, %399
  %401 = fptrunc double %400 to float
  %402 = call float @llvm.round.f32(float %401)
  %403 = fptoui float %402 to i16
  %404 = zext i16 %403 to i32
  %405 = shl i32 %404, 9
  %406 = or i32 %397, %405
  %407 = load i8, ptr %34, align 1, !tbaa !16, !range !18, !noundef !19
  %408 = trunc i8 %407 to i1
  %409 = zext i1 %408 to i32
  %410 = shl i32 %409, 15
  %411 = or i32 %406, %410
  store i32 %411, ptr %36, align 4, !tbaa !12
  %412 = load i32, ptr %35, align 4, !tbaa !12
  %413 = and i32 %412, 255
  %414 = trunc i32 %413 to i8
  %415 = load ptr, ptr %8, align 8, !tbaa !8
  %416 = getelementptr inbounds i8, ptr %415, i64 0
  store i8 %414, ptr %416, align 1, !tbaa !5
  %417 = load i32, ptr %35, align 4, !tbaa !12
  %418 = lshr i32 %417, 8
  %419 = and i32 %418, 255
  %420 = trunc i32 %419 to i8
  %421 = load ptr, ptr %8, align 8, !tbaa !8
  %422 = getelementptr inbounds i8, ptr %421, i64 1
  store i8 %420, ptr %422, align 1, !tbaa !5
  %423 = load i32, ptr %35, align 4, !tbaa !12
  %424 = lshr i32 %423, 16
  %425 = trunc i32 %424 to i8
  %426 = load ptr, ptr %8, align 8, !tbaa !8
  %427 = getelementptr inbounds i8, ptr %426, i64 2
  store i8 %425, ptr %427, align 1, !tbaa !5
  %428 = load i32, ptr %36, align 4, !tbaa !12
  %429 = and i32 %428, 255
  %430 = trunc i32 %429 to i8
  %431 = load ptr, ptr %8, align 8, !tbaa !8
  %432 = getelementptr inbounds i8, ptr %431, i64 3
  store i8 %430, ptr %432, align 1, !tbaa !5
  %433 = load i32, ptr %36, align 4, !tbaa !12
  %434 = lshr i32 %433, 8
  %435 = trunc i32 %434 to i8
  %436 = load ptr, ptr %8, align 8, !tbaa !8
  %437 = getelementptr inbounds i8, ptr %436, i64 4
  store i8 %435, ptr %437, align 1, !tbaa !5
  %438 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %439 = trunc i8 %438 to i1
  br i1 %439, label %440, label %460

440:                                              ; preds = %387
  %441 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 0
  %442 = load double, ptr %441, align 8, !tbaa !21
  %443 = fmul double 1.500000e+01, %442
  %444 = fptrunc double %443 to float
  %445 = call float @llvm.round.f32(float %444)
  %446 = fptoui float %445 to i8
  %447 = zext i8 %446 to i32
  %448 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 3
  %449 = load double, ptr %448, align 8, !tbaa !25
  %450 = fmul double 1.500000e+01, %449
  %451 = fptrunc double %450 to float
  %452 = call float @llvm.round.f32(float %451)
  %453 = fptoui float %452 to i8
  %454 = zext i8 %453 to i32
  %455 = shl i32 %454, 4
  %456 = or i32 %447, %455
  %457 = trunc i32 %456 to i8
  %458 = load ptr, ptr %8, align 8, !tbaa !8
  %459 = getelementptr inbounds i8, ptr %458, i64 5
  store i8 %457, ptr %459, align 1, !tbaa !5
  br label %460

460:                                              ; preds = %440, %387
  call void @llvm.lifetime.start.p0(i64 1, ptr %37) #8
  %461 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %462 = trunc i8 %461 to i1
  %463 = zext i1 %462 to i64
  %464 = select i1 %462, i32 6, i32 5
  %465 = trunc i32 %464 to i8
  store i8 %465, ptr %37, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %38) #8
  store i8 0, ptr %38, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %39) #8
  call void @llvm.memset.p0.i64(ptr align 1 %39, i8 0, i64 4, i1 false)
  %466 = getelementptr inbounds %struct.encoded_channel, ptr %30, i32 0, i32 1
  %467 = load ptr, ptr %466, align 8, !tbaa !23
  %468 = getelementptr inbounds %struct.encoded_channel, ptr %30, i32 0, i32 2
  %469 = load i32, ptr %468, align 8, !tbaa !24
  %470 = load ptr, ptr %8, align 8, !tbaa !8
  %471 = load i8, ptr %37, align 1, !tbaa !5
  %472 = zext i8 %471 to i32
  %473 = sext i32 %472 to i64
  %474 = getelementptr inbounds i8, ptr %470, i64 %473
  %475 = call zeroext i8 @write_varying_factors(ptr noundef %467, i32 noundef %469, ptr noundef %474, ptr noundef %38)
  %476 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 0
  store i8 %475, ptr %476, align 1, !tbaa !5
  %477 = getelementptr inbounds %struct.encoded_channel, ptr %31, i32 0, i32 1
  %478 = load ptr, ptr %477, align 8, !tbaa !23
  %479 = getelementptr inbounds %struct.encoded_channel, ptr %31, i32 0, i32 2
  %480 = load i32, ptr %479, align 8, !tbaa !24
  %481 = load ptr, ptr %8, align 8, !tbaa !8
  %482 = load i8, ptr %37, align 1, !tbaa !5
  %483 = zext i8 %482 to i32
  %484 = sext i32 %483 to i64
  %485 = getelementptr inbounds i8, ptr %481, i64 %484
  %486 = call zeroext i8 @write_varying_factors(ptr noundef %478, i32 noundef %480, ptr noundef %485, ptr noundef %38)
  %487 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 1
  store i8 %486, ptr %487, align 1, !tbaa !5
  %488 = getelementptr inbounds %struct.encoded_channel, ptr %32, i32 0, i32 1
  %489 = load ptr, ptr %488, align 8, !tbaa !23
  %490 = getelementptr inbounds %struct.encoded_channel, ptr %32, i32 0, i32 2
  %491 = load i32, ptr %490, align 8, !tbaa !24
  %492 = load ptr, ptr %8, align 8, !tbaa !8
  %493 = load i8, ptr %37, align 1, !tbaa !5
  %494 = zext i8 %493 to i32
  %495 = sext i32 %494 to i64
  %496 = getelementptr inbounds i8, ptr %492, i64 %495
  %497 = call zeroext i8 @write_varying_factors(ptr noundef %489, i32 noundef %491, ptr noundef %496, ptr noundef %38)
  %498 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 2
  store i8 %497, ptr %498, align 1, !tbaa !5
  %499 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %500 = trunc i8 %499 to i1
  br i1 %500, label %501, label %513

501:                                              ; preds = %460
  %502 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 1
  %503 = load ptr, ptr %502, align 8, !tbaa !23
  %504 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 2
  %505 = load i32, ptr %504, align 8, !tbaa !24
  %506 = load ptr, ptr %8, align 8, !tbaa !8
  %507 = load i8, ptr %37, align 1, !tbaa !5
  %508 = zext i8 %507 to i32
  %509 = sext i32 %508 to i64
  %510 = getelementptr inbounds i8, ptr %506, i64 %509
  %511 = call zeroext i8 @write_varying_factors(ptr noundef %503, i32 noundef %505, ptr noundef %510, ptr noundef %38)
  %512 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 3
  store i8 %511, ptr %512, align 1, !tbaa !5
  br label %513

513:                                              ; preds = %501, %460
  %514 = getelementptr inbounds %struct.encoded_channel, ptr %30, i32 0, i32 1
  %515 = load ptr, ptr %514, align 8, !tbaa !23
  call void @free(ptr noundef %515) #8
  %516 = getelementptr inbounds %struct.encoded_channel, ptr %31, i32 0, i32 1
  %517 = load ptr, ptr %516, align 8, !tbaa !23
  call void @free(ptr noundef %517) #8
  %518 = getelementptr inbounds %struct.encoded_channel, ptr %32, i32 0, i32 1
  %519 = load ptr, ptr %518, align 8, !tbaa !23
  call void @free(ptr noundef %519) #8
  %520 = load i8, ptr %16, align 1, !tbaa !16, !range !18, !noundef !19
  %521 = trunc i8 %520 to i1
  br i1 %521, label %522, label %525

522:                                              ; preds = %513
  %523 = getelementptr inbounds %struct.encoded_channel, ptr %33, i32 0, i32 1
  %524 = load ptr, ptr %523, align 8, !tbaa !23
  call void @free(ptr noundef %524) #8
  br label %525

525:                                              ; preds = %522, %513
  call void @llvm.lifetime.start.p0(i64 4, ptr %40) #8
  store i32 1, ptr %40, align 4, !tbaa !12
  br label %526

526:                                              ; preds = %547, %525
  %527 = load i32, ptr %40, align 4, !tbaa !12
  %528 = icmp slt i32 %527, 4
  br i1 %528, label %530, label %529

529:                                              ; preds = %526
  call void @llvm.lifetime.end.p0(i64 4, ptr %40) #8
  br label %550

530:                                              ; preds = %526
  %531 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 0
  %532 = load i8, ptr %531, align 1, !tbaa !5
  %533 = zext i8 %532 to i32
  %534 = load i32, ptr %40, align 4, !tbaa !12
  %535 = sext i32 %534 to i64
  %536 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 %535
  %537 = load i8, ptr %536, align 1, !tbaa !5
  %538 = zext i8 %537 to i32
  %539 = icmp slt i32 %533, %538
  br i1 %539, label %540, label %546

540:                                              ; preds = %530
  %541 = load i32, ptr %40, align 4, !tbaa !12
  %542 = sext i32 %541 to i64
  %543 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 %542
  %544 = load i8, ptr %543, align 1, !tbaa !5
  %545 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 0
  store i8 %544, ptr %545, align 1, !tbaa !5
  br label %546

546:                                              ; preds = %540, %530
  br label %547

547:                                              ; preds = %546
  %548 = load i32, ptr %40, align 4, !tbaa !12
  %549 = add nsw i32 %548, 1
  store i32 %549, ptr %40, align 4, !tbaa !12
  br label %526, !llvm.loop !26

550:                                              ; preds = %529
  %551 = getelementptr inbounds [4 x i8], ptr %39, i64 0, i64 0
  %552 = load i8, ptr %551, align 1, !tbaa !5
  %553 = zext i8 %552 to i32
  %554 = load i8, ptr %37, align 1, !tbaa !5
  %555 = zext i8 %554 to i32
  %556 = add nsw i32 %553, %555
  %557 = add nsw i32 %556, 1
  %558 = trunc i32 %557 to i8
  call void @llvm.lifetime.end.p0(i64 4, ptr %39) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %38) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %37) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %36) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %35) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %34) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %33) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %32) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %31) #8
  call void @llvm.lifetime.end.p0(i64 32, ptr %30) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #8
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  ret i8 %558
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #5

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

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = { noreturn 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !6, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"_Bool", !6, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !15}
!21 = !{!22, !11, i64 0}
!22 = !{!"encoded_channel", !11, i64 0, !9, i64 8, !13, i64 16, !11, i64 24}
!23 = !{!22, !9, i64 8}
!24 = !{!22, !13, i64 16}
!25 = !{!22, !11, i64 24}
!26 = distinct !{!26, !15}


; 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.encoded_channel = type { double, ptr, i32, double }

@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [92 x i8], align 1
@__PRETTY_FUNCTION__.rgba_to_thumbhash = external hidden unnamed_addr constant [66 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @encode_channel(ptr dead_on_unwind noalias writable sret(%struct.encoded_channel) align 8, ptr noundef, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.maxnum.f64(double, double) #3

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @write_varying_factors(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.round.f32(float) #3

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @rgba_to_thumbhash(i8 noundef zeroext %0, i8 noundef zeroext %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca %struct.encoded_channel, align 8
  %6 = alloca %struct.encoded_channel, align 8
  %7 = alloca %struct.encoded_channel, align 8
  %8 = alloca %struct.encoded_channel, align 8
  %9 = alloca i8, align 1
  %10 = zext i8 %0 to i32
  %11 = icmp ult i8 %0, 101
  br i1 %11, label %13, label %12

12:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 85, ptr noundef nonnull @__PRETTY_FUNCTION__.rgba_to_thumbhash) #7
  unreachable

13:                                               ; preds = %4
  %14 = icmp ult i8 %1, 101
  br i1 %14, label %.preheader, label %17

.preheader:                                       ; preds = %13
  %15 = zext nneg i8 %1 to i32
  %16 = mul nuw nsw i32 %15, %10
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

17:                                               ; preds = %13
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 86, ptr noundef nonnull @__PRETTY_FUNCTION__.rgba_to_thumbhash) #7
  unreachable

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.0147.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %96, %.lr.ph ]
  %.0145.lcssa = phi double [ 0.000000e+00, %.preheader ], [ %95, %.lr.ph ]
  %18 = phi <2 x double> [ zeroinitializer, %.preheader ], [ %90, %.lr.ph ]
  %19 = fcmp une double %.0147.lcssa, 0.000000e+00
  %20 = insertelement <2 x double> poison, double %.0147.lcssa, i64 0
  %21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
  %22 = fdiv <2 x double> %18, %21
  %23 = fdiv double %.0145.lcssa, %.0147.lcssa
  %.1146 = select i1 %19, double %23, double %.0145.lcssa
  %24 = insertelement <2 x i1> poison, i1 %19, i64 0
  %25 = shufflevector <2 x i1> %24, <2 x i1> poison, <2 x i32> zeroinitializer
  %26 = select <2 x i1> %25, <2 x double> %22, <2 x double> %18
  %27 = uitofp nneg i32 %16 to double
  %28 = fcmp olt double %.0147.lcssa, %27
  %29 = select i1 %28, double 5.000000e+00, double 7.000000e+00
  %30 = uitofp i8 %0 to double
  %31 = fmul double %29, %30
  %32 = uitofp i8 %1 to double
  %33 = tail call double @llvm.maxnum.f64(double %30, double %32)
  %34 = fdiv double %31, %33
  %35 = fptrunc double %34 to float
  %36 = tail call float @llvm.round.f32(float %35)
  %37 = fpext float %36 to double
  %38 = tail call double @llvm.maxnum.f64(double %37, double 1.000000e+00)
  %39 = fptoui double %38 to i8
  %40 = fmul double %29, %32
  %41 = fdiv double %40, %33
  %42 = fptrunc double %41 to float
  %43 = tail call float @llvm.round.f32(float %42)
  %44 = fpext float %43 to double
  %45 = tail call double @llvm.maxnum.f64(double %44, double 1.000000e+00)
  %46 = fptoui double %45 to i8
  %47 = shl nuw nsw i32 %16, 3
  %48 = zext nneg i32 %47 to i64
  %49 = tail call noalias ptr @malloc(i64 noundef %48) #8
  %50 = tail call noalias ptr @malloc(i64 noundef %48) #8
  %51 = tail call noalias ptr @malloc(i64 noundef %48) #8
  %52 = tail call noalias ptr @malloc(i64 noundef %48) #8
  br i1 %.not, label %._crit_edge169, label %.lr.ph168.preheader

.lr.ph168.preheader:                              ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %16 to i64
  %min.iters.check = icmp eq i32 %16, 1
  br i1 %min.iters.check, label %.lr.ph168.preheader206, label %vector.ph

.lr.ph168.preheader206:                           ; preds = %middle.block, %.lr.ph168.preheader
  %indvars.iv180.ph = phi i64 [ 0, %.lr.ph168.preheader ], [ %ind.end, %middle.block ]
  %indvars.iv178.ph = phi i64 [ 0, %.lr.ph168.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph168

vector.ph:                                        ; preds = %.lr.ph168.preheader
  %n.vec = and i64 %wide.trip.count, 16382
  %ind.end = shl nuw nsw i64 %n.vec, 2
  %broadcast.splat = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> zeroinitializer
  %broadcast.splat203 = shufflevector <2 x double> %26, <2 x double> poison, <2 x i32> <i32 1, i32 1>
  %broadcast.splatinsert204 = insertelement <2 x double> poison, double %.1146, i64 0
  %broadcast.splat205 = shufflevector <2 x double> %broadcast.splatinsert204, <2 x double> poison, <2 x i32> zeroinitializer
  %invariant.gep = getelementptr i8, ptr %2, i64 -3
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 2
  %53 = or disjoint i64 %offset.idx, 3
  %gep = getelementptr i8, ptr %invariant.gep, i64 %53
  %wide.vec = load <8 x i8>, ptr %gep, align 1, !tbaa !5
  %strided.vec = shufflevector <8 x i8> %wide.vec, <8 x i8> poison, <2 x i32> <i32 0, i32 4>
  %strided.vec199 = shufflevector <8 x i8> %wide.vec, <8 x i8> poison, <2 x i32> <i32 1, i32 5>
  %strided.vec200 = shufflevector <8 x i8> %wide.vec, <8 x i8> poison, <2 x i32> <i32 2, i32 6>
  %strided.vec201 = shufflevector <8 x i8> %wide.vec, <8 x i8> poison, <2 x i32> <i32 3, i32 7>
  %54 = uitofp <2 x i8> %strided.vec201 to <2 x double>
  %55 = fdiv <2 x double> %54, <double 2.550000e+02, double 2.550000e+02>
  %56 = fsub <2 x double> <double 1.000000e+00, double 1.000000e+00>, %55
  %57 = fdiv <2 x double> %55, <double 2.550000e+02, double 2.550000e+02>
  %58 = uitofp <2 x i8> %strided.vec to <2 x double>
  %59 = fmul <2 x double> %57, %58
  %60 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat, <2 x double> %56, <2 x double> %59)
  %61 = uitofp <2 x i8> %strided.vec199 to <2 x double>
  %62 = fmul <2 x double> %57, %61
  %63 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat203, <2 x double> %56, <2 x double> %62)
  %64 = uitofp <2 x i8> %strided.vec200 to <2 x double>
  %65 = fmul <2 x double> %57, %64
  %66 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %broadcast.splat205, <2 x double> %56, <2 x double> %65)
  %67 = fadd <2 x double> %60, %63
  %68 = fadd <2 x double> %67, %66
  %69 = fdiv <2 x double> %68, <double 3.000000e+00, double 3.000000e+00>
  %70 = getelementptr inbounds double, ptr %49, i64 %index
  store <2 x double> %69, ptr %70, align 8, !tbaa !8
  %71 = fmul <2 x double> %67, <double 5.000000e-01, double 5.000000e-01>
  %72 = fsub <2 x double> %71, %66
  %73 = getelementptr inbounds double, ptr %50, i64 %index
  store <2 x double> %72, ptr %73, align 8, !tbaa !8
  %74 = fsub <2 x double> %60, %63
  %75 = getelementptr inbounds double, ptr %51, i64 %index
  store <2 x double> %74, ptr %75, align 8, !tbaa !8
  %76 = getelementptr inbounds double, ptr %52, i64 %index
  store <2 x double> %55, ptr %76, align 8, !tbaa !8
  %index.next = add nuw i64 %index, 2
  %77 = icmp eq i64 %index.next, %n.vec
  br i1 %77, label %middle.block, label %vector.body, !llvm.loop !10

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge169, label %.lr.ph168.preheader206

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %.0145158 = phi double [ %95, %.lr.ph ], [ 0.000000e+00, %.preheader ]
  %.0147157 = phi double [ %96, %.lr.ph ], [ 0.000000e+00, %.preheader ]
  %.0148156 = phi i32 [ %97, %.lr.ph ], [ 0, %.preheader ]
  %78 = phi <2 x double> [ %90, %.lr.ph ], [ zeroinitializer, %.preheader ]
  %79 = or disjoint i64 %indvars.iv, 3
  %80 = getelementptr inbounds i8, ptr %2, i64 %79
  %81 = load i8, ptr %80, align 1, !tbaa !5
  %82 = uitofp i8 %81 to double
  %83 = fdiv double %82, 2.550000e+02
  %84 = fdiv double %83, 2.550000e+02
  %85 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv
  %86 = load <2 x i8>, ptr %85, align 1, !tbaa !5
  %87 = uitofp <2 x i8> %86 to <2 x double>
  %88 = insertelement <2 x double> poison, double %84, i64 0
  %89 = shufflevector <2 x double> %88, <2 x double> poison, <2 x i32> zeroinitializer
  %90 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %89, <2 x double> %87, <2 x double> %78)
  %91 = or disjoint i64 %indvars.iv, 2
  %92 = getelementptr inbounds i8, ptr %2, i64 %91
  %93 = load i8, ptr %92, align 1, !tbaa !5
  %94 = uitofp i8 %93 to double
  %95 = tail call double @llvm.fmuladd.f64(double %84, double %94, double %.0145158)
  %96 = fadd double %.0147157, %83
  %97 = add nuw nsw i32 %.0148156, 1
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not = icmp eq i32 %97, %16
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge169:                                   ; preds = %.lr.ph168, %middle.block, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #9
  %98 = uitofp i8 %39 to double
  %99 = tail call double @llvm.maxnum.f64(double %98, double 3.000000e+00)
  %100 = fptoui double %99 to i8
  %101 = uitofp i8 %46 to double
  %102 = tail call double @llvm.maxnum.f64(double %101, double 3.000000e+00)
  %103 = fptoui double %102 to i8
  call void @encode_channel(ptr dead_on_unwind nonnull writable sret(%struct.encoded_channel) align 8 %5, ptr noundef %49, i8 noundef zeroext %100, i8 noundef zeroext %103, i8 noundef zeroext %0, i8 noundef zeroext %1)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #9
  call void @encode_channel(ptr dead_on_unwind nonnull writable sret(%struct.encoded_channel) align 8 %6, ptr noundef %50, i8 noundef zeroext 3, i8 noundef zeroext 3, i8 noundef zeroext %0, i8 noundef zeroext %1)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #9
  call void @encode_channel(ptr dead_on_unwind nonnull writable sret(%struct.encoded_channel) align 8 %7, ptr noundef %51, i8 noundef zeroext 3, i8 noundef zeroext 3, i8 noundef zeroext %0, i8 noundef zeroext %1)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #9
  br i1 %28, label %138, label %139

.lr.ph168:                                        ; preds = %.lr.ph168.preheader206, %.lr.ph168
  %indvars.iv180 = phi i64 [ %indvars.iv.next181, %.lr.ph168 ], [ %indvars.iv180.ph, %.lr.ph168.preheader206 ]
  %indvars.iv178 = phi i64 [ %indvars.iv.next179, %.lr.ph168 ], [ %indvars.iv178.ph, %.lr.ph168.preheader206 ]
  %104 = or disjoint i64 %indvars.iv180, 3
  %105 = getelementptr inbounds i8, ptr %2, i64 %104
  %106 = load i8, ptr %105, align 1, !tbaa !5
  %107 = uitofp i8 %106 to double
  %108 = fdiv double %107, 2.550000e+02
  %109 = fsub double 1.000000e+00, %108
  %110 = fdiv double %108, 2.550000e+02
  %111 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv180
  %112 = load <2 x i8>, ptr %111, align 1, !tbaa !5
  %113 = uitofp <2 x i8> %112 to <2 x double>
  %114 = insertelement <2 x double> poison, double %110, i64 0
  %115 = shufflevector <2 x double> %114, <2 x double> poison, <2 x i32> zeroinitializer
  %116 = fmul <2 x double> %115, %113
  %117 = insertelement <2 x double> poison, double %109, i64 0
  %118 = shufflevector <2 x double> %117, <2 x double> poison, <2 x i32> zeroinitializer
  %119 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %26, <2 x double> %118, <2 x double> %116)
  %120 = or disjoint i64 %indvars.iv180, 2
  %121 = getelementptr inbounds i8, ptr %2, i64 %120
  %122 = load i8, ptr %121, align 1, !tbaa !5
  %123 = uitofp i8 %122 to double
  %124 = fmul double %110, %123
  %125 = tail call double @llvm.fmuladd.f64(double %.1146, double %109, double %124)
  %126 = extractelement <2 x double> %119, i64 0
  %127 = extractelement <2 x double> %119, i64 1
  %128 = fadd double %126, %127
  %129 = fadd double %128, %125
  %130 = fdiv double %129, 3.000000e+00
  %131 = getelementptr inbounds double, ptr %49, i64 %indvars.iv178
  store double %130, ptr %131, align 8, !tbaa !8
  %132 = fmul double %128, 5.000000e-01
  %133 = fsub double %132, %125
  %134 = getelementptr inbounds double, ptr %50, i64 %indvars.iv178
  store double %133, ptr %134, align 8, !tbaa !8
  %135 = fsub double %126, %127
  %136 = getelementptr inbounds double, ptr %51, i64 %indvars.iv178
  store double %135, ptr %136, align 8, !tbaa !8
  %137 = getelementptr inbounds double, ptr %52, i64 %indvars.iv178
  store double %108, ptr %137, align 8, !tbaa !8
  %indvars.iv.next179 = add nuw nsw i64 %indvars.iv178, 1
  %indvars.iv.next181 = add nuw nsw i64 %indvars.iv180, 4
  %exitcond185.not = icmp eq i64 %indvars.iv.next179, %wide.trip.count
  br i1 %exitcond185.not, label %._crit_edge169, label %.lr.ph168, !llvm.loop !15

138:                                              ; preds = %._crit_edge169
  call void @encode_channel(ptr dead_on_unwind nonnull writable sret(%struct.encoded_channel) align 8 %8, ptr noundef %52, i8 noundef zeroext 5, i8 noundef zeroext 5, i8 noundef zeroext %0, i8 noundef zeroext %1)
  br label %143

139:                                              ; preds = %._crit_edge169
  store double 1.000000e+00, ptr %8, align 8, !tbaa !16
  %140 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr null, ptr %140, align 8, !tbaa !20
  %141 = getelementptr inbounds i8, ptr %8, i64 16
  store i32 0, ptr %141, align 8, !tbaa !21
  %142 = getelementptr inbounds i8, ptr %8, i64 24
  store double 1.000000e+00, ptr %142, align 8, !tbaa !22
  br label %143

143:                                              ; preds = %139, %138
  %144 = phi i32 [ 0, %139 ], [ 8388608, %138 ]
  call void @free(ptr noundef %49) #9
  call void @free(ptr noundef %50) #9
  call void @free(ptr noundef %51) #9
  call void @free(ptr noundef %52) #9
  %145 = icmp ugt i8 %0, %1
  %146 = load double, ptr %5, align 8, !tbaa !16
  %147 = fmul double %146, 6.300000e+01
  %148 = fptrunc double %147 to float
  %149 = call float @llvm.round.f32(float %148)
  %150 = fptoui float %149 to i32
  %151 = load double, ptr %6, align 8, !tbaa !16
  %152 = call double @llvm.fmuladd.f64(double %151, double 3.150000e+01, double 3.150000e+01)
  %153 = fptrunc double %152 to float
  %154 = call float @llvm.round.f32(float %153)
  %155 = fptoui float %154 to i32
  %156 = shl i32 %155, 6
  %157 = or i32 %156, %150
  %158 = load double, ptr %7, align 8, !tbaa !16
  %159 = call double @llvm.fmuladd.f64(double %158, double 3.150000e+01, double 3.150000e+01)
  %160 = fptrunc double %159 to float
  %161 = call float @llvm.round.f32(float %160)
  %162 = fptoui float %161 to i32
  %163 = shl i32 %162, 12
  %164 = or i32 %157, %163
  %165 = getelementptr inbounds i8, ptr %5, i64 24
  %166 = load double, ptr %165, align 8, !tbaa !22
  %167 = fmul double %166, 3.100000e+01
  %168 = fptrunc double %167 to float
  %169 = call float @llvm.round.f32(float %168)
  %170 = fptoui float %169 to i32
  %171 = shl i32 %170, 18
  %172 = or i32 %171, %144
  %173 = or i32 %172, %164
  %.v = select i1 %145, i8 %46, i8 %39
  %174 = getelementptr inbounds i8, ptr %6, i64 24
  %175 = load double, ptr %174, align 8, !tbaa !22
  %176 = fmul double %175, 6.300000e+01
  %177 = fptrunc double %176 to float
  %178 = call float @llvm.round.f32(float %177)
  %179 = fptoui float %178 to i16
  %180 = zext i16 %179 to i32
  %181 = shl nuw nsw i32 %180, 3
  %182 = getelementptr inbounds i8, ptr %7, i64 24
  %183 = load double, ptr %182, align 8, !tbaa !22
  %184 = fmul double %183, 6.300000e+01
  %185 = fptrunc double %184 to float
  %186 = call float @llvm.round.f32(float %185)
  %187 = fptoui float %186 to i16
  %188 = zext i16 %187 to i32
  %189 = shl nuw nsw i32 %188, 9
  %190 = select i1 %145, i32 32768, i32 0
  %191 = or i32 %190, %189
  %192 = or i32 %191, %181
  %193 = trunc i32 %157 to i8
  store i8 %193, ptr %3, align 1, !tbaa !5
  %194 = lshr i32 %164, 8
  %195 = trunc i32 %194 to i8
  %196 = getelementptr inbounds i8, ptr %3, i64 1
  store i8 %195, ptr %196, align 1, !tbaa !5
  %197 = lshr i32 %173, 16
  %198 = trunc i32 %197 to i8
  %199 = getelementptr inbounds i8, ptr %3, i64 2
  store i8 %198, ptr %199, align 1, !tbaa !5
  %200 = trunc i32 %181 to i8
  %201 = or i8 %.v, %200
  %202 = getelementptr inbounds i8, ptr %3, i64 3
  store i8 %201, ptr %202, align 1, !tbaa !5
  %203 = lshr i32 %192, 8
  %204 = trunc i32 %203 to i8
  %205 = getelementptr inbounds i8, ptr %3, i64 4
  store i8 %204, ptr %205, align 1, !tbaa !5
  br i1 %28, label %206, label %221

206:                                              ; preds = %143
  %207 = load double, ptr %8, align 8, !tbaa !16
  %208 = fmul double %207, 1.500000e+01
  %209 = fptrunc double %208 to float
  %210 = call float @llvm.round.f32(float %209)
  %211 = fptoui float %210 to i8
  %212 = getelementptr inbounds i8, ptr %8, i64 24
  %213 = load double, ptr %212, align 8, !tbaa !22
  %214 = fmul double %213, 1.500000e+01
  %215 = fptrunc double %214 to float
  %216 = call float @llvm.round.f32(float %215)
  %217 = fptoui float %216 to i8
  %218 = shl i8 %217, 4
  %219 = or i8 %218, %211
  %220 = getelementptr inbounds i8, ptr %3, i64 5
  store i8 %219, ptr %220, align 1, !tbaa !5
  br label %221

221:                                              ; preds = %206, %143
  %222 = phi i32 [ 6, %206 ], [ 5, %143 ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #9
  store i8 0, ptr %9, align 1, !tbaa !5
  %223 = getelementptr inbounds i8, ptr %5, i64 8
  %224 = load ptr, ptr %223, align 8, !tbaa !20
  %225 = getelementptr inbounds i8, ptr %5, i64 16
  %226 = load i32, ptr %225, align 8, !tbaa !21
  %227 = zext nneg i32 %222 to i64
  %228 = getelementptr inbounds i8, ptr %3, i64 %227
  %229 = call zeroext i8 @write_varying_factors(ptr noundef %224, i32 noundef %226, ptr noundef nonnull %228, ptr noundef nonnull %9)
  %230 = getelementptr inbounds i8, ptr %6, i64 8
  %231 = load ptr, ptr %230, align 8, !tbaa !20
  %232 = getelementptr inbounds i8, ptr %6, i64 16
  %233 = load i32, ptr %232, align 8, !tbaa !21
  %234 = call zeroext i8 @write_varying_factors(ptr noundef %231, i32 noundef %233, ptr noundef nonnull %228, ptr noundef nonnull %9)
  %235 = getelementptr inbounds i8, ptr %7, i64 8
  %236 = load ptr, ptr %235, align 8, !tbaa !20
  %237 = getelementptr inbounds i8, ptr %7, i64 16
  %238 = load i32, ptr %237, align 8, !tbaa !21
  %239 = call zeroext i8 @write_varying_factors(ptr noundef %236, i32 noundef %238, ptr noundef nonnull %228, ptr noundef nonnull %9)
  br i1 %28, label %240, label %.critedge

240:                                              ; preds = %221
  %241 = getelementptr inbounds i8, ptr %8, i64 8
  %242 = load ptr, ptr %241, align 8, !tbaa !20
  %243 = getelementptr inbounds i8, ptr %8, i64 16
  %244 = load i32, ptr %243, align 8, !tbaa !21
  %245 = call zeroext i8 @write_varying_factors(ptr noundef %242, i32 noundef %244, ptr noundef nonnull %228, ptr noundef nonnull %9)
  %246 = load ptr, ptr %223, align 8, !tbaa !20
  call void @free(ptr noundef %246) #9
  br label %.critedge

.critedge:                                        ; preds = %221, %240
  %.sink194 = phi ptr [ %230, %240 ], [ %223, %221 ]
  %.sink193 = phi ptr [ %235, %240 ], [ %230, %221 ]
  %.sink192 = phi ptr [ %241, %240 ], [ %235, %221 ]
  %.sroa.10.0 = phi i8 [ %245, %240 ], [ 0, %221 ]
  %247 = load ptr, ptr %.sink194, align 8, !tbaa !20
  call void @free(ptr noundef %247) #9
  %248 = load ptr, ptr %.sink193, align 8, !tbaa !20
  call void @free(ptr noundef %248) #9
  %249 = load ptr, ptr %.sink192, align 8, !tbaa !20
  call void @free(ptr noundef %249) #9
  %spec.store.select = call i8 @llvm.umax.i8(i8 %229, i8 %234)
  %spec.store.select.1 = call i8 @llvm.umax.i8(i8 %spec.store.select, i8 %239)
  %spec.store.select.2 = call i8 @llvm.umax.i8(i8 %spec.store.select.1, i8 %.sroa.10.0)
  %250 = trunc nuw nsw i32 %222 to i8
  %251 = add nuw nsw i8 %250, 1
  %252 = add i8 %251, %spec.store.select.2
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #9
  ret i8 %252
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #5

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #6

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #5 = { noreturn 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind allocsize(0) }
attributes #9 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"double", !6, i64 0}
!10 = distinct !{!10, !11, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11, !13, !12}
!16 = !{!17, !9, i64 0}
!17 = !{!"encoded_channel", !9, i64 0, !18, i64 8, !19, i64 16, !9, i64 24}
!18 = !{!"any pointer", !6, i64 0}
!19 = !{!"int", !6, i64 0}
!20 = !{!17, !18, i64 8}
!21 = !{!17, !19, i64 16}
!22 = !{!17, !9, i64 24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass