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

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

@_ZN6basisu19g_etc1_inten_tablesE = external dso_local constant [8 x [4 x i32]], 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN6basisu6vectorIhEixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu14etc1_optimizer15refine_solutionEj(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 i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %"class.basisu::color_rgba", align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = 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
  %24 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %25 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 4, !tbaa !22
  store i32 %28, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %199, %2
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = icmp ult i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 2, ptr %7, align 4
  br label %202

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %35 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 15
  %36 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %35, i32 0, i32 2
  %37 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN6basisu6vectorIhEixEm(ptr noundef nonnull align 8 dereferenceable(16) %36, i64 noundef 0)
  store ptr %37, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %38 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 15
  %39 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %"struct.basisu::etc1_solution_coordinates", ptr %39, i32 0, i32 1
  %41 = load i32, ptr %40, align 4, !tbaa !27
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds [8 x [4 x i32]], ptr @_ZN6basisu19g_etc1_inten_tablesE, i64 0, i64 %42
  %44 = getelementptr inbounds [4 x i32], ptr %43, i64 0, i64 0
  store ptr %44, ptr %9, align 8, !tbaa !5
  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 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %45 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 15
  %46 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %45, i32 0, i32 0
  %47 = call i32 @_ZNK6basisu25etc1_solution_coordinates16get_scaled_colorEv(ptr noundef nonnull align 4 dereferenceable(9) %46)
  %48 = getelementptr inbounds %"class.basisu::color_rgba", ptr %13, i32 0, i32 0
  %49 = getelementptr inbounds %union.anon, ptr %48, i32 0, i32 0
  store i32 %47, ptr %49, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %107, %34
  %51 = load i32, ptr %14, align 4, !tbaa !9
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = icmp ult i32 %51, %52
  br i1 %53, label %55, label %54

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

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i32 1
  store ptr %57, ptr %8, align 8, !tbaa !5
  %58 = load i8, ptr %56, align 1, !tbaa !28
  %59 = zext i8 %58 to i32
  store i32 %59, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %60 = load ptr, ptr %9, align 8, !tbaa !5
  %61 = load i32, ptr %15, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds i32, ptr %60, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !9
  store i32 %64, ptr %16, align 4, !tbaa !9
  %65 = getelementptr inbounds %"class.basisu::color_rgba", ptr %13, i32 0, i32 0
  %66 = getelementptr inbounds %struct.anon, ptr %65, i32 0, i32 0
  %67 = load i8, ptr %66, align 1, !tbaa !28
  %68 = zext i8 %67 to i32
  %69 = load i32, ptr %16, align 4, !tbaa !9
  %70 = add nsw i32 %68, %69
  %71 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %70, i32 noundef 0, i32 noundef 255)
  %72 = getelementptr inbounds %"class.basisu::color_rgba", ptr %13, i32 0, i32 0
  %73 = getelementptr inbounds %struct.anon, ptr %72, i32 0, i32 0
  %74 = load i8, ptr %73, align 1, !tbaa !28
  %75 = zext i8 %74 to i32
  %76 = sub nsw i32 %71, %75
  %77 = load i32, ptr %10, align 4, !tbaa !9
  %78 = add nsw i32 %77, %76
  store i32 %78, ptr %10, align 4, !tbaa !9
  %79 = getelementptr inbounds %"class.basisu::color_rgba", ptr %13, i32 0, i32 0
  %80 = getelementptr inbounds %struct.anon, ptr %79, i32 0, i32 1
  %81 = load i8, ptr %80, align 1, !tbaa !28
  %82 = zext i8 %81 to i32
  %83 = load i32, ptr %16, align 4, !tbaa !9
  %84 = add nsw i32 %82, %83
  %85 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %84, i32 noundef 0, i32 noundef 255)
  %86 = getelementptr inbounds %"class.basisu::color_rgba", ptr %13, i32 0, i32 0
  %87 = getelementptr inbounds %struct.anon, ptr %86, i32 0, i32 1
  %88 = load i8, ptr %87, align 1, !tbaa !28
  %89 = zext i8 %88 to i32
  %90 = sub nsw i32 %85, %89
  %91 = load i32, ptr %11, align 4, !tbaa !9
  %92 = add nsw i32 %91, %90
  store i32 %92, ptr %11, align 4, !tbaa !9
  %93 = getelementptr inbounds %"class.basisu::color_rgba", ptr %13, i32 0, i32 0
  %94 = getelementptr inbounds %struct.anon, ptr %93, i32 0, i32 2
  %95 = load i8, ptr %94, align 1, !tbaa !28
  %96 = zext i8 %95 to i32
  %97 = load i32, ptr %16, align 4, !tbaa !9
  %98 = add nsw i32 %96, %97
  %99 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %98, i32 noundef 0, i32 noundef 255)
  %100 = getelementptr inbounds %"class.basisu::color_rgba", ptr %13, i32 0, i32 0
  %101 = getelementptr inbounds %struct.anon, ptr %100, i32 0, i32 2
  %102 = load i8, ptr %101, align 1, !tbaa !28
  %103 = zext i8 %102 to i32
  %104 = sub nsw i32 %99, %103
  %105 = load i32, ptr %12, align 4, !tbaa !9
  %106 = add nsw i32 %105, %104
  store i32 %106, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %107

107:                                              ; preds = %55
  %108 = load i32, ptr %14, align 4, !tbaa !9
  %109 = add i32 %108, 1
  store i32 %109, ptr %14, align 4, !tbaa !9
  br label %50, !llvm.loop !29

110:                                              ; preds = %54
  %111 = load i32, ptr %10, align 4, !tbaa !9
  %112 = icmp ne i32 %111, 0
  br i1 %112, label %120, label %113

113:                                              ; preds = %110
  %114 = load i32, ptr %11, align 4, !tbaa !9
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %120, label %116

116:                                              ; preds = %113
  %117 = load i32, ptr %12, align 4, !tbaa !9
  %118 = icmp ne i32 %117, 0
  br i1 %118, label %120, label %119

119:                                              ; preds = %116
  store i32 2, ptr %7, align 4
  br label %196

120:                                              ; preds = %116, %113, %110
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %121 = load i32, ptr %10, align 4, !tbaa !9
  %122 = sitofp i32 %121 to float
  %123 = load i32, ptr %5, align 4, !tbaa !9
  %124 = uitofp i32 %123 to float
  %125 = fdiv float %122, %124
  store float %125, ptr %17, align 4, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %126 = load i32, ptr %11, align 4, !tbaa !9
  %127 = sitofp i32 %126 to float
  %128 = load i32, ptr %5, align 4, !tbaa !9
  %129 = uitofp i32 %128 to float
  %130 = fdiv float %127, %129
  store float %130, ptr %18, align 4, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %131 = load i32, ptr %12, align 4, !tbaa !9
  %132 = sitofp i32 %131 to float
  %133 = load i32, ptr %5, align 4, !tbaa !9
  %134 = uitofp i32 %133 to float
  %135 = fdiv float %132, %134
  store float %135, ptr %19, align 4, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %136 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 3
  %137 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %136, i32 noundef 0)
  %138 = load float, ptr %137, align 4, !tbaa !31
  %139 = load float, ptr %17, align 4, !tbaa !31
  %140 = fsub float %138, %139
  %141 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 2
  %142 = load i32, ptr %141, align 8, !tbaa !32
  %143 = sitofp i32 %142 to float
  %144 = fmul float %140, %143
  %145 = fdiv float %144, 2.550000e+02
  %146 = fadd float %145, 5.000000e-01
  %147 = fptosi float %146 to i32
  %148 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 2
  %149 = load i32, ptr %148, align 8, !tbaa !32
  %150 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %147, i32 noundef 0, i32 noundef %149)
  store i32 %150, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  %151 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 3
  %152 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %151, i32 noundef 1)
  %153 = load float, ptr %152, align 4, !tbaa !31
  %154 = load float, ptr %18, align 4, !tbaa !31
  %155 = fsub float %153, %154
  %156 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 2
  %157 = load i32, ptr %156, align 8, !tbaa !32
  %158 = sitofp i32 %157 to float
  %159 = fmul float %155, %158
  %160 = fdiv float %159, 2.550000e+02
  %161 = fadd float %160, 5.000000e-01
  %162 = fptosi float %161 to i32
  %163 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 2
  %164 = load i32, ptr %163, align 8, !tbaa !32
  %165 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %162, i32 noundef 0, i32 noundef %164)
  store i32 %165, ptr %21, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %166 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 3
  %167 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %166, i32 noundef 2)
  %168 = load float, ptr %167, align 4, !tbaa !31
  %169 = load float, ptr %19, align 4, !tbaa !31
  %170 = fsub float %168, %169
  %171 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 2
  %172 = load i32, ptr %171, align 8, !tbaa !32
  %173 = sitofp i32 %172 to float
  %174 = fmul float %170, %173
  %175 = fdiv float %174, 2.550000e+02
  %176 = fadd float %175, 5.000000e-01
  %177 = fptosi float %176 to i32
  %178 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 2
  %179 = load i32, ptr %178, align 8, !tbaa !32
  %180 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %177, i32 noundef 0, i32 noundef %179)
  store i32 %180, ptr %22, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %23) #4
  %181 = load i32, ptr %20, align 4, !tbaa !9
  %182 = load i32, ptr %21, align 4, !tbaa !9
  %183 = load i32, ptr %22, align 4, !tbaa !9
  %184 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 0
  %185 = load ptr, ptr %184, align 8, !tbaa !11
  %186 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %185, i32 0, i32 3
  %187 = load i8, ptr %186, align 8, !tbaa !33, !range !34, !noundef !35
  %188 = trunc i8 %187 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %23, i32 noundef %181, i32 noundef %182, i32 noundef %183, i32 noundef 0, i1 noundef zeroext %188)
  %189 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 16
  %190 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %24, i32 0, i32 15
  %191 = call noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384) %24, ptr noundef nonnull align 4 dereferenceable(9) %23, ptr noundef nonnull align 8 dereferenceable(41) %189, ptr noundef %190)
  %192 = xor i1 %191, true
  call void @llvm.lifetime.end.p0(i64 12, ptr %23) #4
  br i1 %192, label %193, label %194

193:                                              ; preds = %120
  store i32 2, ptr %7, align 4
  br label %195

194:                                              ; preds = %120
  store i32 0, ptr %7, align 4
  br label %195

195:                                              ; preds = %194, %193
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  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
  br label %196

196:                                              ; preds = %195, %119
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %197 = load i32, ptr %7, align 4
  switch i32 %197, label %202 [
    i32 0, label %198
  ]

198:                                              ; preds = %196
  br label %199

199:                                              ; preds = %198
  %200 = load i32, ptr %6, align 4, !tbaa !9
  %201 = add i32 %200, 1
  store i32 %201, ptr %6, align 4, !tbaa !9
  br label %29, !llvm.loop !36

202:                                              ; preds = %196, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %203

203:                                              ; preds = %202
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  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, !6, i64 0}
!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 = !{!23, !10, i64 12}
!23 = !{!"_ZTSN6basisu14etc1_optimizer6paramsE", !24, 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}
!24 = !{!"_ZTSN6basisu22basis_etc1_pack_paramsE", !25, i64 0, !20, i64 4, !20, i64 5, !20, i64 6, !20, i64 7, !26, i64 8}
!25 = !{!"_ZTSN6basisu17basis_etc_qualityE", !7, i64 0}
!26 = !{!"float", !7, i64 0}
!27 = !{!12, !10, i64 148}
!28 = !{!7, !7, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!26, !26, i64 0}
!32 = !{!12, !10, i64 16}
!33 = !{!23, !20, i64 24}
!34 = !{i8 0, i8 2}
!35 = !{}
!36 = distinct !{!36, !30}


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

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZN6basisu6vectorIhEixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu14etc1_optimizer15refine_solutionEj(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 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 12
  %6 = load i32, ptr %5, align 4, !tbaa !20
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %.thread, label %.lr.ph57

.lr.ph57:                                         ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  %8 = getelementptr inbounds i8, ptr %0, i64 160
  %9 = getelementptr inbounds i8, ptr %0, i64 148
  %.not60 = icmp eq i32 %6, 0
  %10 = uitofp i32 %6 to float
  %11 = getelementptr inbounds i8, ptr %0, i64 20
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = getelementptr inbounds i8, ptr %0, i64 192
  br label %14

14:                                               ; preds = %45, %.lr.ph57
  %.055 = phi i32 [ 0, %.lr.ph57 ], [ %87, %45 ]
  %15 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZN6basisu6vectorIhEixEm(ptr noundef nonnull align 8 dereferenceable(16) %8, i64 noundef 0)
  %16 = load i32, ptr %9, align 4, !tbaa !25
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds [8 x [4 x i32]], ptr @_ZN6basisu19g_etc1_inten_tablesE, i64 0, i64 %17
  %19 = call i32 @_ZNK6basisu25etc1_solution_coordinates16get_scaled_colorEv(ptr noundef nonnull align 4 dereferenceable(9) %7)
  br i1 %.not60, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %14
  %.sroa.7.0.extract.shift = lshr i32 %19, 16
  %.sroa.5.0.extract.shift = lshr i32 %19, 8
  %20 = and i32 %19, 255
  %21 = and i32 %.sroa.5.0.extract.shift, 255
  %22 = and i32 %.sroa.7.0.extract.shift, 255
  br label %26

._crit_edge:                                      ; preds = %26, %14
  %.041.lcssa = phi i32 [ 0, %14 ], [ %43, %26 ]
  %.040.lcssa = phi i32 [ 0, %14 ], [ %39, %26 ]
  %.039.lcssa = phi i32 [ 0, %14 ], [ %35, %26 ]
  %23 = icmp ne i32 %.039.lcssa, 0
  %24 = icmp ne i32 %.040.lcssa, 0
  %or.cond = select i1 %23, i1 true, i1 %24
  %25 = icmp ne i32 %.041.lcssa, 0
  %or.cond3 = select i1 %or.cond, i1 true, i1 %25
  br i1 %or.cond3, label %45, label %.thread

26:                                               ; preds = %.lr.ph, %26
  %.03852 = phi ptr [ %15, %.lr.ph ], [ %27, %26 ]
  %.03951 = phi i32 [ 0, %.lr.ph ], [ %35, %26 ]
  %.04050 = phi i32 [ 0, %.lr.ph ], [ %39, %26 ]
  %.04149 = phi i32 [ 0, %.lr.ph ], [ %43, %26 ]
  %.04248 = phi i32 [ 0, %.lr.ph ], [ %44, %26 ]
  %27 = getelementptr inbounds i8, ptr %.03852, i64 1
  %28 = load i8, ptr %.03852, align 1, !tbaa !26
  %29 = zext i8 %28 to i64
  %30 = getelementptr inbounds i32, ptr %18, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !27
  %32 = add nsw i32 %31, %20
  %33 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %32, i32 noundef 0, i32 noundef 255)
  %34 = sub i32 %.03951, %20
  %35 = add i32 %34, %33
  %36 = add nsw i32 %31, %21
  %37 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %36, i32 noundef 0, i32 noundef 255)
  %38 = sub i32 %.04050, %21
  %39 = add i32 %38, %37
  %40 = add nsw i32 %31, %22
  %41 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %40, i32 noundef 0, i32 noundef 255)
  %42 = sub i32 %.04149, %22
  %43 = add i32 %42, %41
  %44 = add nuw i32 %.04248, 1
  %exitcond.not = icmp eq i32 %44, %6
  br i1 %exitcond.not, label %._crit_edge, label %26, !llvm.loop !28

45:                                               ; preds = %._crit_edge
  %46 = sitofp i32 %.039.lcssa to float
  %47 = fdiv float %46, %10
  %48 = sitofp i32 %.040.lcssa to float
  %49 = fdiv float %48, %10
  %50 = sitofp i32 %.041.lcssa to float
  %51 = fdiv float %50, %10
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %11, i32 noundef 0)
  %53 = load float, ptr %52, align 4, !tbaa !30
  %54 = fsub float %53, %47
  %55 = load i32, ptr %12, align 8, !tbaa !31
  %56 = sitofp i32 %55 to float
  %57 = fmul float %54, %56
  %58 = fdiv float %57, 2.550000e+02
  %59 = fadd float %58, 5.000000e-01
  %60 = fptosi float %59 to i32
  %61 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %60, i32 noundef 0, i32 noundef %55)
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %11, i32 noundef 1)
  %63 = load float, ptr %62, align 4, !tbaa !30
  %64 = fsub float %63, %49
  %65 = load i32, ptr %12, align 8, !tbaa !31
  %66 = sitofp i32 %65 to float
  %67 = fmul float %64, %66
  %68 = fdiv float %67, 2.550000e+02
  %69 = fadd float %68, 5.000000e-01
  %70 = fptosi float %69 to i32
  %71 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %70, i32 noundef 0, i32 noundef %65)
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu3vecILj3EfEixEj(ptr noundef nonnull align 4 dereferenceable(12) %11, i32 noundef 2)
  %73 = load float, ptr %72, align 4, !tbaa !30
  %74 = fsub float %73, %51
  %75 = load i32, ptr %12, align 8, !tbaa !31
  %76 = sitofp i32 %75 to float
  %77 = fmul float %74, %76
  %78 = fdiv float %77, 2.550000e+02
  %79 = fadd float %78, 5.000000e-01
  %80 = fptosi float %79 to i32
  %81 = call noundef i32 @_ZN6basisu5clampIiEET_S1_S1_S1_(i32 noundef %80, i32 noundef 0, i32 noundef %75)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  %82 = load ptr, ptr %0, align 8, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %82, i64 24
  %84 = load i8, ptr %83, align 8, !tbaa !32, !range !33, !noundef !34
  %85 = trunc nuw i8 %84 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %3, i32 noundef %61, i32 noundef %71, i32 noundef %81, i32 noundef 0, i1 noundef zeroext %85)
  %86 = 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) %13, ptr noundef nonnull %7)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  %87 = add nuw i32 %.055, 1
  %exitcond63.not = icmp ne i32 %87, %1
  %or.cond67.not = select i1 %86, i1 %exitcond63.not, i1 false
  br i1 %or.cond67.not, label %14, label %.thread, !llvm.loop !35

.thread:                                          ; preds = %45, %._crit_edge, %2
  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, !7, i64 0}
!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 = !{!21, !10, i64 12}
!21 = !{!"_ZTSN6basisu14etc1_optimizer6paramsE", !22, 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}
!22 = !{!"_ZTSN6basisu22basis_etc1_pack_paramsE", !23, i64 0, !18, i64 4, !18, i64 5, !18, i64 6, !18, i64 7, !24, i64 8}
!23 = !{!"_ZTSN6basisu17basis_etc_qualityE", !8, i64 0}
!24 = !{!"float", !8, i64 0}
!25 = !{!6, !10, i64 148}
!26 = !{!8, !8, i64 0}
!27 = !{!10, !10, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!24, !24, i64 0}
!31 = !{!6, !10, i64 16}
!32 = !{!21, !18, i64 24}
!33 = !{i8 0, i8 2}
!34 = !{}
!35 = distinct !{!35, !29}


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