; LLVM IR from Try/Tempest :: Engine/thirdparty/squish/rangefit.ll (ZN6squish8RangeFit9Compress4EPv)

; 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::ColourFit" = type <{ ptr, ptr, i32, [4 x i8] }>
%"class.squish::RangeFit" = type { %"class.squish::ColourFit.base", %"class.squish::Vec3", %"class.squish::Vec3", %"class.squish::Vec3", float, [4 x i8] }
%"class.squish::ColourFit.base" = type <{ ptr, ptr, i32 }>

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

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

; 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) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6squish9ColourSet8GetCountEv(ptr noundef nonnull align 4 dereferenceable(325)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6squish9ColourSet9GetPointsEv(ptr noundef nonnull align 4 dereferenceable(325)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishplERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef, ptr noundef nonnull align 4 dereferenceable(12)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12)) #4

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3

declare void @_ZNK6squish9ColourSet12RemapIndicesEPKhPh(ptr noundef nonnull align 4 dereferenceable(325), ptr noundef, ptr noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6squish8RangeFit9Compress4EPv(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1) unnamed_addr #6 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca [4 x %"class.squish::Vec3"], align 16
  %8 = alloca %"class.squish::Vec3", align 4
  %9 = alloca %"class.squish::Vec3", align 4
  %10 = alloca { <2 x float>, float }, align 8
  %11 = alloca %"class.squish::Vec3", align 4
  %12 = alloca { <2 x float>, float }, align 8
  %13 = alloca { <2 x float>, float }, align 8
  %14 = alloca %"class.squish::Vec3", align 4
  %15 = alloca %"class.squish::Vec3", align 4
  %16 = alloca { <2 x float>, float }, align 8
  %17 = alloca %"class.squish::Vec3", align 4
  %18 = alloca { <2 x float>, float }, align 8
  %19 = alloca { <2 x float>, float }, align 8
  %20 = alloca [16 x i8], align 16
  %21 = alloca float, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca float, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  %27 = alloca float, align 4
  %28 = alloca %"class.squish::Vec3", align 4
  %29 = alloca %"class.squish::Vec3", align 4
  %30 = alloca { <2 x float>, float }, align 8
  %31 = alloca { <2 x float>, float }, align 8
  %32 = alloca [16 x i8], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %33 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %34 = getelementptr inbounds %"class.squish::ColourFit", ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = call noundef i32 @_ZNK6squish9ColourSet8GetCountEv(ptr noundef nonnull align 4 dereferenceable(325) %35)
  store i32 %36, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %37 = getelementptr inbounds %"class.squish::ColourFit", ptr %33, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = call noundef ptr @_ZNK6squish9ColourSet9GetPointsEv(ptr noundef nonnull align 4 dereferenceable(325) %38)
  store ptr %39, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 48, ptr %7) #7
  %40 = getelementptr inbounds [4 x %"class.squish::Vec3"], ptr %7, i32 0, i32 0
  %41 = getelementptr inbounds %"class.squish::Vec3", ptr %40, i64 4
  br label %42

42:                                               ; preds = %42, %2
  %43 = phi ptr [ %40, %2 ], [ %44, %42 ]
  call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %43)
  %44 = getelementptr inbounds %"class.squish::Vec3", ptr %43, i64 1
  %45 = icmp eq ptr %44, %41
  br i1 %45, label %46, label %42

46:                                               ; preds = %42
  %47 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 2
  %48 = getelementptr inbounds [4 x %"class.squish::Vec3"], ptr %7, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %48, ptr align 8 %47, i64 12, i1 false), !tbaa.struct !13
  %49 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 3
  %50 = getelementptr inbounds [4 x %"class.squish::Vec3"], ptr %7, i64 0, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %50, ptr align 4 %49, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #7
  %51 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 2
  %52 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FE5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %51)
  store { <2 x float>, float } %52, ptr %10, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 8 %10, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #7
  %53 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 3
  %54 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FD5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %53)
  store { <2 x float>, float } %54, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %12, i64 12, i1 false)
  %55 = call { <2 x float>, float } @_ZN6squishplERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %11)
  store { <2 x float>, float } %55, ptr %13, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %13, i64 12, i1 false)
  %56 = getelementptr inbounds [4 x %"class.squish::Vec3"], ptr %7, i64 0, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %56, ptr align 4 %8, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %15) #7
  %57 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 2
  %58 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FD5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %57)
  store { <2 x float>, float } %58, ptr %16, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 8 %16, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %17) #7
  %59 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 3
  %60 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FE5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %59)
  store { <2 x float>, float } %60, ptr %18, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 8 %18, i64 12, i1 false)
  %61 = call { <2 x float>, float } @_ZN6squishplERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %15, ptr noundef nonnull align 4 dereferenceable(12) %17)
  store { <2 x float>, float } %61, ptr %19, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 8 %19, i64 12, i1 false)
  %62 = getelementptr inbounds [4 x %"class.squish::Vec3"], ptr %7, i64 0, i64 3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %62, ptr align 4 %14, i64 12, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 12, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store float 0.000000e+00, ptr %21, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #7
  store i32 0, ptr %22, align 4, !tbaa !12
  br label %63

63:                                               ; preds = %104, %46
  %64 = load i32, ptr %22, align 4, !tbaa !12
  %65 = load i32, ptr %5, align 4, !tbaa !12
  %66 = icmp slt i32 %64, %65
  br i1 %66, label %68, label %67

67:                                               ; preds = %63
  store i32 2, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #7
  br label %107

68:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  store float 0x47EFFFFFE0000000, ptr %24, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #7
  store i32 0, ptr %25, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #7
  store i32 0, ptr %26, align 4, !tbaa !12
  br label %69

69:                                               ; preds = %92, %68
  %70 = load i32, ptr %26, align 4, !tbaa !12
  %71 = icmp slt i32 %70, 4
  br i1 %71, label %73, label %72

72:                                               ; preds = %69
  store i32 5, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #7
  br label %95

73:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %28) #7
  %74 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %29) #7
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load i32, ptr %22, align 4, !tbaa !12
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %"class.squish::Vec3", ptr %75, i64 %77
  %79 = load i32, ptr %26, align 4, !tbaa !12
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [4 x %"class.squish::Vec3"], ptr %7, i64 0, i64 %80
  %82 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %78, ptr noundef nonnull align 4 dereferenceable(12) %81)
  store { <2 x float>, float } %82, ptr %30, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %29, ptr align 8 %30, i64 12, i1 false)
  %83 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %74, ptr noundef nonnull align 4 dereferenceable(12) %29)
  store { <2 x float>, float } %83, ptr %31, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 8 %31, i64 12, i1 false)
  %84 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %28)
  call void @llvm.lifetime.end.p0(i64 12, ptr %29) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %28) #7
  store float %84, ptr %27, align 4, !tbaa !14
  %85 = load float, ptr %27, align 4, !tbaa !14
  %86 = load float, ptr %24, align 4, !tbaa !14
  %87 = fcmp olt float %85, %86
  br i1 %87, label %88, label %91

88:                                               ; preds = %73
  %89 = load float, ptr %27, align 4, !tbaa !14
  store float %89, ptr %24, align 4, !tbaa !14
  %90 = load i32, ptr %26, align 4, !tbaa !12
  store i32 %90, ptr %25, align 4, !tbaa !12
  br label %91

91:                                               ; preds = %88, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #7
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %26, align 4, !tbaa !12
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %26, align 4, !tbaa !12
  br label %69, !llvm.loop !16

95:                                               ; preds = %72
  %96 = load i32, ptr %25, align 4, !tbaa !12
  %97 = trunc i32 %96 to i8
  %98 = load i32, ptr %22, align 4, !tbaa !12
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [16 x i8], ptr %20, i64 0, i64 %99
  store i8 %97, ptr %100, align 1, !tbaa !18
  %101 = load float, ptr %24, align 4, !tbaa !14
  %102 = load float, ptr %21, align 4, !tbaa !14
  %103 = fadd float %102, %101
  store float %103, ptr %21, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  br label %104

104:                                              ; preds = %95
  %105 = load i32, ptr %22, align 4, !tbaa !12
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %22, align 4, !tbaa !12
  br label %63, !llvm.loop !19

107:                                              ; preds = %67
  %108 = load float, ptr %21, align 4, !tbaa !14
  %109 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 4
  %110 = load float, ptr %109, align 8, !tbaa !20
  %111 = fcmp olt float %108, %110
  br i1 %111, label %112, label %123

112:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 16, ptr %32) #7
  %113 = getelementptr inbounds %"class.squish::ColourFit", ptr %33, i32 0, i32 1
  %114 = load ptr, ptr %113, align 8, !tbaa !9
  %115 = getelementptr inbounds [16 x i8], ptr %20, i64 0, i64 0
  %116 = getelementptr inbounds [16 x i8], ptr %32, i64 0, i64 0
  call void @_ZNK6squish9ColourSet12RemapIndicesEPKhPh(ptr noundef nonnull align 4 dereferenceable(325) %114, ptr noundef %115, ptr noundef %116)
  %117 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 2
  %118 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 3
  %119 = getelementptr inbounds [16 x i8], ptr %32, i64 0, i64 0
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN6squish17WriteColourBlock4ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12) %117, ptr noundef nonnull align 4 dereferenceable(12) %118, ptr noundef %119, ptr noundef %120)
  %121 = load float, ptr %21, align 4, !tbaa !14
  %122 = getelementptr inbounds %"class.squish::RangeFit", ptr %33, i32 0, i32 4
  store float %121, ptr %122, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 16, ptr %32) #7
  br label %123

123:                                              ; preds = %112, %107
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  ret void
}

declare void @_ZN6squish17WriteColourBlock4ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef, ptr noundef) #5

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { mustprogress uwtable "min-legal-vector-width"="64" "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 #7 = { 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, !6, i64 8}
!10 = !{!"_ZTSN6squish9ColourFitE", !6, i64 8, !11, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{i64 0, i64 4, !14, i64 4, i64 4, !14, i64 8, i64 4, !14}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !17}
!20 = !{!21, !15, i64 56}
!21 = !{!"_ZTSN6squish8RangeFitE", !10, i64 0, !22, i64 20, !22, i64 32, !22, i64 44, !15, i64 56}
!22 = !{!"_ZTSN6squish4Vec3E", !15, i64 0, !15, i64 4, !15, i64 8}


; 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
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 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: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6squish9ColourSet8GetCountEv(ptr noundef nonnull align 4 dereferenceable(325)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6squish9ColourSet9GetPointsEv(ptr noundef nonnull align 4 dereferenceable(325)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishplERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef, ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #3

declare void @_ZNK6squish9ColourSet12RemapIndicesEPKhPh(ptr noundef nonnull align 4 dereferenceable(325), ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6squish8RangeFit9Compress4EPv(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1) unnamed_addr #6 align 2 {
  %3 = alloca [4 x %"class.squish::Vec3"], align 16
  %4 = alloca %"class.squish::Vec3", align 8
  %5 = alloca %"class.squish::Vec3", align 8
  %6 = alloca %"class.squish::Vec3", align 8
  %7 = alloca %"class.squish::Vec3", align 8
  %8 = alloca [16 x i8], align 16
  %9 = alloca %"class.squish::Vec3", align 8
  %10 = alloca %"class.squish::Vec3", align 8
  %11 = alloca [16 x i8], align 16
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %14 = tail call noundef i32 @_ZNK6squish9ColourSet8GetCountEv(ptr noundef nonnull align 4 dereferenceable(325) %13)
  %15 = load ptr, ptr %12, align 8, !tbaa !5
  %16 = tail call noundef ptr @_ZNK6squish9ColourSet9GetPointsEv(ptr noundef nonnull align 4 dereferenceable(325) %15)
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #7
  call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %3)
  %.ptr.1 = getelementptr inbounds i8, ptr %3, i64 12
  call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.ptr.2 = getelementptr inbounds i8, ptr %3, i64 24
  call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %.ptr.3 = getelementptr inbounds i8, ptr %3, i64 36
  call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.3)
  %17 = getelementptr inbounds i8, ptr %0, i64 32
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(12) %3, ptr noundef nonnull align 8 dereferenceable(12) %17, i64 12, i1 false), !tbaa.struct !11
  %18 = getelementptr inbounds i8, ptr %0, i64 44
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1, ptr noundef nonnull align 4 dereferenceable(12) %18, i64 12, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #7
  %19 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FE5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %17)
  %.fca.0.extract40 = extractvalue { <2 x float>, float } %19, 0
  %.fca.1.extract41 = extractvalue { <2 x float>, float } %19, 1
  store <2 x float> %.fca.0.extract40, ptr %4, align 8
  %.sroa.243.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  store float %.fca.1.extract41, ptr %.sroa.243.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #7
  %20 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FD5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %18)
  %.fca.0.extract36 = extractvalue { <2 x float>, float } %20, 0
  %.fca.1.extract37 = extractvalue { <2 x float>, float } %20, 1
  store <2 x float> %.fca.0.extract36, ptr %5, align 8
  %.sroa.239.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract37, ptr %.sroa.239.0..sroa_idx, align 8
  %21 = call { <2 x float>, float } @_ZN6squishplERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %4, ptr noundef nonnull align 4 dereferenceable(12) %5)
  %.fca.0.extract32 = extractvalue { <2 x float>, float } %21, 0
  %.fca.1.extract33 = extractvalue { <2 x float>, float } %21, 1
  store <2 x float> %.fca.0.extract32, ptr %.ptr.2, align 8
  %.sroa.445.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 32
  store float %.fca.1.extract33, ptr %.sroa.445.0..sroa_idx, align 16, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #7
  %22 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FD5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %17)
  %.fca.0.extract27 = extractvalue { <2 x float>, float } %22, 0
  %.fca.1.extract28 = extractvalue { <2 x float>, float } %22, 1
  store <2 x float> %.fca.0.extract27, ptr %6, align 8
  %.sroa.230.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store float %.fca.1.extract28, ptr %.sroa.230.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #7
  %23 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 0x3FE5555560000000, ptr noundef nonnull align 4 dereferenceable(12) %18)
  %.fca.0.extract23 = extractvalue { <2 x float>, float } %23, 0
  %.fca.1.extract24 = extractvalue { <2 x float>, float } %23, 1
  store <2 x float> %.fca.0.extract23, ptr %7, align 8
  %.sroa.226.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  store float %.fca.1.extract24, ptr %.sroa.226.0..sroa_idx, align 8
  %24 = call { <2 x float>, float } @_ZN6squishplERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %7)
  %.fca.0.extract19 = extractvalue { <2 x float>, float } %24, 0
  %.fca.1.extract20 = extractvalue { <2 x float>, float } %24, 1
  store <2 x float> %.fca.0.extract19, ptr %.ptr.3, align 4
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 44
  store float %.fca.1.extract20, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #7
  %25 = icmp sgt i32 %14, 0
  br i1 %25, label %.preheader.lr.ph, label %._crit_edge

.preheader.lr.ph:                                 ; preds = %2
  %26 = getelementptr inbounds i8, ptr %0, i64 20
  %.sroa.24.0..sroa_idx = getelementptr inbounds i8, ptr %10, i64 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %9, i64 8
  %wide.trip.count = zext nneg i32 %14 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next, %.preheader ]
  %.061 = phi float [ 0.000000e+00, %.preheader.lr.ph ], [ %48, %.preheader ]
  %27 = getelementptr inbounds %"class.squish::Vec3", ptr %16, i64 %indvars.iv
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #7
  %28 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %27, ptr noundef nonnull align 4 dereferenceable(12) %3)
  %.fca.0.extract1 = extractvalue { <2 x float>, float } %28, 0
  %.fca.1.extract2 = extractvalue { <2 x float>, float } %28, 1
  store <2 x float> %.fca.0.extract1, ptr %10, align 8
  store float %.fca.1.extract2, ptr %.sroa.24.0..sroa_idx, align 8
  %29 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %26, ptr noundef nonnull align 4 dereferenceable(12) %10)
  %.fca.0.extract = extractvalue { <2 x float>, float } %29, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %29, 1
  store <2 x float> %.fca.0.extract, ptr %9, align 8
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %30 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #7
  %31 = fcmp olt float %30, 0x47EFFFFFE0000000
  %.1 = select i1 %31, float %30, float 0x47EFFFFFE0000000
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #7
  %32 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %27, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.fca.0.extract1.1 = extractvalue { <2 x float>, float } %32, 0
  %.fca.1.extract2.1 = extractvalue { <2 x float>, float } %32, 1
  store <2 x float> %.fca.0.extract1.1, ptr %10, align 8
  store float %.fca.1.extract2.1, ptr %.sroa.24.0..sroa_idx, align 8
  %33 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %26, ptr noundef nonnull align 4 dereferenceable(12) %10)
  %.fca.0.extract.1 = extractvalue { <2 x float>, float } %33, 0
  %.fca.1.extract.1 = extractvalue { <2 x float>, float } %33, 1
  store <2 x float> %.fca.0.extract.1, ptr %9, align 8
  store float %.fca.1.extract.1, ptr %.sroa.2.0..sroa_idx, align 8
  %34 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #7
  %35 = fcmp olt float %34, %.1
  %.1.1 = select i1 %35, float %34, float %.1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #7
  %36 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %27, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %.fca.0.extract1.2 = extractvalue { <2 x float>, float } %36, 0
  %.fca.1.extract2.2 = extractvalue { <2 x float>, float } %36, 1
  store <2 x float> %.fca.0.extract1.2, ptr %10, align 8
  store float %.fca.1.extract2.2, ptr %.sroa.24.0..sroa_idx, align 8
  %37 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %26, ptr noundef nonnull align 4 dereferenceable(12) %10)
  %.fca.0.extract.2 = extractvalue { <2 x float>, float } %37, 0
  %.fca.1.extract.2 = extractvalue { <2 x float>, float } %37, 1
  store <2 x float> %.fca.0.extract.2, ptr %9, align 8
  store float %.fca.1.extract.2, ptr %.sroa.2.0..sroa_idx, align 8
  %38 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #7
  %39 = fcmp olt float %38, %.1.1
  %40 = zext i1 %35 to i8
  %.1.2 = select i1 %39, float %38, float %.1.1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %9) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %10) #7
  %41 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %27, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.3)
  %.fca.0.extract1.3 = extractvalue { <2 x float>, float } %41, 0
  %.fca.1.extract2.3 = extractvalue { <2 x float>, float } %41, 1
  store <2 x float> %.fca.0.extract1.3, ptr %10, align 8
  store float %.fca.1.extract2.3, ptr %.sroa.24.0..sroa_idx, align 8
  %42 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %26, ptr noundef nonnull align 4 dereferenceable(12) %10)
  %.fca.0.extract.3 = extractvalue { <2 x float>, float } %42, 0
  %.fca.1.extract.3 = extractvalue { <2 x float>, float } %42, 1
  store <2 x float> %.fca.0.extract.3, ptr %9, align 8
  store float %.fca.1.extract.3, ptr %.sroa.2.0..sroa_idx, align 8
  %43 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %9) #7
  %44 = fcmp olt float %43, %.1.2
  %45 = select i1 %39, i8 2, i8 %40
  %.1.3 = select i1 %44, float %43, float %.1.2
  %46 = select i1 %44, i8 3, i8 %45
  %47 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 %indvars.iv
  store i8 %46, ptr %47, align 1, !tbaa !14
  %48 = fadd float %.061, %.1.3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.preheader, !llvm.loop !15

._crit_edge:                                      ; preds = %.preheader, %2
  %.0.lcssa = phi float [ 0.000000e+00, %2 ], [ %48, %.preheader ]
  %49 = getelementptr inbounds i8, ptr %0, i64 56
  %50 = load float, ptr %49, align 8, !tbaa !17
  %51 = fcmp olt float %.0.lcssa, %50
  br i1 %51, label %52, label %54

52:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %11) #7
  %53 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZNK6squish9ColourSet12RemapIndicesEPKhPh(ptr noundef nonnull align 4 dereferenceable(325) %53, ptr noundef nonnull %8, ptr noundef nonnull %11)
  call void @_ZN6squish17WriteColourBlock4ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12) %17, ptr noundef nonnull align 4 dereferenceable(12) %18, ptr noundef nonnull %11, ptr noundef %1)
  store float %.0.lcssa, ptr %49, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %11) #7
  br label %54

54:                                               ; preds = %52, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #7
  ret void
}

declare void @_ZN6squish17WriteColourBlock4ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef, ptr noundef) local_unnamed_addr #5

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 = { 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 = { 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { mustprogress uwtable "min-legal-vector-width"="64" "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 #7 = { 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 8}
!6 = !{!"_ZTSN6squish9ColourFitE", !7, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 4, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!8, !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !13, i64 56}
!18 = !{!"_ZTSN6squish8RangeFitE", !6, i64 0, !19, i64 20, !19, i64 32, !19, i64 44, !13, i64 56}
!19 = !{!"_ZTSN6squish4Vec3E", !13, i64 0, !13, i64 4, !13, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass