; LLVM IR from KonajuGames/libsquish :: colourset.ll (ZN6squish9ColourSetC2EPKfii)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.squish::Vec3" = type { float, float, float }
%"class.squish::ColourSet" = type <{ i32, [16 x %"class.squish::Vec3"], [16 x float], [16 x i32], i8, [3 x i8] }>

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6squish9ColourSetC2EPKfii(ptr noundef nonnull align 4 dereferenceable(325) %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca %"class.squish::Vec3", align 4
  %20 = alloca i32, align 4
  %21 = alloca i8, align 1
  %22 = alloca i32, align 4
  %23 = alloca float, align 4
  %24 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %25 = load ptr, ptr %5, align 8
  %26 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 0
  store i32 0, ptr %26, align 4, !tbaa !11
  %27 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 1
  %28 = getelementptr inbounds [16 x %"class.squish::Vec3"], ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %"class.squish::Vec3", ptr %28, i64 16
  br label %30

30:                                               ; preds = %30, %4
  %31 = phi ptr [ %28, %4 ], [ %32, %30 ]
  call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %31)
  %32 = getelementptr inbounds %"class.squish::Vec3", ptr %31, i64 1
  %33 = icmp eq ptr %32, %29
  br i1 %33, label %34, label %30

34:                                               ; preds = %30
  %35 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 4
  store i8 0, ptr %35, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = and i32 %36, 1
  %38 = icmp ne i32 %37, 0
  %39 = zext i1 %38 to i8
  store i8 %39, ptr %9, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #5
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = and i32 %40, 128
  %42 = icmp ne i32 %41, 0
  %43 = zext i1 %42 to i8
  store i8 %43, ptr %10, align 1, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %265, %34
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = icmp slt i32 %45, 16
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %268

48:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %49 = load i32, ptr %11, align 4, !tbaa !9
  %50 = shl i32 1, %49
  store i32 %50, ptr %13, align 4, !tbaa !9
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = and i32 %51, %52
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %55, label %60

55:                                               ; preds = %48
  %56 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 3
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [16 x i32], ptr %56, i64 0, i64 %58
  store i32 -1, ptr %59, align 4, !tbaa !9
  store i32 4, ptr %12, align 4
  br label %262

60:                                               ; preds = %48
  %61 = load i8, ptr %9, align 1, !tbaa !15, !range !16, !noundef !17
  %62 = trunc i8 %61 to i1
  br i1 %62, label %63, label %78

63:                                               ; preds = %60
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load i32, ptr %11, align 4, !tbaa !9
  %66 = mul nsw i32 4, %65
  %67 = add nsw i32 %66, 3
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %64, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !18
  %71 = fcmp olt float %70, 5.000000e-01
  br i1 %71, label %72, label %78

72:                                               ; preds = %63
  %73 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 3
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [16 x i32], ptr %73, i64 0, i64 %75
  store i32 -1, ptr %76, align 4, !tbaa !9
  %77 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 4
  store i8 1, ptr %77, align 4, !tbaa !14
  store i32 4, ptr %12, align 4
  br label %262

78:                                               ; preds = %63, %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %257, %78
  %80 = load i32, ptr %14, align 4, !tbaa !9
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = icmp eq i32 %80, %81
  br i1 %82, label %83, label %145

83:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load i32, ptr %11, align 4, !tbaa !9
  %86 = mul nsw i32 4, %85
  %87 = add nsw i32 %86, 0
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %84, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !18
  store float %90, ptr %15, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load i32, ptr %11, align 4, !tbaa !9
  %93 = mul nsw i32 4, %92
  %94 = add nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds float, ptr %91, i64 %95
  %97 = load float, ptr %96, align 4, !tbaa !18
  store float %97, ptr %16, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = load i32, ptr %11, align 4, !tbaa !9
  %100 = mul nsw i32 4, %99
  %101 = add nsw i32 %100, 2
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds float, ptr %98, i64 %102
  %104 = load float, ptr %103, align 4, !tbaa !18
  store float %104, ptr %17, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  %106 = load i32, ptr %11, align 4, !tbaa !9
  %107 = mul nsw i32 4, %106
  %108 = add nsw i32 %107, 3
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds float, ptr %105, i64 %109
  %111 = load float, ptr %110, align 4, !tbaa !18
  store float %111, ptr %18, align 4, !tbaa !18
  %112 = load float, ptr %18, align 4, !tbaa !18
  %113 = fcmp oeq float %112, 0.000000e+00
  br i1 %113, label %114, label %115

114:                                              ; preds = %83
  store float 3.906250e-03, ptr %18, align 4, !tbaa !18
  br label %115

115:                                              ; preds = %114, %83
  call void @llvm.lifetime.start.p0(i64 12, ptr %19) #5
  %116 = load float, ptr %17, align 4, !tbaa !18
  %117 = load float, ptr %16, align 4, !tbaa !18
  %118 = load float, ptr %15, align 4, !tbaa !18
  call void @_ZN6squish4Vec3C2Efff(ptr noundef nonnull align 4 dereferenceable(12) %19, float noundef %116, float noundef %117, float noundef %118)
  %119 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 1
  %120 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 0
  %121 = load i32, ptr %120, align 4, !tbaa !11
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [16 x %"class.squish::Vec3"], ptr %119, i64 0, i64 %122
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %123, ptr align 4 %19, i64 12, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.end.p0(i64 12, ptr %19) #5
  %124 = load i8, ptr %10, align 1, !tbaa !15, !range !16, !noundef !17
  %125 = trunc i8 %124 to i1
  br i1 %125, label %126, label %128

126:                                              ; preds = %115
  %127 = load float, ptr %18, align 4, !tbaa !18
  br label %129

128:                                              ; preds = %115
  br label %129

129:                                              ; preds = %128, %126
  %130 = phi float [ %127, %126 ], [ 1.000000e+00, %128 ]
  %131 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 2
  %132 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 0
  %133 = load i32, ptr %132, align 4, !tbaa !11
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [16 x float], ptr %131, i64 0, i64 %134
  store float %130, ptr %135, align 4, !tbaa !18
  %136 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 0
  %137 = load i32, ptr %136, align 4, !tbaa !11
  %138 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 3
  %139 = load i32, ptr %11, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [16 x i32], ptr %138, i64 0, i64 %140
  store i32 %137, ptr %141, align 4, !tbaa !9
  %142 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 0
  %143 = load i32, ptr %142, align 4, !tbaa !11
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %142, align 4, !tbaa !11
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %260

145:                                              ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %146 = load i32, ptr %14, align 4, !tbaa !9
  %147 = shl i32 1, %146
  store i32 %147, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %21) #5
  %148 = load i32, ptr %7, align 4, !tbaa !9
  %149 = load i32, ptr %20, align 4, !tbaa !9
  %150 = and i32 %148, %149
  %151 = icmp ne i32 %150, 0
  br i1 %151, label %152, label %213

152:                                              ; preds = %145
  %153 = load ptr, ptr %6, align 8, !tbaa !5
  %154 = load i32, ptr %11, align 4, !tbaa !9
  %155 = mul nsw i32 4, %154
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds float, ptr %153, i64 %156
  %158 = load float, ptr %157, align 4, !tbaa !18
  %159 = load ptr, ptr %6, align 8, !tbaa !5
  %160 = load i32, ptr %14, align 4, !tbaa !9
  %161 = mul nsw i32 4, %160
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds float, ptr %159, i64 %162
  %164 = load float, ptr %163, align 4, !tbaa !18
  %165 = fcmp oeq float %158, %164
  br i1 %165, label %166, label %213

166:                                              ; preds = %152
  %167 = load ptr, ptr %6, align 8, !tbaa !5
  %168 = load i32, ptr %11, align 4, !tbaa !9
  %169 = mul nsw i32 4, %168
  %170 = add nsw i32 %169, 1
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds float, ptr %167, i64 %171
  %173 = load float, ptr %172, align 4, !tbaa !18
  %174 = load ptr, ptr %6, align 8, !tbaa !5
  %175 = load i32, ptr %14, align 4, !tbaa !9
  %176 = mul nsw i32 4, %175
  %177 = add nsw i32 %176, 1
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds float, ptr %174, i64 %178
  %180 = load float, ptr %179, align 4, !tbaa !18
  %181 = fcmp oeq float %173, %180
  br i1 %181, label %182, label %213

182:                                              ; preds = %166
  %183 = load ptr, ptr %6, align 8, !tbaa !5
  %184 = load i32, ptr %11, align 4, !tbaa !9
  %185 = mul nsw i32 4, %184
  %186 = add nsw i32 %185, 2
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds float, ptr %183, i64 %187
  %189 = load float, ptr %188, align 4, !tbaa !18
  %190 = load ptr, ptr %6, align 8, !tbaa !5
  %191 = load i32, ptr %14, align 4, !tbaa !9
  %192 = mul nsw i32 4, %191
  %193 = add nsw i32 %192, 2
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds float, ptr %190, i64 %194
  %196 = load float, ptr %195, align 4, !tbaa !18
  %197 = fcmp oeq float %189, %196
  br i1 %197, label %198, label %213

198:                                              ; preds = %182
  %199 = load ptr, ptr %6, align 8, !tbaa !5
  %200 = load i32, ptr %14, align 4, !tbaa !9
  %201 = mul nsw i32 4, %200
  %202 = add nsw i32 %201, 3
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds float, ptr %199, i64 %203
  %205 = load float, ptr %204, align 4, !tbaa !18
  %206 = fcmp oge float %205, 5.000000e-01
  br i1 %206, label %211, label %207

207:                                              ; preds = %198
  %208 = load i8, ptr %9, align 1, !tbaa !15, !range !16, !noundef !17
  %209 = trunc i8 %208 to i1
  %210 = xor i1 %209, true
  br label %211

211:                                              ; preds = %207, %198
  %212 = phi i1 [ true, %198 ], [ %210, %207 ]
  br label %213

213:                                              ; preds = %211, %182, %166, %152, %145
  %214 = phi i1 [ false, %182 ], [ false, %166 ], [ false, %152 ], [ false, %145 ], [ %212, %211 ]
  %215 = zext i1 %214 to i8
  store i8 %215, ptr %21, align 1, !tbaa !15
  %216 = load i8, ptr %21, align 1, !tbaa !15, !range !16, !noundef !17
  %217 = trunc i8 %216 to i1
  br i1 %217, label %218, label %253

218:                                              ; preds = %213
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  %219 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 3
  %220 = load i32, ptr %14, align 4, !tbaa !9
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [16 x i32], ptr %219, i64 0, i64 %221
  %223 = load i32, ptr %222, align 4, !tbaa !9
  store i32 %223, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #5
  %224 = load ptr, ptr %6, align 8, !tbaa !5
  %225 = load i32, ptr %11, align 4, !tbaa !9
  %226 = mul nsw i32 4, %225
  %227 = add nsw i32 %226, 3
  %228 = sext i32 %227 to i64
  %229 = getelementptr inbounds float, ptr %224, i64 %228
  %230 = load float, ptr %229, align 4, !tbaa !18
  store float %230, ptr %23, align 4, !tbaa !18
  %231 = load float, ptr %23, align 4, !tbaa !18
  %232 = fcmp oeq float %231, 0.000000e+00
  br i1 %232, label %233, label %234

233:                                              ; preds = %218
  store float 3.906250e-03, ptr %23, align 4, !tbaa !18
  br label %234

234:                                              ; preds = %233, %218
  %235 = load i8, ptr %10, align 1, !tbaa !15, !range !16, !noundef !17
  %236 = trunc i8 %235 to i1
  br i1 %236, label %237, label %239

237:                                              ; preds = %234
  %238 = load float, ptr %23, align 4, !tbaa !18
  br label %240

239:                                              ; preds = %234
  br label %240

240:                                              ; preds = %239, %237
  %241 = phi float [ %238, %237 ], [ 1.000000e+00, %239 ]
  %242 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 2
  %243 = load i32, ptr %22, align 4, !tbaa !9
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [16 x float], ptr %242, i64 0, i64 %244
  %246 = load float, ptr %245, align 4, !tbaa !18
  %247 = fadd float %246, %241
  store float %247, ptr %245, align 4, !tbaa !18
  %248 = load i32, ptr %22, align 4, !tbaa !9
  %249 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 3
  %250 = load i32, ptr %11, align 4, !tbaa !9
  %251 = sext i32 %250 to i64
  %252 = getelementptr inbounds [16 x i32], ptr %249, i64 0, i64 %251
  store i32 %248, ptr %252, align 4, !tbaa !9
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  br label %254

253:                                              ; preds = %213
  store i32 0, ptr %12, align 4
  br label %254

254:                                              ; preds = %253, %240
  call void @llvm.lifetime.end.p0(i64 1, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  %255 = load i32, ptr %12, align 4
  switch i32 %255, label %260 [
    i32 0, label %256
  ]

256:                                              ; preds = %254
  br label %257

257:                                              ; preds = %256
  %258 = load i32, ptr %14, align 4, !tbaa !9
  %259 = add nsw i32 %258, 1
  store i32 %259, ptr %14, align 4, !tbaa !9
  br label %79, !llvm.loop !21

260:                                              ; preds = %254, %129
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %261

261:                                              ; preds = %260
  store i32 0, ptr %12, align 4
  br label %262

262:                                              ; preds = %261, %72, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %263 = load i32, ptr %12, align 4
  switch i32 %263, label %290 [
    i32 0, label %264
    i32 4, label %265
  ]

264:                                              ; preds = %262
  br label %265

265:                                              ; preds = %264, %262
  %266 = load i32, ptr %11, align 4, !tbaa !9
  %267 = add nsw i32 %266, 1
  store i32 %267, ptr %11, align 4, !tbaa !9
  br label %44, !llvm.loop !23

268:                                              ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #5
  store i32 0, ptr %24, align 4, !tbaa !9
  br label %269

269:                                              ; preds = %286, %268
  %270 = load i32, ptr %24, align 4, !tbaa !9
  %271 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 0
  %272 = load i32, ptr %271, align 4, !tbaa !11
  %273 = icmp slt i32 %270, %272
  br i1 %273, label %275, label %274

274:                                              ; preds = %269
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #5
  br label %289

275:                                              ; preds = %269
  %276 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 2
  %277 = load i32, ptr %24, align 4, !tbaa !9
  %278 = sext i32 %277 to i64
  %279 = getelementptr inbounds [16 x float], ptr %276, i64 0, i64 %278
  %280 = load float, ptr %279, align 4, !tbaa !18
  %281 = call noundef float @_ZSt4sqrtf(float noundef %280)
  %282 = getelementptr inbounds %"class.squish::ColourSet", ptr %25, i32 0, i32 2
  %283 = load i32, ptr %24, align 4, !tbaa !9
  %284 = sext i32 %283 to i64
  %285 = getelementptr inbounds [16 x float], ptr %282, i64 0, i64 %284
  store float %281, ptr %285, align 4, !tbaa !18
  br label %286

286:                                              ; preds = %275
  %287 = load i32, ptr %24, align 4, !tbaa !9
  %288 = add nsw i32 %287, 1
  store i32 %288, ptr %24, align 4, !tbaa !9
  br label %269, !llvm.loop !24

289:                                              ; preds = %274
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  ret void

290:                                              ; preds = %262
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6squish4Vec3C2Efff(ptr noundef nonnull align 4 dereferenceable(12), float noundef, float noundef, float noundef) unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) #4

attributes #0 = { 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 #1 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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, !10, i64 0}
!12 = !{!"_ZTSN6squish9ColourSetE", !10, i64 0, !7, i64 4, !7, i64 196, !7, i64 260, !13, i64 324}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !13, i64 324}
!15 = !{!13, !13, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !7, i64 0}
!20 = !{i64 0, i64 4, !18, i64 4, i64 4, !18, i64 8, i64 4, !18}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = distinct !{!24, !22}


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

%"class.squish::Vec3" = type { float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6squish9ColourSetC2EPKfii(ptr noundef nonnull align 4 dereferenceable(325) %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3) unnamed_addr #0 align 2 {
  %5 = alloca %"class.squish::Vec3", align 4
  store i32 0, ptr %0, align 4, !tbaa !5
  %.ptr = getelementptr inbounds i8, ptr %0, i64 4
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr)
  %.ptr.1 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %0, i64 28
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %.ptr.3 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.3)
  %.ptr.4 = getelementptr inbounds i8, ptr %0, i64 52
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.4)
  %.ptr.5 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.5)
  %.ptr.6 = getelementptr inbounds i8, ptr %0, i64 76
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.6)
  %.ptr.7 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.7)
  %.ptr.8 = getelementptr inbounds i8, ptr %0, i64 100
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.8)
  %.ptr.9 = getelementptr inbounds i8, ptr %0, i64 112
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.9)
  %.ptr.10 = getelementptr inbounds i8, ptr %0, i64 124
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.10)
  %.ptr.11 = getelementptr inbounds i8, ptr %0, i64 136
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.11)
  %.ptr.12 = getelementptr inbounds i8, ptr %0, i64 148
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.12)
  %.ptr.13 = getelementptr inbounds i8, ptr %0, i64 160
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.13)
  %.ptr.14 = getelementptr inbounds i8, ptr %0, i64 172
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.14)
  %.ptr.15 = getelementptr inbounds i8, ptr %0, i64 184
  tail call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.15)
  %6 = getelementptr inbounds i8, ptr %0, i64 324
  store i8 0, ptr %6, align 4, !tbaa !11
  %7 = and i32 %3, 1
  %.not = icmp eq i32 %7, 0
  %8 = and i32 %3, 128
  %.not72 = icmp eq i32 %8, 0
  %9 = getelementptr inbounds i8, ptr %0, i64 260
  %10 = getelementptr inbounds i8, ptr %0, i64 196
  br label %13

.preheader:                                       ; preds = %126
  %11 = load i32, ptr %0, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph83, label %._crit_edge84

13:                                               ; preds = %4, %126
  %indvars.iv93 = phi i64 [ 0, %4 ], [ %indvars.iv.next94, %126 ]
  %14 = trunc nuw nsw i64 %indvars.iv93 to i32
  %15 = shl nuw nsw i32 1, %14
  %16 = and i32 %15, %2
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %20

18:                                               ; preds = %13
  %19 = getelementptr inbounds [16 x i32], ptr %9, i64 0, i64 %indvars.iv93
  store i32 -1, ptr %19, align 4, !tbaa !12
  br label %126

20:                                               ; preds = %13
  br i1 %.not, label %29, label %21

21:                                               ; preds = %20
  %22 = shl nuw nsw i64 %indvars.iv93, 2
  %23 = or disjoint i64 %22, 3
  %24 = getelementptr inbounds float, ptr %1, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !13
  %26 = fcmp olt float %25, 5.000000e-01
  br i1 %26, label %27, label %.thread

27:                                               ; preds = %21
  %28 = getelementptr inbounds [16 x i32], ptr %9, i64 0, i64 %indvars.iv93
  store i32 -1, ptr %28, align 4, !tbaa !12
  store i8 1, ptr %6, align 4, !tbaa !11
  br label %126

29:                                               ; preds = %20
  %30 = icmp eq i64 %indvars.iv93, 0
  br i1 %30, label %._crit_edge, label %.lr.ph.split.us.preheader

.thread:                                          ; preds = %21
  %31 = icmp eq i64 %indvars.iv93, 0
  br i1 %31, label %._crit_edge, label %.lr.ph.split.preheader

.lr.ph.split.preheader:                           ; preds = %.thread
  %32 = shl nuw nsw i64 %indvars.iv93, 2
  %33 = getelementptr inbounds float, ptr %1, i64 %32
  %34 = or disjoint i64 %32, 1
  %35 = getelementptr inbounds float, ptr %1, i64 %34
  %36 = or disjoint i64 %32, 2
  %37 = getelementptr inbounds float, ptr %1, i64 %36
  br label %.lr.ph.split

.lr.ph.split.us.preheader:                        ; preds = %29
  %38 = shl nuw nsw i64 %indvars.iv93, 2
  %39 = getelementptr inbounds float, ptr %1, i64 %38
  %40 = or disjoint i64 %38, 1
  %41 = getelementptr inbounds float, ptr %1, i64 %40
  %42 = or disjoint i64 %38, 2
  %43 = getelementptr inbounds float, ptr %1, i64 %42
  br label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph.split.us.preheader, %.critedge.us
  %indvars.iv90 = phi i64 [ 0, %.lr.ph.split.us.preheader ], [ %indvars.iv.next91, %.critedge.us ]
  %44 = trunc nuw nsw i64 %indvars.iv90 to i32
  %45 = shl nuw i32 1, %44
  %46 = and i32 %45, %2
  %.not73.us = icmp eq i32 %46, 0
  br i1 %.not73.us, label %.critedge.us, label %47

47:                                               ; preds = %.lr.ph.split.us
  %48 = load float, ptr %39, align 4, !tbaa !13
  %49 = shl nsw i64 %indvars.iv90, 2
  %50 = getelementptr inbounds float, ptr %1, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !13
  %52 = fcmp oeq float %48, %51
  br i1 %52, label %53, label %.critedge.us

53:                                               ; preds = %47
  %54 = load float, ptr %41, align 4, !tbaa !13
  %55 = or disjoint i64 %49, 1
  %56 = getelementptr inbounds float, ptr %1, i64 %55
  %57 = load float, ptr %56, align 4, !tbaa !13
  %58 = fcmp oeq float %54, %57
  br i1 %58, label %59, label %.critedge.us

59:                                               ; preds = %53
  %60 = load float, ptr %43, align 4, !tbaa !13
  %61 = or disjoint i64 %49, 2
  %62 = getelementptr inbounds float, ptr %1, i64 %61
  %63 = load float, ptr %62, align 4, !tbaa !13
  %64 = fcmp oeq float %60, %63
  br i1 %64, label %.split.us, label %.critedge.us

.critedge.us:                                     ; preds = %59, %53, %47, %.lr.ph.split.us
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %65 = icmp eq i64 %indvars.iv.next91, %indvars.iv93
  br i1 %65, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !15

._crit_edge:                                      ; preds = %.critedge, %.critedge.us, %.thread, %29
  %.pre-phi102 = phi i64 [ 2, %29 ], [ 2, %.thread ], [ %42, %.critedge.us ], [ %36, %.critedge ]
  %.pre-phi100 = phi i64 [ 1, %29 ], [ 1, %.thread ], [ %40, %.critedge.us ], [ %34, %.critedge ]
  %.pre-phi = phi i64 [ 0, %29 ], [ 0, %.thread ], [ %38, %.critedge.us ], [ %32, %.critedge ]
  %66 = getelementptr inbounds float, ptr %1, i64 %.pre-phi
  %67 = load float, ptr %66, align 4, !tbaa !13
  %68 = getelementptr inbounds float, ptr %1, i64 %.pre-phi100
  %69 = load float, ptr %68, align 4, !tbaa !13
  %70 = getelementptr inbounds float, ptr %1, i64 %.pre-phi102
  %71 = load float, ptr %70, align 4, !tbaa !13
  %72 = or disjoint i64 %.pre-phi, 3
  %73 = getelementptr inbounds float, ptr %1, i64 %72
  %74 = load float, ptr %73, align 4, !tbaa !13
  %75 = fcmp oeq float %74, 0.000000e+00
  %.067 = select i1 %75, float 3.906250e-03, float %74
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  call void @_ZN6squish4Vec3C2Efff(ptr noundef nonnull align 4 dereferenceable(12) %5, float noundef %71, float noundef %69, float noundef %67)
  %76 = load i32, ptr %0, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [16 x %"class.squish::Vec3"], ptr %.ptr, i64 0, i64 %77
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %78, ptr noundef nonnull align 4 dereferenceable(12) %5, i64 12, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  %79 = select i1 %.not72, float 1.000000e+00, float %.067
  %80 = load i32, ptr %0, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [16 x float], ptr %10, i64 0, i64 %81
  store float %79, ptr %82, align 4, !tbaa !13
  %83 = getelementptr inbounds [16 x i32], ptr %9, i64 0, i64 %indvars.iv93
  store i32 %80, ptr %83, align 4, !tbaa !12
  %84 = add nsw i32 %80, 1
  store i32 %84, ptr %0, align 4, !tbaa !5
  br label %126

.lr.ph.split:                                     ; preds = %.lr.ph.split.preheader, %.critedge
  %indvars.iv = phi i64 [ 0, %.lr.ph.split.preheader ], [ %indvars.iv.next, %.critedge ]
  %85 = trunc nuw nsw i64 %indvars.iv to i32
  %86 = shl nuw i32 1, %85
  %87 = and i32 %86, %2
  %.not73 = icmp eq i32 %87, 0
  br i1 %.not73, label %.critedge, label %88

88:                                               ; preds = %.lr.ph.split
  %89 = load float, ptr %33, align 4, !tbaa !13
  %90 = shl nsw i64 %indvars.iv, 2
  %91 = getelementptr inbounds float, ptr %1, i64 %90
  %92 = load float, ptr %91, align 4, !tbaa !13
  %93 = fcmp oeq float %89, %92
  br i1 %93, label %94, label %.critedge

94:                                               ; preds = %88
  %95 = load float, ptr %35, align 4, !tbaa !13
  %96 = or disjoint i64 %90, 1
  %97 = getelementptr inbounds float, ptr %1, i64 %96
  %98 = load float, ptr %97, align 4, !tbaa !13
  %99 = fcmp oeq float %95, %98
  br i1 %99, label %100, label %.critedge

100:                                              ; preds = %94
  %101 = load float, ptr %37, align 4, !tbaa !13
  %102 = or disjoint i64 %90, 2
  %103 = getelementptr inbounds float, ptr %1, i64 %102
  %104 = load float, ptr %103, align 4, !tbaa !13
  %105 = fcmp oeq float %101, %104
  br i1 %105, label %106, label %.critedge

106:                                              ; preds = %100
  %107 = or disjoint i64 %90, 3
  %108 = getelementptr inbounds float, ptr %1, i64 %107
  %109 = load float, ptr %108, align 4, !tbaa !13
  %110 = fcmp ult float %109, 5.000000e-01
  br i1 %110, label %.critedge, label %.split.us

.split.us:                                        ; preds = %106, %59
  %111 = phi i64 [ %38, %59 ], [ %32, %106 ]
  %.us-phi77 = phi i64 [ %indvars.iv90, %59 ], [ %indvars.iv, %106 ]
  %112 = and i64 %.us-phi77, 4294967295
  %113 = getelementptr inbounds [16 x i32], ptr %9, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !12
  %115 = or disjoint i64 %111, 3
  %116 = getelementptr inbounds float, ptr %1, i64 %115
  %117 = load float, ptr %116, align 4, !tbaa !13
  %118 = fcmp oeq float %117, 0.000000e+00
  %.063 = select i1 %118, float 3.906250e-03, float %117
  %119 = select i1 %.not72, float 1.000000e+00, float %.063
  %120 = sext i32 %114 to i64
  %121 = getelementptr inbounds [16 x float], ptr %10, i64 0, i64 %120
  %122 = load float, ptr %121, align 4, !tbaa !13
  %123 = fadd float %122, %119
  store float %123, ptr %121, align 4, !tbaa !13
  %124 = getelementptr inbounds [16 x i32], ptr %9, i64 0, i64 %indvars.iv93
  store i32 %114, ptr %124, align 4, !tbaa !12
  br label %126

.critedge:                                        ; preds = %100, %94, %88, %.lr.ph.split, %106
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %125 = icmp eq i64 %indvars.iv.next, %indvars.iv93
  br i1 %125, label %._crit_edge, label %.lr.ph.split, !llvm.loop !15

126:                                              ; preds = %.split.us, %._crit_edge, %27, %18
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next94, 16
  br i1 %exitcond.not, label %.preheader, label %13, !llvm.loop !18

._crit_edge84:                                    ; preds = %.lr.ph83, %.preheader
  ret void

.lr.ph83:                                         ; preds = %.preheader, %.lr.ph83
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %.lr.ph83 ], [ 0, %.preheader ]
  %127 = getelementptr inbounds [16 x float], ptr %10, i64 0, i64 %indvars.iv96
  %128 = load float, ptr %127, align 4, !tbaa !13
  %129 = call noundef float @_ZSt4sqrtf(float noundef %128)
  store float %129, ptr %127, align 4, !tbaa !13
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %130 = load i32, ptr %0, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = icmp slt i64 %indvars.iv.next97, %131
  br i1 %132, label %.lr.ph83, label %._crit_edge84, !llvm.loop !19
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #0 align 2

; 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 nounwind uwtable
declare dso_local void @_ZN6squish4Vec3C2Efff(ptr noundef nonnull align 4 dereferenceable(12), float noundef, float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) local_unnamed_addr #3

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTSN6squish9ColourSetE", !7, i64 0, !8, i64 4, !8, i64 196, !8, i64 260, !10, i64 324}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!6, !10, i64 324}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i64 0, i64 4, !13, i64 4, i64 4, !13, i64 8, i64 4, !13}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}


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