; LLVM IR from facebookresearch/habitat-sim :: src/deps/basis-universal/encoder (basisu_enc)

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

%"class.basisu::palette_index_reorderer" = type { %"class.basisu::vector.18", %"class.basisu::vector.18", %"class.basisu::vector.18", %"class.basisu::vector.18", %"class.basisu::vector.18" }
%"class.basisu::vector.18" = type { ptr, i32, i32 }

@.str.4 = external hidden unnamed_addr constant [110 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f = external hidden unnamed_addr constant [114 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [57 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, float noundef %6) #3 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store float %6, ptr %14, align 4, !tbaa !11
  %21 = load ptr, ptr %8, align 8
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = icmp ugt i32 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %7
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = icmp ugt i32 %25, 0
  br label %27

27:                                               ; preds = %24, %7
  %28 = phi i1 [ false, %7 ], [ %26, %24 ]
  br i1 %28, label %29, label %30

29:                                               ; preds = %27
  br label %32

30:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str.26, ptr noundef @.str.4, i32 noundef 1281, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f) #5
  unreachable

31:                                               ; No predecessors!
  br label %32

32:                                               ; preds = %31, %29
  %33 = load float, ptr %14, align 4, !tbaa !11
  %34 = fcmp oge float %33, 0.000000e+00
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load float, ptr %14, align 4, !tbaa !11
  %37 = fcmp ole float %36, 1.000000e+00
  br label %38

38:                                               ; preds = %35, %32
  %39 = phi i1 [ false, %32 ], [ %37, %35 ]
  br i1 %39, label %40, label %41

40:                                               ; preds = %38
  br label %43

41:                                               ; preds = %38
  call void @__assert_fail(ptr noundef @.str.27, ptr noundef @.str.4, i32 noundef 1282, ptr noundef @__PRETTY_FUNCTION__._ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f) #5
  unreachable

42:                                               ; No predecessors!
  br label %43

43:                                               ; preds = %42, %40
  call void @_ZN6basisu23palette_index_reorderer5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %21)
  %44 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 4
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = zext i32 %45 to i64
  call void @_ZN6basisu6vectorIjE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(16) %44, i64 noundef %46, i1 noundef zeroext false)
  %47 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 2
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  call void @_ZN6basisu6vectorIjE7reserveEm(ptr noundef nonnull align 8 dereferenceable(16) %47, i64 noundef %49)
  %50 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 1
  %51 = load i32, ptr %11, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  call void @_ZN6basisu6vectorIjE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(16) %50, i64 noundef %52, i1 noundef zeroext false)
  %53 = load i32, ptr %9, align 4, !tbaa !9
  %54 = icmp ule i32 %53, 1
  br i1 %54, label %55, label %56

55:                                               ; preds = %43
  br label %143

56:                                               ; preds = %43
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN6basisu23palette_index_reorderer12prepare_histEjjPKj(ptr noundef nonnull align 8 dereferenceable(80) %21, i32 noundef %57, i32 noundef %58, ptr noundef %59)
  %60 = load i32, ptr %11, align 4, !tbaa !9
  call void @_ZN6basisu23palette_index_reorderer12find_initialEj(ptr noundef nonnull align 8 dereferenceable(80) %21, i32 noundef %60)
  br label %61

61:                                               ; preds = %123, %56
  %62 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 3
  %63 = call noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %62)
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %124

65:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load ptr, ptr %13, align 8, !tbaa !5
  %68 = load float, ptr %14, align 4, !tbaa !11
  call void @_ZN6basisu23palette_index_reorderer15find_next_entryERjRdPFfjjPvES3_f(ptr noundef nonnull align 8 dereferenceable(80) %21, ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef %66, ptr noundef %67, float noundef %68)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %69 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 3
  %70 = load i32, ptr %15, align 4, !tbaa !9
  %71 = zext i32 %70 to i64
  %72 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %69, i64 noundef %71)
  %73 = load i32, ptr %72, align 4, !tbaa !9
  store i32 %73, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = load i32, ptr %17, align 4, !tbaa !9
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = load float, ptr %14, align 4, !tbaa !11
  %79 = call noundef float @_ZN6basisu23palette_index_reorderer9pick_sideEjjPFfjjPvES1_f(ptr noundef nonnull align 8 dereferenceable(80) %21, i32 noundef %74, i32 noundef %75, ptr noundef %76, ptr noundef %77, float noundef %78)
  store float %79, ptr %18, align 4, !tbaa !11
  %80 = load float, ptr %18, align 4, !tbaa !11
  %81 = fcmp ole float %80, 0.000000e+00
  br i1 %81, label %82, label %84

82:                                               ; preds = %65
  %83 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 2
  call void @_ZN6basisu6vectorIjE9push_backERKj(ptr noundef nonnull align 8 dereferenceable(16) %83, ptr noundef nonnull align 4 dereferenceable(4) %17)
  br label %88

84:                                               ; preds = %65
  %85 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 2
  %86 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 2
  %87 = call noundef ptr @_ZN6basisu6vectorIjE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %86)
  call void @_ZN6basisu6vectorIjE6insertEPjRKj(ptr noundef nonnull align 8 dereferenceable(16) %85, ptr noundef %87, ptr noundef nonnull align 4 dereferenceable(4) %17)
  br label %88

88:                                               ; preds = %84, %82
  %89 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 3
  %90 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 3
  %91 = call noundef ptr @_ZN6basisu6vectorIjE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %90)
  %92 = load i32, ptr %15, align 4, !tbaa !9
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds i32, ptr %91, i64 %93
  call void @_ZN6basisu6vectorIjE5eraseEPj(ptr noundef nonnull align 8 dereferenceable(16) %89, ptr noundef %94)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %120, %88
  %96 = load i32, ptr %19, align 4, !tbaa !9
  %97 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 3
  %98 = call noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %97)
  %99 = icmp ult i32 %96, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %123

101:                                              ; preds = %95
  %102 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 3
  %103 = load i32, ptr %19, align 4, !tbaa !9
  %104 = zext i32 %103 to i64
  %105 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %102, i64 noundef %104)
  %106 = load i32, ptr %105, align 4, !tbaa !9
  %107 = load i32, ptr %17, align 4, !tbaa !9
  %108 = load i32, ptr %11, align 4, !tbaa !9
  %109 = call noundef i32 @_ZNK6basisu23palette_index_reorderer8get_histEiii(ptr noundef nonnull align 8 dereferenceable(80) %21, i32 noundef %106, i32 noundef %107, i32 noundef %108)
  %110 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 1
  %111 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 3
  %112 = load i32, ptr %19, align 4, !tbaa !9
  %113 = zext i32 %112 to i64
  %114 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %111, i64 noundef %113)
  %115 = load i32, ptr %114, align 4, !tbaa !9
  %116 = zext i32 %115 to i64
  %117 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %110, i64 noundef %116)
  %118 = load i32, ptr %117, align 4, !tbaa !9
  %119 = add i32 %118, %109
  store i32 %119, ptr %117, align 4, !tbaa !9
  br label %120

120:                                              ; preds = %101
  %121 = load i32, ptr %19, align 4, !tbaa !9
  %122 = add i32 %121, 1
  store i32 %122, ptr %19, align 4, !tbaa !9
  br label %95, !llvm.loop !13

123:                                              ; preds = %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %61, !llvm.loop !15

124:                                              ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %125

125:                                              ; preds = %140, %124
  %126 = load i32, ptr %20, align 4, !tbaa !9
  %127 = load i32, ptr %11, align 4, !tbaa !9
  %128 = icmp ult i32 %126, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %125
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %143

130:                                              ; preds = %125
  %131 = load i32, ptr %20, align 4, !tbaa !9
  %132 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 4
  %133 = getelementptr inbounds %"class.basisu::palette_index_reorderer", ptr %21, i32 0, i32 2
  %134 = load i32, ptr %20, align 4, !tbaa !9
  %135 = zext i32 %134 to i64
  %136 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %133, i64 noundef %135)
  %137 = load i32, ptr %136, align 4, !tbaa !9
  %138 = zext i32 %137 to i64
  %139 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %132, i64 noundef %138)
  store i32 %131, ptr %139, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %130
  %141 = load i32, ptr %20, align 4, !tbaa !9
  %142 = add i32 %141, 1
  store i32 %142, ptr %20, align 4, !tbaa !9
  br label %125, !llvm.loop !16

143:                                              ; preds = %129, %55
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer5clearEv(ptr noundef nonnull align 8 dereferenceable(80)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i1 noundef zeroext) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE7reserveEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer12prepare_histEjjPKj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer12find_initialEj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer15find_next_entryERjRdPFfjjPvES3_f(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ptr noundef, float noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN6basisu23palette_index_reorderer9pick_sideEjjPFfjjPvES1_f(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, ptr noundef, ptr noundef, float noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE9push_backERKj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE6insertEPjRKj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6basisu6vectorIjE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE5eraseEPj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu23palette_index_reorderer8get_histEiii(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, i32 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 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 #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 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 = { noreturn nounwind }
attributes #6 = { 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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

@.str.4 = external hidden unnamed_addr constant [110 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [36 x i8], align 1
@__PRETTY_FUNCTION__._ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f = external hidden unnamed_addr constant [114 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [57 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %5, float noundef %6) local_unnamed_addr #3 align 2 {
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = icmp ne i32 %3, 0
  %12 = icmp ne i32 %1, 0
  %13 = and i1 %12, %11
  br i1 %13, label %15, label %14

14:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.26, ptr noundef nonnull @.str.4, i32 noundef 1281, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f) #6
  unreachable

15:                                               ; preds = %7
  %16 = fcmp oge float %6, 0.000000e+00
  %17 = fcmp ole float %6, 1.000000e+00
  %18 = and i1 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  tail call void @__assert_fail(ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.4, i32 noundef 1282, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6basisu23palette_index_reorderer4initEjPKjjPFfjjPvES3_f) #6
  unreachable

20:                                               ; preds = %15
  tail call void @_ZN6basisu23palette_index_reorderer5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %21 = getelementptr inbounds i8, ptr %0, i64 64
  %22 = zext i32 %3 to i64
  tail call void @_ZN6basisu6vectorIjE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(16) %21, i64 noundef %22, i1 noundef zeroext false)
  %23 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZN6basisu6vectorIjE7reserveEm(ptr noundef nonnull align 8 dereferenceable(16) %23, i64 noundef %22)
  %24 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZN6basisu6vectorIjE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(16) %24, i64 noundef %22, i1 noundef zeroext false)
  %25 = icmp ult i32 %1, 2
  br i1 %25, label %.loopexit, label %26

26:                                               ; preds = %20
  tail call void @_ZN6basisu23palette_index_reorderer12prepare_histEjjPKj(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %3, i32 noundef %1, ptr noundef %2)
  tail call void @_ZN6basisu23palette_index_reorderer12find_initialEj(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %3)
  %27 = getelementptr inbounds i8, ptr %0, i64 48
  %28 = tail call noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
  %.not35 = icmp eq i32 %28, 0
  br i1 %.not35, label %.preheader, label %.lr.ph37

.preheader:                                       ; preds = %._crit_edge, %26
  %umax = call i32 @llvm.umax.i32(i32 %3, i32 1)
  %wide.trip.count = zext i32 %umax to i64
  br label %58

.lr.ph37:                                         ; preds = %26, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #7
  call void @_ZN6basisu23palette_index_reorderer15find_next_entryERjRdPFfjjPvES3_f(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 4 dereferenceable(4) %8, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef %4, ptr noundef %5, float noundef %6)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #7
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = zext i32 %29 to i64
  %31 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %27, i64 noundef %30)
  %32 = load i32, ptr %31, align 4, !tbaa !5
  store i32 %32, ptr %10, align 4, !tbaa !5
  %33 = call noundef float @_ZN6basisu23palette_index_reorderer9pick_sideEjjPFfjjPvES1_f(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %3, i32 noundef %32, ptr noundef %4, ptr noundef %5, float noundef %6)
  %34 = fcmp ugt float %33, 0.000000e+00
  br i1 %34, label %36, label %35

35:                                               ; preds = %.lr.ph37
  call void @_ZN6basisu6vectorIjE9push_backERKj(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 4 dereferenceable(4) %10)
  br label %38

36:                                               ; preds = %.lr.ph37
  %37 = call noundef ptr @_ZN6basisu6vectorIjE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %23)
  call void @_ZN6basisu6vectorIjE6insertEPjRKj(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef %37, ptr noundef nonnull align 4 dereferenceable(4) %10)
  br label %38

38:                                               ; preds = %36, %35
  %39 = call noundef ptr @_ZN6basisu6vectorIjE5beginEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %39, i64 %41
  call void @_ZN6basisu6vectorIjE5eraseEPj(ptr noundef nonnull align 8 dereferenceable(16) %27, ptr noundef %42)
  %43 = call noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
  %.not39 = icmp eq i32 %43, 0
  br i1 %.not39, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #7
  %44 = call noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
  %.not = icmp eq i32 %44, 0
  br i1 %.not, label %.preheader, label %.lr.ph37, !llvm.loop !9

.lr.ph:                                           ; preds = %38, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %38 ]
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %27, i64 noundef %indvars.iv)
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !5
  %48 = call noundef i32 @_ZNK6basisu23palette_index_reorderer8get_histEiii(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %46, i32 noundef %47, i32 noundef %3)
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %27, i64 noundef %indvars.iv)
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = zext i32 %50 to i64
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %24, i64 noundef %51)
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = add i32 %53, %48
  store i32 %54, ptr %52, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %55 = call noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %27)
  %56 = zext i32 %55 to i64
  %57 = icmp ult i64 %indvars.iv.next, %56
  br i1 %57, label %.lr.ph, label %._crit_edge, !llvm.loop !11

58:                                               ; preds = %.preheader, %58
  %indvars.iv41 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next42, %58 ]
  %59 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %23, i64 noundef %indvars.iv41)
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = zext i32 %60 to i64
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6basisu6vectorIjEixEm(ptr noundef nonnull align 8 dereferenceable(16) %21, i64 noundef %61)
  %63 = trunc nuw i64 %indvars.iv41 to i32
  store i32 %63, ptr %62, align 4, !tbaa !5
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next42, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %58, !llvm.loop !12

.loopexit:                                        ; preds = %58, %20
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer5clearEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i1 noundef zeroext) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE7reserveEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer12prepare_histEjjPKj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer12find_initialEj(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu6vectorIjE4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6basisu23palette_index_reorderer15find_next_entryERjRdPFfjjPvES3_f(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, ptr noundef, float noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN6basisu23palette_index_reorderer9pick_sideEjjPFfjjPvES1_f(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, ptr noundef, ptr noundef, float noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE9push_backERKj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE6insertEPjRKj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN6basisu6vectorIjE5beginEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN6basisu6vectorIjE5eraseEPj(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6basisu23palette_index_reorderer8get_histEiii(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 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 #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 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { noreturn nounwind }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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