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

; 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
define dso_local void @_ZN6squish8RangeFit9Compress3EPv(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1) unnamed_addr #4 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca [3 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 [16 x i8], align 16
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca float, align 4
  %22 = alloca %"class.squish::Vec3", align 4
  %23 = alloca %"class.squish::Vec3", align 4
  %24 = alloca { <2 x float>, float }, align 8
  %25 = alloca { <2 x float>, float }, align 8
  %26 = alloca [16 x i8], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %27 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %28 = getelementptr inbounds %"class.squish::ColourFit", ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = call noundef i32 @_ZNK6squish9ColourSet8GetCountEv(ptr noundef nonnull align 4 dereferenceable(325) %29)
  store i32 %30, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %31 = getelementptr inbounds %"class.squish::ColourFit", ptr %27, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = call noundef ptr @_ZNK6squish9ColourSet9GetPointsEv(ptr noundef nonnull align 4 dereferenceable(325) %32)
  store ptr %33, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 36, ptr %7) #7
  %34 = getelementptr inbounds [3 x %"class.squish::Vec3"], ptr %7, i32 0, i32 0
  %35 = getelementptr inbounds %"class.squish::Vec3", ptr %34, i64 3
  br label %36

36:                                               ; preds = %36, %2
  %37 = phi ptr [ %34, %2 ], [ %38, %36 ]
  call void @_ZN6squish4Vec3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %37)
  %38 = getelementptr inbounds %"class.squish::Vec3", ptr %37, i64 1
  %39 = icmp eq ptr %38, %35
  br i1 %39, label %40, label %36

40:                                               ; preds = %36
  %41 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 2
  %42 = getelementptr inbounds [3 x %"class.squish::Vec3"], ptr %7, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %42, ptr align 8 %41, i64 12, i1 false), !tbaa.struct !13
  %43 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 3
  %44 = getelementptr inbounds [3 x %"class.squish::Vec3"], ptr %7, i64 0, i64 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %44, ptr align 4 %43, 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
  %45 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 2
  %46 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 5.000000e-01, ptr noundef nonnull align 4 dereferenceable(12) %45)
  store { <2 x float>, float } %46, 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
  %47 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 3
  %48 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 5.000000e-01, ptr noundef nonnull align 4 dereferenceable(12) %47)
  store { <2 x float>, float } %48, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %12, i64 12, i1 false)
  %49 = 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 } %49, ptr %13, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 8 %13, i64 12, i1 false)
  %50 = getelementptr inbounds [3 x %"class.squish::Vec3"], ptr %7, i64 0, i64 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %50, 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 16, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store float 0.000000e+00, ptr %15, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 0, ptr %16, align 4, !tbaa !12
  br label %51

51:                                               ; preds = %92, %40
  %52 = load i32, ptr %16, align 4, !tbaa !12
  %53 = load i32, ptr %5, align 4, !tbaa !12
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 2, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %95

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store float 0x47EFFFFFE0000000, ptr %18, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #7
  store i32 0, ptr %19, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  store i32 0, ptr %20, align 4, !tbaa !12
  br label %57

57:                                               ; preds = %80, %56
  %58 = load i32, ptr %20, align 4, !tbaa !12
  %59 = icmp slt i32 %58, 3
  br i1 %59, label %61, label %60

60:                                               ; preds = %57
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  br label %83

61:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr %22) #7
  %62 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 12, ptr %23) #7
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load i32, ptr %16, align 4, !tbaa !12
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %"class.squish::Vec3", ptr %63, i64 %65
  %67 = load i32, ptr %20, align 4, !tbaa !12
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [3 x %"class.squish::Vec3"], ptr %7, i64 0, i64 %68
  %70 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %66, ptr noundef nonnull align 4 dereferenceable(12) %69)
  store { <2 x float>, float } %70, ptr %24, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 8 %24, i64 12, i1 false)
  %71 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %62, ptr noundef nonnull align 4 dereferenceable(12) %23)
  store { <2 x float>, float } %71, ptr %25, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 8 %25, i64 12, i1 false)
  %72 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %22)
  call void @llvm.lifetime.end.p0(i64 12, ptr %23) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr %22) #7
  store float %72, ptr %21, align 4, !tbaa !14
  %73 = load float, ptr %21, align 4, !tbaa !14
  %74 = load float, ptr %18, align 4, !tbaa !14
  %75 = fcmp olt float %73, %74
  br i1 %75, label %76, label %79

76:                                               ; preds = %61
  %77 = load float, ptr %21, align 4, !tbaa !14
  store float %77, ptr %18, align 4, !tbaa !14
  %78 = load i32, ptr %20, align 4, !tbaa !12
  store i32 %78, ptr %19, align 4, !tbaa !12
  br label %79

79:                                               ; preds = %76, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %80

80:                                               ; preds = %79
  %81 = load i32, ptr %20, align 4, !tbaa !12
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %20, align 4, !tbaa !12
  br label %57, !llvm.loop !16

83:                                               ; preds = %60
  %84 = load i32, ptr %19, align 4, !tbaa !12
  %85 = trunc i32 %84 to i8
  %86 = load i32, ptr %16, align 4, !tbaa !12
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 %87
  store i8 %85, ptr %88, align 1, !tbaa !18
  %89 = load float, ptr %18, align 4, !tbaa !14
  %90 = load float, ptr %15, align 4, !tbaa !14
  %91 = fadd float %90, %89
  store float %91, ptr %15, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %92

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

95:                                               ; preds = %55
  %96 = load float, ptr %15, align 4, !tbaa !14
  %97 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 4
  %98 = load float, ptr %97, align 8, !tbaa !20
  %99 = fcmp olt float %96, %98
  br i1 %99, label %100, label %111

100:                                              ; preds = %95
  call void @llvm.lifetime.start.p0(i64 16, ptr %26) #7
  %101 = getelementptr inbounds %"class.squish::ColourFit", ptr %27, i32 0, i32 1
  %102 = load ptr, ptr %101, align 8, !tbaa !9
  %103 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  %104 = getelementptr inbounds [16 x i8], ptr %26, i64 0, i64 0
  call void @_ZNK6squish9ColourSet12RemapIndicesEPKhPh(ptr noundef nonnull align 4 dereferenceable(325) %102, ptr noundef %103, ptr noundef %104)
  %105 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 2
  %106 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 3
  %107 = getelementptr inbounds [16 x i8], ptr %26, i64 0, i64 0
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN6squish17WriteColourBlock3ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12) %105, ptr noundef nonnull align 4 dereferenceable(12) %106, ptr noundef %107, ptr noundef %108)
  %109 = load float, ptr %15, align 4, !tbaa !14
  %110 = getelementptr inbounds %"class.squish::RangeFit", ptr %27, i32 0, i32 4
  store float %109, ptr %110, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 16, ptr %26) #7
  br label %111

111:                                              ; preds = %100, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 36, 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
}

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

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

declare void @_ZN6squish17WriteColourBlock3ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef, ptr noundef) #6

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 = { 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 #5 = { 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 #6 = { "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
define dso_local void @_ZN6squish8RangeFit9Compress3EPv(ptr noundef nonnull align 8 dereferenceable(60) %0, ptr noundef %1) unnamed_addr #4 align 2 {
  %3 = alloca [3 x %"class.squish::Vec3"], align 16
  %4 = alloca %"class.squish::Vec3", align 8
  %5 = alloca %"class.squish::Vec3", align 8
  %6 = alloca [16 x i8], align 16
  %7 = alloca %"class.squish::Vec3", align 8
  %8 = alloca %"class.squish::Vec3", align 8
  %9 = alloca [16 x i8], align 16
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call noundef i32 @_ZNK6squish9ColourSet8GetCountEv(ptr noundef nonnull align 4 dereferenceable(325) %11)
  %13 = load ptr, ptr %10, align 8, !tbaa !5
  %14 = tail call noundef ptr @_ZNK6squish9ColourSet9GetPointsEv(ptr noundef nonnull align 4 dereferenceable(325) %13)
  call void @llvm.lifetime.start.p0(i64 36, 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)
  %15 = 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) %15, i64 12, i1 false), !tbaa.struct !11
  %16 = 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) %16, i64 12, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %4) #7
  %17 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 5.000000e-01, ptr noundef nonnull align 4 dereferenceable(12) %15)
  %.fca.0.extract27 = extractvalue { <2 x float>, float } %17, 0
  %.fca.1.extract28 = extractvalue { <2 x float>, float } %17, 1
  store <2 x float> %.fca.0.extract27, ptr %4, align 8
  %.sroa.230.0..sroa_idx = getelementptr inbounds i8, ptr %4, 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 %5) #7
  %18 = call { <2 x float>, float } @_ZN6squishmlEfRKNS_4Vec3E(float noundef 5.000000e-01, ptr noundef nonnull align 4 dereferenceable(12) %16)
  %.fca.0.extract23 = extractvalue { <2 x float>, float } %18, 0
  %.fca.1.extract24 = extractvalue { <2 x float>, float } %18, 1
  store <2 x float> %.fca.0.extract23, ptr %5, align 8
  %.sroa.226.0..sroa_idx = getelementptr inbounds i8, ptr %5, i64 8
  store float %.fca.1.extract24, ptr %.sroa.226.0..sroa_idx, align 8
  %19 = 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.extract19 = extractvalue { <2 x float>, float } %19, 0
  %.fca.1.extract20 = extractvalue { <2 x float>, float } %19, 1
  store <2 x float> %.fca.0.extract19, ptr %.ptr.2, align 8
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 32
  store float %.fca.1.extract20, ptr %.sroa.4.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 16, ptr nonnull %6) #7
  %20 = icmp sgt i32 %12, 0
  br i1 %20, label %.preheader.lr.ph, label %._crit_edge

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

.preheader:                                       ; preds = %.preheader.lr.ph, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next, %.preheader ]
  %.047 = phi float [ 0.000000e+00, %.preheader.lr.ph ], [ %38, %.preheader ]
  %22 = getelementptr inbounds %"class.squish::Vec3", ptr %14, i64 %indvars.iv
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #7
  %23 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %22, ptr noundef nonnull align 4 dereferenceable(12) %3)
  %.fca.0.extract1 = extractvalue { <2 x float>, float } %23, 0
  %.fca.1.extract2 = extractvalue { <2 x float>, float } %23, 1
  store <2 x float> %.fca.0.extract1, ptr %8, align 8
  store float %.fca.1.extract2, ptr %.sroa.24.0..sroa_idx, align 8
  %24 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %21, ptr noundef nonnull align 4 dereferenceable(12) %8)
  %.fca.0.extract = extractvalue { <2 x float>, float } %24, 0
  %.fca.1.extract = extractvalue { <2 x float>, float } %24, 1
  store <2 x float> %.fca.0.extract, ptr %7, align 8
  store float %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %25 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  %26 = fcmp olt float %25, 0x47EFFFFFE0000000
  %.1 = select i1 %26, float %25, float 0x47EFFFFFE0000000
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #7
  %27 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %22, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.1)
  %.fca.0.extract1.1 = extractvalue { <2 x float>, float } %27, 0
  %.fca.1.extract2.1 = extractvalue { <2 x float>, float } %27, 1
  store <2 x float> %.fca.0.extract1.1, ptr %8, align 8
  store float %.fca.1.extract2.1, ptr %.sroa.24.0..sroa_idx, align 8
  %28 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %21, ptr noundef nonnull align 4 dereferenceable(12) %8)
  %.fca.0.extract.1 = extractvalue { <2 x float>, float } %28, 0
  %.fca.1.extract.1 = extractvalue { <2 x float>, float } %28, 1
  store <2 x float> %.fca.0.extract.1, ptr %7, align 8
  store float %.fca.1.extract.1, ptr %.sroa.2.0..sroa_idx, align 8
  %29 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  %30 = fcmp olt float %29, %.1
  %.1.1 = select i1 %30, float %29, float %.1
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %8) #7
  %31 = call { <2 x float>, float } @_ZN6squishmiERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %22, ptr noundef nonnull align 4 dereferenceable(12) %.ptr.2)
  %.fca.0.extract1.2 = extractvalue { <2 x float>, float } %31, 0
  %.fca.1.extract2.2 = extractvalue { <2 x float>, float } %31, 1
  store <2 x float> %.fca.0.extract1.2, ptr %8, align 8
  store float %.fca.1.extract2.2, ptr %.sroa.24.0..sroa_idx, align 8
  %32 = call { <2 x float>, float } @_ZN6squishmlERKNS_4Vec3ES2_(ptr noundef nonnull align 4 dereferenceable(12) %21, ptr noundef nonnull align 4 dereferenceable(12) %8)
  %.fca.0.extract.2 = extractvalue { <2 x float>, float } %32, 0
  %.fca.1.extract.2 = extractvalue { <2 x float>, float } %32, 1
  store <2 x float> %.fca.0.extract.2, ptr %7, align 8
  store float %.fca.1.extract.2, ptr %.sroa.2.0..sroa_idx, align 8
  %33 = call noundef float @_ZN6squish13LengthSquaredERKNS_4Vec3E(ptr noundef nonnull align 4 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %7) #7
  %34 = fcmp olt float %33, %.1.1
  %35 = zext i1 %30 to i8
  %.1.2 = select i1 %34, float %33, float %.1.1
  %36 = select i1 %34, i8 2, i8 %35
  %37 = getelementptr inbounds [16 x i8], ptr %6, i64 0, i64 %indvars.iv
  store i8 %36, ptr %37, align 1, !tbaa !14
  %38 = fadd float %.047, %.1.2
  %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 ], [ %38, %.preheader ]
  %39 = getelementptr inbounds i8, ptr %0, i64 56
  %40 = load float, ptr %39, align 8, !tbaa !17
  %41 = fcmp olt float %.0.lcssa, %40
  br i1 %41, label %42, label %44

42:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #7
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZNK6squish9ColourSet12RemapIndicesEPKhPh(ptr noundef nonnull align 4 dereferenceable(325) %43, ptr noundef nonnull %6, ptr noundef nonnull %9)
  call void @_ZN6squish17WriteColourBlock3ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12) %15, ptr noundef nonnull align 4 dereferenceable(12) %16, ptr noundef nonnull %9, ptr noundef %1)
  store float %.0.lcssa, ptr %39, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #7
  br label %44

44:                                               ; preds = %42, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %3) #7
  ret void
}

; 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 #5

; 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 #6

declare void @_ZN6squish17WriteColourBlock3ERKNS_4Vec3ES2_PKhPv(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef, ptr noundef) local_unnamed_addr #6

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 = { 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 #5 = { 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 #6 = { "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