; LLVM IR from facebookresearch/habitat-sim :: src/deps/basis-universal/encoder (basisu_etc)

; 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.anon.7 = type { [4 x i8] }
%"struct.basisu::etc1_solution_coordinates" = type <{ %"class.basisu::color_rgba", i32, i8, [3 x i8] }>
%"class.basisu::color_rgba" = type { %union.anon }
%union.anon = type { [4 x i8] }
%"class.basisu::etc1_optimizer" = type { ptr, ptr, i32, %"class.basisu::vec", i32, i32, i32, i32, %"class.basisu::vector", %"class.basisu::vector.3", %"class.basisu::vector.3", ptr, ptr, %"class.basisu::vector.5", %"class.basisu::vector.5", %"struct.basisu::etc1_optimizer::potential_solution", %"struct.basisu::etc1_optimizer::potential_solution", %"class.basisu::vector.5", [128 x i8] }
%"class.basisu::vec" = type { [3 x float] }
%"class.basisu::vector" = type { ptr, i32, i32 }
%"class.basisu::vector.3" = type { ptr, i32, i32 }
%"struct.basisu::etc1_optimizer::potential_solution" = type <{ %"struct.basisu::etc1_solution_coordinates", [4 x i8], %"class.basisu::vector.5", i64, i8, [7 x i8] }>
%"class.basisu::vector.5" = type { ptr, i32, i32 }
%struct.anon = type { i8, i8, i8, i8 }
%"struct.basisu::etc1_optimizer::params" = type { %"struct.basisu::basis_etc1_pack_params", i32, ptr, i8, ptr, i32, %"class.basisu::color_rgba", i8, i8, ptr }
%"struct.basisu::basis_etc1_pack_params" = type { i32, i8, i8, i8, i8, float }

@_ZN6basisu19g_etc1_inten_tablesE = external dso_local constant [8 x [4 x i32]], align 16
@_ZN6basisuL23g_cluster_fit_order_tabE = external hidden constant [165 x %struct.anon.7], align 16

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu14etc1_optimizer28compute_internal_cluster_fitEj(ptr noundef nonnull align 8 dereferenceable(384) %0, i32 noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"struct.basisu::etc1_solution_coordinates", align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca %"class.basisu::color_rgba", align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca %"struct.basisu::etc1_solution_coordinates", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %23 = load ptr, ptr %3, align 8
  %24 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %25 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %24, i32 0, i32 4
  %26 = load i8, ptr %25, align 8, !tbaa !11, !range !22, !noundef !23
  %27 = trunc i8 %26 to i1
  br i1 %27, label %28, label %61

28:                                               ; preds = %2
  %29 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 4
  %30 = load i32, ptr %29, align 8, !tbaa !24
  %31 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %32 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %"struct.basisu::etc1_solution_coordinates", ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %"class.basisu::color_rgba", ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.anon, ptr %34, i32 0, i32 0
  %36 = load i8, ptr %35, align 8, !tbaa !25
  %37 = zext i8 %36 to i32
  %38 = icmp ne i32 %30, %37
  br i1 %38, label %61, label %39

39:                                               ; preds = %28
  %40 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 5
  %41 = load i32, ptr %40, align 4, !tbaa !26
  %42 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %43 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %"struct.basisu::etc1_solution_coordinates", ptr %43, i32 0, i32 0
  %45 = getelementptr inbounds %"class.basisu::color_rgba", ptr %44, i32 0, i32 0
  %46 = getelementptr inbounds %struct.anon, ptr %45, i32 0, i32 1
  %47 = load i8, ptr %46, align 1, !tbaa !25
  %48 = zext i8 %47 to i32
  %49 = icmp ne i32 %41, %48
  br i1 %49, label %61, label %50

50:                                               ; preds = %39
  %51 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 6
  %52 = load i32, ptr %51, align 8, !tbaa !27
  %53 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %54 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds %"struct.basisu::etc1_solution_coordinates", ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds %"class.basisu::color_rgba", ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds %struct.anon, ptr %56, i32 0, i32 2
  %58 = load i8, ptr %57, align 2, !tbaa !25
  %59 = zext i8 %58 to i32
  %60 = icmp ne i32 %52, %59
  br i1 %60, label %61, label %76

61:                                               ; preds = %50, %39, %28, %2
  call void @llvm.lifetime.start.p0(i64 12, ptr %5) #4
  %62 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 4
  %63 = load i32, ptr %62, align 8, !tbaa !24
  %64 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 5
  %65 = load i32, ptr %64, align 4, !tbaa !26
  %66 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 6
  %67 = load i32, ptr %66, align 8, !tbaa !27
  %68 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !28
  %70 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %69, i32 0, i32 3
  %71 = load i8, ptr %70, align 8, !tbaa !29, !range !22, !noundef !23
  %72 = trunc i8 %71 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %5, i32 noundef %63, i32 noundef %65, i32 noundef %67, i32 noundef 0, i1 noundef zeroext %72)
  %73 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 16
  %74 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %75 = call noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384) %23, ptr noundef nonnull align 4 dereferenceable(9) %5, ptr noundef nonnull align 8 dereferenceable(41) %73, ptr noundef %74)
  call void @llvm.lifetime.end.p0(i64 12, ptr %5) #4
  br label %76

76:                                               ; preds = %61, %50
  %77 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %78 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %77, i32 0, i32 3
  %79 = load i64, ptr %78, align 8, !tbaa !34
  %80 = icmp eq i64 %79, 0
  br i1 %80, label %86, label %81

81:                                               ; preds = %76
  %82 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %83 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %82, i32 0, i32 4
  %84 = load i8, ptr %83, align 8, !tbaa !11, !range !22, !noundef !23
  %85 = trunc i8 %84 to i1
  br i1 %85, label %87, label %86

86:                                               ; preds = %81, %76
  br label %277

87:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %273, %87
  %89 = load i32, ptr %6, align 4, !tbaa !9
  %90 = load i32, ptr %4, align 4, !tbaa !9
  %91 = icmp ult i32 %89, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %88
  store i32 2, ptr %7, align 4
  br label %276

93:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %94 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %95 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %94, i32 0, i32 0
  %96 = getelementptr inbounds %"struct.basisu::etc1_solution_coordinates", ptr %95, i32 0, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !35
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds [8 x [4 x i32]], ptr @_ZN6basisu19g_etc1_inten_tablesE, i64 0, i64 %98
  %100 = getelementptr inbounds [4 x i32], ptr %99, i64 0, i64 0
  store ptr %100, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %101 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %102 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %101, i32 0, i32 0
  %103 = call i32 @_ZNK6basisu25etc1_solution_coordinates16get_scaled_colorEv(ptr noundef nonnull align 4 dereferenceable(9) %102)
  %104 = getelementptr inbounds %"class.basisu::color_rgba", ptr %12, i32 0, i32 0
  %105 = getelementptr inbounds %union.anon, ptr %104, i32 0, i32 0
  store i32 %103, ptr %105, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %106 = load i32, ptr %6, align 4, !tbaa !9
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds [165 x %struct.anon.7], ptr @_ZN6basisuL23g_cluster_fit_order_tabE, i64 0, i64 %107
  %109 = getelementptr inbounds %struct.anon.7, ptr %108, i32 0, i32 0
  %110 = getelementptr inbounds [4 x i8], ptr %109, i64 0, i64 0
  store ptr %110, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %184, %93
  %112 = load i32, ptr %14, align 4, !tbaa !9
  %113 = icmp ult i32 %112, 4
  br i1 %113, label %115, label %114

114:                                              ; preds = %111
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %187

115:                                              ; preds = %111
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %116 = load ptr, ptr %11, align 8, !tbaa !5
  %117 = load i32, ptr %14, align 4, !tbaa !9
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds i32, ptr %116, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !9
  store i32 %120, ptr %15, align 4, !tbaa !9
  %121 = load ptr, ptr %13, align 8, !tbaa !5
  %122 = load i32, ptr %14, align 4, !tbaa !9
  %123 = zext i32 %122 to i64
  %124 = getelementptr inbounds i8, ptr %121, i64 %123
  %125 = load i8, ptr %124, align 1, !tbaa !25
  %126 = zext i8 %125 to i32
  %127 = getelementptr inbounds %"class.basisu::color_rgba", ptr %12, i32 0, i32 0
  %128 = getelementptr inbounds %struct.anon, ptr %127, i32 0, i32 0
  %129 = load i8, ptr %128, align 1, !tbaa !25
  %130 = zext i8 %129 to i32
  %131 = load i32, ptr %15, align 4, !tbaa !9
  %132 = add nsw i32 %130, %131
  %133 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %132, i32 noundef 0, i32 noundef 255)
  %134 = getelementptr inbounds %"class.basisu::color_rgba", ptr %12, i32 0, i32 0
  %135 = getelementptr inbounds %struct.anon, ptr %134, i32 0, i32 0
  %136 = load i8, ptr %135, align 1, !tbaa !25
  %137 = zext i8 %136 to i32
  %138 = sub nsw i32 %133, %137
  %139 = mul nsw i32 %126, %138
  %140 = load i32, ptr %8, align 4, !tbaa !9
  %141 = add nsw i32 %140, %139
  store i32 %141, ptr %8, align 4, !tbaa !9
  %142 = load ptr, ptr %13, align 8, !tbaa !5
  %143 = load i32, ptr %14, align 4, !tbaa !9
  %144 = zext i32 %143 to i64
  %145 = getelementptr inbounds i8, ptr %142, i64 %144
  %146 = load i8, ptr %145, align 1, !tbaa !25
  %147 = zext i8 %146 to i32
  %148 = getelementptr inbounds %"class.basisu::color_rgba", ptr %12, i32 0, i32 0
  %149 = getelementptr inbounds %struct.anon, ptr %148, i32 0, i32 1
  %150 = load i8, ptr %149, align 1, !tbaa !25
  %151 = zext i8 %150 to i32
  %152 = load i32, ptr %15, align 4, !tbaa !9
  %153 = add nsw i32 %151, %152
  %154 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %153, i32 noundef 0, i32 noundef 255)
  %155 = getelementptr inbounds %"class.basisu::color_rgba", ptr %12, i32 0, i32 0
  %156 = getelementptr inbounds %struct.anon, ptr %155, i32 0, i32 1
  %157 = load i8, ptr %156, align 1, !tbaa !25
  %158 = zext i8 %157 to i32
  %159 = sub nsw i32 %154, %158
  %160 = mul nsw i32 %147, %159
  %161 = load i32, ptr %9, align 4, !tbaa !9
  %162 = add nsw i32 %161, %160
  store i32 %162, ptr %9, align 4, !tbaa !9
  %163 = load ptr, ptr %13, align 8, !tbaa !5
  %164 = load i32, ptr %14, align 4, !tbaa !9
  %165 = zext i32 %164 to i64
  %166 = getelementptr inbounds i8, ptr %163, i64 %165
  %167 = load i8, ptr %166, align 1, !tbaa !25
  %168 = zext i8 %167 to i32
  %169 = getelementptr inbounds %"class.basisu::color_rgba", ptr %12, i32 0, i32 0
  %170 = getelementptr inbounds %struct.anon, ptr %169, i32 0, i32 2
  %171 = load i8, ptr %170, align 1, !tbaa !25
  %172 = zext i8 %171 to i32
  %173 = load i32, ptr %15, align 4, !tbaa !9
  %174 = add nsw i32 %172, %173
  %175 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %174, i32 noundef 0, i32 noundef 255)
  %176 = getelementptr inbounds %"class.basisu::color_rgba", ptr %12, i32 0, i32 0
  %177 = getelementptr inbounds %struct.anon, ptr %176, i32 0, i32 2
  %178 = load i8, ptr %177, align 1, !tbaa !25
  %179 = zext i8 %178 to i32
  %180 = sub nsw i32 %175, %179
  %181 = mul nsw i32 %168, %180
  %182 = load i32, ptr %10, align 4, !tbaa !9
  %183 = add nsw i32 %182, %181
  store i32 %183, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %184

184:                                              ; preds = %115
  %185 = load i32, ptr %14, align 4, !tbaa !9
  %186 = add i32 %185, 1
  store i32 %186, ptr %14, align 4, !tbaa !9
  br label %111, !llvm.loop !36

187:                                              ; preds = %114
  %188 = load i32, ptr %8, align 4, !tbaa !9
  %189 = icmp ne i32 %188, 0
  br i1 %189, label %197, label %190

190:                                              ; preds = %187
  %191 = load i32, ptr %9, align 4, !tbaa !9
  %192 = icmp ne i32 %191, 0
  br i1 %192, label %197, label %193

193:                                              ; preds = %190
  %194 = load i32, ptr %10, align 4, !tbaa !9
  %195 = icmp ne i32 %194, 0
  br i1 %195, label %197, label %196

196:                                              ; preds = %193
  store i32 4, ptr %7, align 4
  br label %270

197:                                              ; preds = %193, %190, %187
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %198 = load i32, ptr %8, align 4, !tbaa !9
  %199 = sitofp i32 %198 to float
  %200 = fdiv float %199, 8.000000e+00
  store float %200, ptr %16, align 4, !tbaa !38
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %201 = load i32, ptr %9, align 4, !tbaa !9
  %202 = sitofp i32 %201 to float
  %203 = fdiv float %202, 8.000000e+00
  store float %203, ptr %17, align 4, !tbaa !38
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %204 = load i32, ptr %10, align 4, !tbaa !9
  %205 = sitofp i32 %204 to float
  %206 = fdiv float %205, 8.000000e+00
  store float %206, ptr %18, align 4, !tbaa !38
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %207 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 3
  %208 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %207, i32 noundef 0)
  %209 = load float, ptr %208, align 4, !tbaa !38
  %210 = load float, ptr %16, align 4, !tbaa !38
  %211 = fsub float %209, %210
  %212 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 2
  %213 = load i32, ptr %212, align 8, !tbaa !39
  %214 = sitofp i32 %213 to float
  %215 = fmul float %211, %214
  %216 = fdiv float %215, 2.550000e+02
  %217 = fadd float %216, 5.000000e-01
  %218 = fptosi float %217 to i32
  %219 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 2
  %220 = load i32, ptr %219, align 8, !tbaa !39
  %221 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %218, i32 noundef 0, i32 noundef %220)
  store i32 %221, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %222 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 3
  %223 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %222, i32 noundef 1)
  %224 = load float, ptr %223, align 4, !tbaa !38
  %225 = load float, ptr %17, align 4, !tbaa !38
  %226 = fsub float %224, %225
  %227 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 2
  %228 = load i32, ptr %227, align 8, !tbaa !39
  %229 = sitofp i32 %228 to float
  %230 = fmul float %226, %229
  %231 = fdiv float %230, 2.550000e+02
  %232 = fadd float %231, 5.000000e-01
  %233 = fptosi float %232 to i32
  %234 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 2
  %235 = load i32, ptr %234, align 8, !tbaa !39
  %236 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %233, i32 noundef 0, i32 noundef %235)
  store i32 %236, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %237 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 3
  %238 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %237, i32 noundef 2)
  %239 = load float, ptr %238, align 4, !tbaa !38
  %240 = load float, ptr %18, align 4, !tbaa !38
  %241 = fsub float %239, %240
  %242 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 2
  %243 = load i32, ptr %242, align 8, !tbaa !39
  %244 = sitofp i32 %243 to float
  %245 = fmul float %241, %244
  %246 = fdiv float %245, 2.550000e+02
  %247 = fadd float %246, 5.000000e-01
  %248 = fptosi float %247 to i32
  %249 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 2
  %250 = load i32, ptr %249, align 8, !tbaa !39
  %251 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %248, i32 noundef 0, i32 noundef %250)
  store i32 %251, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %22) #4
  %252 = load i32, ptr %19, align 4, !tbaa !9
  %253 = load i32, ptr %20, align 4, !tbaa !9
  %254 = load i32, ptr %21, align 4, !tbaa !9
  %255 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 0
  %256 = load ptr, ptr %255, align 8, !tbaa !28
  %257 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %256, i32 0, i32 3
  %258 = load i8, ptr %257, align 8, !tbaa !29, !range !22, !noundef !23
  %259 = trunc i8 %258 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %22, i32 noundef %252, i32 noundef %253, i32 noundef %254, i32 noundef 0, i1 noundef zeroext %259)
  %260 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 16
  %261 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %262 = call noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384) %23, ptr noundef nonnull align 4 dereferenceable(9) %22, ptr noundef nonnull align 8 dereferenceable(41) %260, ptr noundef %261)
  call void @llvm.lifetime.end.p0(i64 12, ptr %22) #4
  %263 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %23, i32 0, i32 15
  %264 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %263, i32 0, i32 3
  %265 = load i64, ptr %264, align 8, !tbaa !34
  %266 = icmp eq i64 %265, 0
  br i1 %266, label %267, label %268

267:                                              ; preds = %197
  store i32 2, ptr %7, align 4
  br label %269

268:                                              ; preds = %197
  store i32 0, ptr %7, align 4
  br label %269

269:                                              ; preds = %268, %267
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %270

270:                                              ; preds = %269, %196
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %271 = load i32, ptr %7, align 4
  switch i32 %271, label %276 [
    i32 0, label %272
    i32 4, label %273
  ]

272:                                              ; preds = %270
  br label %273

273:                                              ; preds = %272, %270
  %274 = load i32, ptr %6, align 4, !tbaa !9
  %275 = add i32 %274, 1
  store i32 %275, ptr %6, align 4, !tbaa !9
  br label %88, !llvm.loop !40

276:                                              ; preds = %270, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %277

277:                                              ; preds = %276, %86
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK6basisu25etc1_solution_coordinates16get_scaled_colorEv(ptr noundef nonnull align 4 dereferenceable(9)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384), ptr noundef nonnull align 4 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(41), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9), i32 noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #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 = { inlinehint 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 #4 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !20, i64 184}
!12 = !{!"_ZTSN6basisu14etc1_optimizerE", !6, i64 0, !6, i64 8, !10, i64 16, !13, i64 20, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !14, i64 48, !15, i64 64, !15, i64 80, !6, i64 96, !6, i64 104, !16, i64 112, !16, i64 128, !17, i64 144, !17, i64 192, !16, i64 240, !7, i64 256}
!13 = !{!"_ZTSN6basisu3vecILj3EfEE", !7, i64 0}
!14 = !{!"_ZTSN6basisu6vectorItEE", !6, i64 0, !10, i64 8, !10, i64 12}
!15 = !{!"_ZTSN6basisu6vectorIjEE", !6, i64 0, !10, i64 8, !10, i64 12}
!16 = !{!"_ZTSN6basisu6vectorIhEE", !6, i64 0, !10, i64 8, !10, i64 12}
!17 = !{!"_ZTSN6basisu14etc1_optimizer18potential_solutionE", !18, i64 0, !16, i64 16, !21, i64 32, !20, i64 40}
!18 = !{!"_ZTSN6basisu25etc1_solution_coordinatesE", !19, i64 0, !10, i64 4, !20, i64 8}
!19 = !{!"_ZTSN6basisu10color_rgbaE", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!12, !10, i64 32}
!25 = !{!7, !7, i64 0}
!26 = !{!12, !10, i64 36}
!27 = !{!12, !10, i64 40}
!28 = !{!12, !6, i64 0}
!29 = !{!30, !20, i64 24}
!30 = !{!"_ZTSN6basisu14etc1_optimizer6paramsE", !31, i64 0, !10, i64 12, !6, i64 16, !20, i64 24, !6, i64 32, !10, i64 40, !19, i64 44, !20, i64 48, !20, i64 49, !6, i64 56}
!31 = !{!"_ZTSN6basisu22basis_etc1_pack_paramsE", !32, i64 0, !20, i64 4, !20, i64 5, !20, i64 6, !20, i64 7, !33, i64 8}
!32 = !{!"_ZTSN6basisu17basis_etc_qualityE", !7, i64 0}
!33 = !{!"float", !7, i64 0}
!34 = !{!12, !21, i64 176}
!35 = !{!12, !10, i64 148}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}
!38 = !{!33, !33, i64 0}
!39 = !{!12, !10, i64 16}
!40 = distinct !{!40, !37}


; 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.anon.7 = type { [4 x i8] }
%"struct.basisu::etc1_solution_coordinates" = type <{ %"class.basisu::color_rgba", i32, i8, [3 x i8] }>
%"class.basisu::color_rgba" = type { %union.anon }
%union.anon = type { [4 x i8] }

@_ZN6basisu19g_etc1_inten_tablesE = external dso_local local_unnamed_addr constant [8 x [4 x i32]], align 16
@_ZN6basisuL23g_cluster_fit_order_tabE = external hidden local_unnamed_addr constant [165 x %struct.anon.7], align 16

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu14etc1_optimizer28compute_internal_cluster_fitEj(ptr noundef nonnull align 8 dereferenceable(384) %0, i32 noundef %1) local_unnamed_addr #2 align 2 {
  %3 = alloca %"struct.basisu::etc1_solution_coordinates", align 4
  %4 = alloca %"struct.basisu::etc1_solution_coordinates", align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 144
  %6 = getelementptr inbounds i8, ptr %0, i64 184
  %7 = load i8, ptr %6, align 8, !tbaa !5, !range !20, !noundef !21
  %8 = trunc nuw i8 %7 to i1
  %9 = getelementptr inbounds i8, ptr %0, i64 32
  %10 = load i32, ptr %9, align 8, !tbaa !22
  %11 = load i8, ptr %5, align 8
  %12 = zext i8 %11 to i32
  %.not = icmp eq i32 %10, %12
  %or.cond61 = select i1 %8, i1 %.not, i1 false
  br i1 %or.cond61, label %13, label %._crit_edge

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %0, i64 36
  %15 = load i32, ptr %14, align 4, !tbaa !23
  %16 = getelementptr inbounds i8, ptr %0, i64 145
  %17 = load i8, ptr %16, align 1, !tbaa !24
  %18 = zext i8 %17 to i32
  %.not44 = icmp eq i32 %15, %18
  br i1 %.not44, label %19, label %._crit_edge

19:                                               ; preds = %13
  %20 = getelementptr inbounds i8, ptr %0, i64 40
  %21 = load i32, ptr %20, align 8, !tbaa !25
  %22 = getelementptr inbounds i8, ptr %0, i64 146
  %23 = load i8, ptr %22, align 2, !tbaa !24
  %24 = zext i8 %23 to i32
  %.not45 = icmp eq i32 %21, %24
  br i1 %.not45, label %35, label %._crit_edge

._crit_edge:                                      ; preds = %2, %19, %13
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  %25 = getelementptr inbounds i8, ptr %0, i64 36
  %26 = load i32, ptr %25, align 4, !tbaa !23
  %27 = getelementptr inbounds i8, ptr %0, i64 40
  %28 = load i32, ptr %27, align 8, !tbaa !25
  %29 = load ptr, ptr %0, align 8, !tbaa !26
  %30 = getelementptr inbounds i8, ptr %29, i64 24
  %31 = load i8, ptr %30, align 8, !tbaa !27, !range !20, !noundef !21
  %32 = trunc nuw i8 %31 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %3, i32 noundef %10, i32 noundef %26, i32 noundef %28, i32 noundef 0, i1 noundef zeroext %32)
  %33 = getelementptr inbounds i8, ptr %0, i64 192
  %34 = call noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384) %0, ptr noundef nonnull align 4 dereferenceable(9) %3, ptr noundef nonnull align 8 dereferenceable(41) %33, ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  br label %35

35:                                               ; preds = %._crit_edge, %19
  %36 = getelementptr inbounds i8, ptr %0, i64 176
  %37 = load i64, ptr %36, align 8, !tbaa !32
  %38 = icmp eq i64 %37, 0
  br i1 %38, label %.loopexit, label %39

39:                                               ; preds = %35
  %40 = load i8, ptr %6, align 8, !tbaa !5, !range !20, !noundef !21
  %41 = trunc nuw i8 %40 to i1
  %42 = icmp ne i32 %1, 0
  %or.cond53 = and i1 %42, %41
  br i1 %or.cond53, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %39
  %43 = getelementptr inbounds i8, ptr %0, i64 148
  %44 = getelementptr inbounds i8, ptr %0, i64 20
  %45 = getelementptr inbounds i8, ptr %0, i64 16
  %46 = getelementptr inbounds i8, ptr %0, i64 192
  br label %.backedge

.backedge:                                        ; preds = %.backedge.backedge, %.lr.ph
  %.051 = phi i32 [ 0, %.lr.ph ], [ %.051.be, %.backedge.backedge ]
  %47 = load i32, ptr %43, align 4, !tbaa !33
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds [8 x [4 x i32]], ptr @_ZN6basisu19g_etc1_inten_tablesE, i64 0, i64 %48
  %50 = call i32 @_ZNK6basisu25etc1_solution_coordinates16get_scaled_colorEv(ptr noundef nonnull align 4 dereferenceable(9) %5)
  %.sroa.5.0.extract.shift = lshr i32 %50, 8
  %.sroa.7.0.extract.shift = lshr i32 %50, 16
  %51 = zext i32 %.051 to i64
  %52 = getelementptr inbounds [165 x %struct.anon.7], ptr @_ZN6basisuL23g_cluster_fit_order_tabE, i64 0, i64 %51
  %53 = and i32 %50, 255
  %54 = and i32 %.sroa.5.0.extract.shift, 255
  %55 = and i32 %.sroa.7.0.extract.shift, 255
  %56 = load i32, ptr %49, align 16, !tbaa !34
  %57 = load i8, ptr %52, align 4, !tbaa !24
  %58 = zext i8 %57 to i32
  %59 = add nsw i32 %56, %53
  %60 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %59, i32 noundef 0, i32 noundef 255)
  %61 = sub nsw i32 %60, %53
  %62 = mul nsw i32 %61, %58
  %63 = add nsw i32 %56, %54
  %64 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %63, i32 noundef 0, i32 noundef 255)
  %65 = sub nsw i32 %64, %54
  %66 = mul nsw i32 %65, %58
  %67 = add nsw i32 %56, %55
  %68 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %67, i32 noundef 0, i32 noundef 255)
  %69 = sub nsw i32 %68, %55
  %70 = mul nsw i32 %69, %58
  %71 = getelementptr inbounds i8, ptr %49, i64 4
  %72 = load i32, ptr %71, align 4, !tbaa !34
  %73 = getelementptr inbounds i8, ptr %52, i64 1
  %74 = load i8, ptr %73, align 1, !tbaa !24
  %75 = zext i8 %74 to i32
  %76 = add nsw i32 %72, %53
  %77 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %76, i32 noundef 0, i32 noundef 255)
  %78 = sub nsw i32 %77, %53
  %79 = mul nsw i32 %78, %75
  %80 = add nsw i32 %79, %62
  %81 = add nsw i32 %72, %54
  %82 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %81, i32 noundef 0, i32 noundef 255)
  %83 = sub nsw i32 %82, %54
  %84 = mul nsw i32 %83, %75
  %85 = add nsw i32 %84, %66
  %86 = add nsw i32 %72, %55
  %87 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %86, i32 noundef 0, i32 noundef 255)
  %88 = sub nsw i32 %87, %55
  %89 = mul nsw i32 %88, %75
  %90 = add nsw i32 %89, %70
  %91 = getelementptr inbounds i8, ptr %49, i64 8
  %92 = load i32, ptr %91, align 8, !tbaa !34
  %93 = getelementptr inbounds i8, ptr %52, i64 2
  %94 = load i8, ptr %93, align 2, !tbaa !24
  %95 = zext i8 %94 to i32
  %96 = add nsw i32 %92, %53
  %97 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %96, i32 noundef 0, i32 noundef 255)
  %98 = sub nsw i32 %97, %53
  %99 = mul nsw i32 %98, %95
  %100 = add nsw i32 %99, %80
  %101 = add nsw i32 %92, %54
  %102 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %101, i32 noundef 0, i32 noundef 255)
  %103 = sub nsw i32 %102, %54
  %104 = mul nsw i32 %103, %95
  %105 = add nsw i32 %104, %85
  %106 = add nsw i32 %92, %55
  %107 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %106, i32 noundef 0, i32 noundef 255)
  %108 = sub nsw i32 %107, %55
  %109 = mul nsw i32 %108, %95
  %110 = add nsw i32 %109, %90
  %111 = getelementptr inbounds i8, ptr %49, i64 12
  %112 = load i32, ptr %111, align 4, !tbaa !34
  %113 = getelementptr inbounds i8, ptr %52, i64 3
  %114 = load i8, ptr %113, align 1, !tbaa !24
  %115 = zext i8 %114 to i32
  %116 = add nsw i32 %112, %53
  %117 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %116, i32 noundef 0, i32 noundef 255)
  %118 = sub nsw i32 %117, %53
  %119 = mul nsw i32 %118, %115
  %120 = add nsw i32 %119, %100
  %121 = add nsw i32 %112, %54
  %122 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %121, i32 noundef 0, i32 noundef 255)
  %123 = sub nsw i32 %122, %54
  %124 = mul nsw i32 %123, %115
  %125 = add nsw i32 %124, %105
  %126 = add nsw i32 %112, %55
  %127 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %126, i32 noundef 0, i32 noundef 255)
  %128 = sub nsw i32 %127, %55
  %129 = mul nsw i32 %128, %115
  %130 = add nsw i32 %129, %110
  %131 = icmp ne i32 %120, 0
  %132 = icmp ne i32 %125, 0
  %or.cond = select i1 %131, i1 true, i1 %132
  %133 = icmp ne i32 %130, 0
  %or.cond3 = select i1 %or.cond, i1 true, i1 %133
  br i1 %or.cond3, label %134, label %180

134:                                              ; preds = %.backedge
  %135 = sitofp i32 %120 to float
  %136 = fmul float %135, 1.250000e-01
  %137 = sitofp i32 %125 to float
  %138 = fmul float %137, 1.250000e-01
  %139 = sitofp i32 %130 to float
  %140 = fmul float %139, 1.250000e-01
  %141 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %44, i32 noundef 0)
  %142 = load float, ptr %141, align 4, !tbaa !35
  %143 = fsub float %142, %136
  %144 = load i32, ptr %45, align 8, !tbaa !36
  %145 = sitofp i32 %144 to float
  %146 = fmul float %143, %145
  %147 = fdiv float %146, 2.550000e+02
  %148 = fadd float %147, 5.000000e-01
  %149 = fptosi float %148 to i32
  %150 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %149, i32 noundef 0, i32 noundef %144)
  %151 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %44, i32 noundef 1)
  %152 = load float, ptr %151, align 4, !tbaa !35
  %153 = fsub float %152, %138
  %154 = load i32, ptr %45, align 8, !tbaa !36
  %155 = sitofp i32 %154 to float
  %156 = fmul float %153, %155
  %157 = fdiv float %156, 2.550000e+02
  %158 = fadd float %157, 5.000000e-01
  %159 = fptosi float %158 to i32
  %160 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %159, i32 noundef 0, i32 noundef %154)
  %161 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %44, i32 noundef 2)
  %162 = load float, ptr %161, align 4, !tbaa !35
  %163 = fsub float %162, %140
  %164 = load i32, ptr %45, align 8, !tbaa !36
  %165 = sitofp i32 %164 to float
  %166 = fmul float %163, %165
  %167 = fdiv float %166, 2.550000e+02
  %168 = fadd float %167, 5.000000e-01
  %169 = fptosi float %168 to i32
  %170 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %169, i32 noundef 0, i32 noundef %164)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #4
  %171 = load ptr, ptr %0, align 8, !tbaa !26
  %172 = getelementptr inbounds i8, ptr %171, i64 24
  %173 = load i8, ptr %172, align 8, !tbaa !27, !range !20, !noundef !21
  %174 = trunc nuw i8 %173 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %4, i32 noundef %150, i32 noundef %160, i32 noundef %170, i32 noundef 0, i1 noundef zeroext %174)
  %175 = call noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384) %0, ptr noundef nonnull align 4 dereferenceable(9) %4, ptr noundef nonnull align 8 dereferenceable(41) %46, ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #4
  %176 = load i64, ptr %36, align 8, !tbaa !32
  %177 = icmp ne i64 %176, 0
  %178 = add i32 %.051, 1
  %179 = icmp ult i32 %178, %1
  %or.cond55 = select i1 %177, i1 %179, i1 false
  br i1 %or.cond55, label %.backedge.backedge, label %.loopexit

180:                                              ; preds = %.backedge
  %.old = add i32 %.051, 1
  %.old54 = icmp ult i32 %.old, %1
  br i1 %.old54, label %.backedge.backedge, label %.loopexit

.backedge.backedge:                               ; preds = %180, %134
  %.051.be = phi i32 [ %.old, %180 ], [ %178, %134 ]
  br label %.backedge, !llvm.loop !37

.loopexit:                                        ; preds = %180, %134, %35, %39
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK6basisu25etc1_solution_coordinates16get_scaled_colorEv(ptr noundef nonnull align 4 dereferenceable(9)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384), ptr noundef nonnull align 4 dereferenceable(9), ptr noundef nonnull align 8 dereferenceable(41), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9), i32 noundef, i32 noundef, i32 noundef, i32 noundef, i1 noundef zeroext) unnamed_addr #3 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #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 = { inlinehint 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 #4 = { 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, !18, i64 184}
!6 = !{!"_ZTSN6basisu14etc1_optimizerE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 20, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !12, i64 48, !13, i64 64, !13, i64 80, !7, i64 96, !7, i64 104, !14, i64 112, !14, i64 128, !15, i64 144, !15, i64 192, !14, i64 240, !8, i64 256}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTSN6basisu3vecILj3EfEE", !8, i64 0}
!12 = !{!"_ZTSN6basisu6vectorItEE", !7, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!"_ZTSN6basisu6vectorIjEE", !7, i64 0, !10, i64 8, !10, i64 12}
!14 = !{!"_ZTSN6basisu6vectorIhEE", !7, i64 0, !10, i64 8, !10, i64 12}
!15 = !{!"_ZTSN6basisu14etc1_optimizer18potential_solutionE", !16, i64 0, !14, i64 16, !19, i64 32, !18, i64 40}
!16 = !{!"_ZTSN6basisu25etc1_solution_coordinatesE", !17, i64 0, !10, i64 4, !18, i64 8}
!17 = !{!"_ZTSN6basisu10color_rgbaE", !8, i64 0}
!18 = !{!"bool", !8, i64 0}
!19 = !{!"long", !8, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!6, !10, i64 32}
!23 = !{!6, !10, i64 36}
!24 = !{!8, !8, i64 0}
!25 = !{!6, !10, i64 40}
!26 = !{!6, !7, i64 0}
!27 = !{!28, !18, i64 24}
!28 = !{!"_ZTSN6basisu14etc1_optimizer6paramsE", !29, i64 0, !10, i64 12, !7, i64 16, !18, i64 24, !7, i64 32, !10, i64 40, !17, i64 44, !18, i64 48, !18, i64 49, !7, i64 56}
!29 = !{!"_ZTSN6basisu22basis_etc1_pack_paramsE", !30, i64 0, !18, i64 4, !18, i64 5, !18, i64 6, !18, i64 7, !31, i64 8}
!30 = !{!"_ZTSN6basisu17basis_etc_qualityE", !8, i64 0}
!31 = !{!"float", !8, i64 0}
!32 = !{!6, !19, i64 176}
!33 = !{!6, !10, i64 148}
!34 = !{!10, !10, i64 0}
!35 = !{!31, !31, i64 0}
!36 = !{!6, !10, i64 16}
!37 = distinct !{!37, !38}
!38 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass