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

; 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: mustprogress uwtable
define dso_local void @_ZN6basisu14etc1_optimizer29compute_internal_neighborhoodEiii(ptr noundef nonnull align 8 dereferenceable(384) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 align 2 {
  %5 = alloca ptr, align 8
  %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 i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca %"struct.basisu::etc1_solution_coordinates", align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8
  %22 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 15
  %23 = getelementptr inbounds %"struct.basisu::etc1_optimizer::potential_solution", ptr %22, i32 0, i32 3
  %24 = load i64, ptr %23, align 8, !tbaa !11
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %4
  br label %178

27:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %28 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 0
  %29 = load ptr, ptr %28, align 8, !tbaa !22
  %30 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %29, i32 0, i32 5
  %31 = load i32, ptr %30, align 8, !tbaa !23
  store i32 %31, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %173, %27
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 2, ptr %11, align 4
  br label %176

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %38 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !22
  %40 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %39, i32 0, i32 4
  %41 = load ptr, ptr %40, align 8, !tbaa !28
  %42 = load i32, ptr %10, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %41, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  store i32 %45, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = load i32, ptr %12, align 4, !tbaa !9
  %48 = add nsw i32 %46, %47
  store i32 %48, ptr %13, align 4, !tbaa !9
  %49 = load i32, ptr %13, align 4, !tbaa !9
  %50 = icmp slt i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %37
  store i32 4, ptr %11, align 4
  br label %170

52:                                               ; preds = %37
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 2
  %55 = load i32, ptr %54, align 8, !tbaa !29
  %56 = icmp sgt i32 %53, %55
  br i1 %56, label %57, label %58

57:                                               ; preds = %52
  store i32 2, ptr %11, align 4
  br label %170

58:                                               ; preds = %52
  br label %59

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

60:                                               ; preds = %165, %59
  %61 = load i32, ptr %14, align 4, !tbaa !9
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %65, label %64

64:                                               ; preds = %60
  store i32 5, ptr %11, align 4
  br label %168

65:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %66 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !22
  %68 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !28
  %70 = load i32, ptr %14, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i32, ptr %69, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !9
  store i32 %73, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = load i32, ptr %15, align 4, !tbaa !9
  %76 = add nsw i32 %74, %75
  store i32 %76, ptr %16, align 4, !tbaa !9
  %77 = load i32, ptr %16, align 4, !tbaa !9
  %78 = icmp slt i32 %77, 0
  br i1 %78, label %79, label %80

79:                                               ; preds = %65
  store i32 7, ptr %11, align 4
  br label %162

80:                                               ; preds = %65
  %81 = load i32, ptr %16, align 4, !tbaa !9
  %82 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 2
  %83 = load i32, ptr %82, align 8, !tbaa !29
  %84 = icmp sgt i32 %81, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %80
  store i32 5, ptr %11, align 4
  br label %162

86:                                               ; preds = %80
  br label %87

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

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

92:                                               ; preds = %88
  store i32 8, ptr %11, align 4
  br label %160

93:                                               ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %94 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !22
  %96 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %95, i32 0, i32 4
  %97 = load ptr, ptr %96, align 8, !tbaa !28
  %98 = load i32, ptr %17, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds i32, ptr %97, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !9
  store i32 %101, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %102 = load i32, ptr %6, align 4, !tbaa !9
  %103 = load i32, ptr %18, align 4, !tbaa !9
  %104 = add nsw i32 %102, %103
  store i32 %104, ptr %19, align 4, !tbaa !9
  %105 = load i32, ptr %19, align 4, !tbaa !9
  %106 = icmp slt i32 %105, 0
  br i1 %106, label %107, label %108

107:                                              ; preds = %93
  store i32 10, ptr %11, align 4
  br label %154

108:                                              ; preds = %93
  %109 = load i32, ptr %19, align 4, !tbaa !9
  %110 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 2
  %111 = load i32, ptr %110, align 8, !tbaa !29
  %112 = icmp sgt i32 %109, %111
  br i1 %112, label %113, label %114

113:                                              ; preds = %108
  store i32 8, ptr %11, align 4
  br label %154

114:                                              ; preds = %108
  br label %115

115:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 12, ptr %20) #3
  %116 = load i32, ptr %19, align 4, !tbaa !9
  %117 = load i32, ptr %16, align 4, !tbaa !9
  %118 = load i32, ptr %13, align 4, !tbaa !9
  %119 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 0
  %120 = load ptr, ptr %119, align 8, !tbaa !22
  %121 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %120, i32 0, i32 3
  %122 = load i8, ptr %121, align 8, !tbaa !30, !range !31, !noundef !32
  %123 = trunc i8 %122 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %20, i32 noundef %116, i32 noundef %117, i32 noundef %118, i32 noundef 0, i1 noundef zeroext %123)
  %124 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 16
  %125 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 15
  %126 = call noundef zeroext i1 @_ZN6basisu14etc1_optimizer17evaluate_solutionERKNS_25etc1_solution_coordinatesERNS0_18potential_solutionEPS4_(ptr noundef nonnull align 8 dereferenceable(384) %21, ptr noundef nonnull align 4 dereferenceable(9) %20, ptr noundef nonnull align 8 dereferenceable(41) %124, ptr noundef %125)
  br i1 %126, label %128, label %127

127:                                              ; preds = %115
  store i32 10, ptr %11, align 4
  br label %153

128:                                              ; preds = %115
  %129 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 0
  %130 = load ptr, ptr %129, align 8, !tbaa !22
  %131 = getelementptr inbounds %"struct.basisu::etc1_optimizer::params", ptr %130, i32 0, i32 8
  %132 = load i8, ptr %131, align 1, !tbaa !33, !range !31, !noundef !32
  %133 = trunc i8 %132 to i1
  br i1 %133, label %134, label %152

134:                                              ; preds = %128
  %135 = getelementptr inbounds %"class.basisu::etc1_optimizer", ptr %21, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !22
  %137 = getelementptr inbounds %"struct.basisu::basis_etc1_pack_params", ptr %136, i32 0, i32 0
  %138 = load i32, ptr %137, align 8, !tbaa !34
  %139 = icmp eq i32 %138, 0
  br i1 %139, label %140, label %141

140:                                              ; preds = %134
  br label %150

141:                                              ; preds = %134
  %142 = load i32, ptr %18, align 4, !tbaa !9
  %143 = load i32, ptr %15, align 4, !tbaa !9
  %144 = or i32 %142, %143
  %145 = load i32, ptr %12, align 4, !tbaa !9
  %146 = or i32 %144, %145
  %147 = icmp eq i32 %146, 0
  %148 = zext i1 %147 to i64
  %149 = select i1 %147, i32 4, i32 2
  br label %150

150:                                              ; preds = %141, %140
  %151 = phi i32 [ 2, %140 ], [ %149, %141 ]
  call void @_ZN6basisu14etc1_optimizer15refine_solutionEj(ptr noundef nonnull align 8 dereferenceable(384) %21, i32 noundef %151)
  br label %152

152:                                              ; preds = %150, %128
  store i32 0, ptr %11, align 4
  br label %153

153:                                              ; preds = %152, %127
  call void @llvm.lifetime.end.p0(i64 12, ptr %20) #3
  br label %154

154:                                              ; preds = %153, %113, %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %155 = load i32, ptr %11, align 4
  switch i32 %155, label %160 [
    i32 0, label %156
    i32 10, label %157
  ]

156:                                              ; preds = %154
  br label %157

157:                                              ; preds = %156, %154
  %158 = load i32, ptr %17, align 4, !tbaa !9
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %17, align 4, !tbaa !9
  br label %88, !llvm.loop !35

160:                                              ; preds = %154, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %161

161:                                              ; preds = %160
  store i32 0, ptr %11, align 4
  br label %162

162:                                              ; preds = %161, %85, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  %163 = load i32, ptr %11, align 4
  switch i32 %163, label %168 [
    i32 0, label %164
    i32 7, label %165
  ]

164:                                              ; preds = %162
  br label %165

165:                                              ; preds = %164, %162
  %166 = load i32, ptr %14, align 4, !tbaa !9
  %167 = add nsw i32 %166, 1
  store i32 %167, ptr %14, align 4, !tbaa !9
  br label %60, !llvm.loop !37

168:                                              ; preds = %162, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %169

169:                                              ; preds = %168
  store i32 0, ptr %11, align 4
  br label %170

170:                                              ; preds = %169, %57, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %171 = load i32, ptr %11, align 4
  switch i32 %171, label %176 [
    i32 0, label %172
    i32 4, label %173
  ]

172:                                              ; preds = %170
  br label %173

173:                                              ; preds = %172, %170
  %174 = load i32, ptr %10, align 4, !tbaa !9
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %10, align 4, !tbaa !9
  br label %32, !llvm.loop !38

176:                                              ; preds = %170, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %177

177:                                              ; preds = %176
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %178

178:                                              ; preds = %177, %26
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu14etc1_optimizer15refine_solutionEj(ptr noundef nonnull align 8 dereferenceable(384), 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) #2 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 #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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, !21, i64 176}
!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 = !{!12, !6, i64 0}
!23 = !{!24, !10, i64 40}
!24 = !{!"_ZTSN6basisu14etc1_optimizer6paramsE", !25, 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}
!25 = !{!"_ZTSN6basisu22basis_etc1_pack_paramsE", !26, i64 0, !20, i64 4, !20, i64 5, !20, i64 6, !20, i64 7, !27, i64 8}
!26 = !{!"_ZTSN6basisu17basis_etc_qualityE", !7, i64 0}
!27 = !{!"float", !7, i64 0}
!28 = !{!24, !6, i64 32}
!29 = !{!12, !10, i64 16}
!30 = !{!24, !20, i64 24}
!31 = !{i8 0, i8 2}
!32 = !{}
!33 = !{!24, !20, i64 49}
!34 = !{!25, !26, i64 0}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}
!37 = distinct !{!37, !36}
!38 = distinct !{!38, !36}


; 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] }

; 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: mustprogress uwtable
define dso_local void @_ZN6basisu14etc1_optimizer29compute_internal_neighborhoodEiii(ptr noundef nonnull align 8 dereferenceable(384) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"struct.basisu::etc1_solution_coordinates", align 4
  %6 = getelementptr inbounds i8, ptr %0, i64 144
  %7 = getelementptr inbounds i8, ptr %0, i64 176
  %8 = load i64, ptr %7, align 8, !tbaa !5
  %9 = icmp eq i64 %8, 0
  br i1 %9, label %.loopexit49, label %10

10:                                               ; preds = %4
  %11 = load ptr, ptr %0, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %11, i64 40
  %13 = load i32, ptr %12, align 8, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = icmp sgt i32 %13, 0
  br i1 %15, label %.lr.ph.split.us.preheader, label %.loopexit49

.lr.ph.split.us.preheader:                        ; preds = %10
  %16 = getelementptr inbounds i8, ptr %0, i64 192
  %wide.trip.count69 = zext nneg i32 %13 to i64
  br label %.lr.ph.split.us

.lr.ph.split.us:                                  ; preds = %.lr.ph.split.us.preheader, %.loopexit.us
  %indvars.iv66 = phi i64 [ 0, %.lr.ph.split.us.preheader ], [ %indvars.iv.next67, %.loopexit.us ]
  %17 = load ptr, ptr %0, align 8, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %17, i64 32
  %19 = load ptr, ptr %18, align 8, !tbaa !26
  %20 = getelementptr inbounds i32, ptr %19, i64 %indvars.iv66
  %21 = load i32, ptr %20, align 4, !tbaa !27
  %22 = add nsw i32 %21, %3
  %23 = icmp slt i32 %22, 0
  br i1 %23, label %.loopexit.us, label %24

24:                                               ; preds = %.lr.ph.split.us
  %25 = load i32, ptr %14, align 8, !tbaa !28
  %26 = icmp sgt i32 %22, %25
  br i1 %26, label %.loopexit49, label %.preheader48.us

.loopexit.us:                                     ; preds = %.thread.us.us, %34, %.lr.ph.split.us
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %exitcond70.not = icmp eq i64 %indvars.iv.next67, %wide.trip.count69
  br i1 %exitcond70.not, label %.loopexit49, label %.lr.ph.split.us, !llvm.loop !29

.preheader48.us:                                  ; preds = %24, %.thread.us.us
  %indvars.iv61 = phi i64 [ %indvars.iv.next62, %.thread.us.us ], [ 0, %24 ]
  %27 = load ptr, ptr %0, align 8, !tbaa !20
  %28 = getelementptr inbounds i8, ptr %27, i64 32
  %29 = load ptr, ptr %28, align 8, !tbaa !26
  %30 = getelementptr inbounds i32, ptr %29, i64 %indvars.iv61
  %31 = load i32, ptr %30, align 4, !tbaa !27
  %32 = add nsw i32 %31, %2
  %33 = icmp slt i32 %32, 0
  br i1 %33, label %.thread.us.us, label %34

34:                                               ; preds = %.preheader48.us
  %35 = load i32, ptr %14, align 8, !tbaa !28
  %36 = icmp sgt i32 %32, %35
  br i1 %36, label %.loopexit.us, label %.preheader.us.us

37:                                               ; preds = %.preheader.us.us, %.thread41.us.us
  %indvars.iv = phi i64 [ 0, %.preheader.us.us ], [ %indvars.iv.next, %.thread41.us.us ]
  %38 = load ptr, ptr %0, align 8, !tbaa !20
  %39 = getelementptr inbounds i8, ptr %38, i64 32
  %40 = load ptr, ptr %39, align 8, !tbaa !26
  %41 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv
  %42 = load i32, ptr %41, align 4, !tbaa !27
  %43 = add nsw i32 %42, %1
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %.thread41.us.us, label %45

45:                                               ; preds = %37
  %46 = load i32, ptr %14, align 8, !tbaa !28
  %47 = icmp sgt i32 %43, %46
  br i1 %47, label %.thread.us.us, label %48

48:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #3
  %49 = getelementptr inbounds i8, ptr %38, i64 24
  %50 = load i8, ptr %49, align 8, !tbaa !31, !range !32, !noundef !33
  %51 = trunc nuw i8 %50 to i1
  call void @_ZN6basisu25etc1_solution_coordinatesC2Ejjjjb(ptr noundef nonnull align 4 dereferenceable(9) %5, i32 noundef %43, i32 noundef %32, i32 noundef %22, i32 noundef 0, i1 noundef zeroext %51)
  %52 = 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) %5, ptr noundef nonnull align 8 dereferenceable(41) %16, ptr noundef nonnull %6)
  br i1 %52, label %53, label %65

53:                                               ; preds = %48
  %54 = load ptr, ptr %0, align 8, !tbaa !20
  %55 = getelementptr inbounds i8, ptr %54, i64 49
  %56 = load i8, ptr %55, align 1, !tbaa !34, !range !32, !noundef !33
  %57 = trunc nuw i8 %56 to i1
  br i1 %57, label %58, label %65

58:                                               ; preds = %53
  %59 = load i32, ptr %54, align 8, !tbaa !35
  %60 = icmp eq i32 %59, 0
  %61 = or i32 %66, %42
  %62 = icmp eq i32 %61, 0
  %63 = select i1 %62, i32 4, i32 2
  %64 = select i1 %60, i32 2, i32 %63
  call void @_ZN6basisu14etc1_optimizer15refine_solutionEj(ptr noundef nonnull align 8 dereferenceable(384) %0, i32 noundef %64)
  br label %65

65:                                               ; preds = %58, %53, %48
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #3
  br label %.thread41.us.us

.thread41.us.us:                                  ; preds = %65, %37
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count69
  br i1 %exitcond.not, label %.thread.us.us, label %37, !llvm.loop !36

.thread.us.us:                                    ; preds = %45, %.thread41.us.us, %.preheader48.us
  %indvars.iv.next62 = add nuw nsw i64 %indvars.iv61, 1
  %exitcond65.not = icmp eq i64 %indvars.iv.next62, %wide.trip.count69
  br i1 %exitcond65.not, label %.loopexit.us, label %.preheader48.us, !llvm.loop !37

.preheader.us.us:                                 ; preds = %34
  %66 = or i32 %31, %21
  br label %37

.loopexit49:                                      ; preds = %.loopexit.us, %24, %10, %4
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu14etc1_optimizer15refine_solutionEj(ptr noundef nonnull align 8 dereferenceable(384), 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 #2 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 #2 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { 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, !19, i64 176}
!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 = !{!6, !7, i64 0}
!21 = !{!22, !10, i64 40}
!22 = !{!"_ZTSN6basisu14etc1_optimizer6paramsE", !23, 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}
!23 = !{!"_ZTSN6basisu22basis_etc1_pack_paramsE", !24, i64 0, !18, i64 4, !18, i64 5, !18, i64 6, !18, i64 7, !25, i64 8}
!24 = !{!"_ZTSN6basisu17basis_etc_qualityE", !8, i64 0}
!25 = !{!"float", !8, i64 0}
!26 = !{!22, !7, i64 32}
!27 = !{!10, !10, i64 0}
!28 = !{!6, !10, i64 16}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!22, !18, i64 24}
!32 = !{i8 0, i8 2}
!33 = !{}
!34 = !{!22, !18, i64 49}
!35 = !{!23, !24, i64 0}
!36 = distinct !{!36, !30}
!37 = distinct !{!37, !30}


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