; LLVM IR from Optiroc/SuperFamiconv :: src/Image.ll (ZN3sfc5ImageC2ERKS0_RKNS_10SubpaletteE)

; 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.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"struct.sfc::rgba_color" = type { i8, i8, i8, i8 }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.sfc::Image" = type { i32, i32, i32, i32, %"class.std::vector", %"class.std::vector", %"class.std::vector.0", %"class.std::set" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTISt13runtime_error = external constant ptr
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIjSt4lessIjESaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) 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

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 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 nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3sfc5Image9rgba_dataEv(ptr dead_on_unwind noalias writable sret(%"class.std::vector.0") align 8, ptr noundef nonnull align 8 dereferenceable(136)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIjSaIjEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt3setIjSt4lessIjESaIjEEC2IN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjS2_EEEEET_SB_(ptr noundef nonnull align 8 dereferenceable(48), ptr, ptr) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3setIjSt4lessIjESaIjEEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIjSt4lessIjESaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIjSaIjEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3sfc10rgba_colorC2Ej(ptr noundef nonnull align 1 dereferenceable(4), i32 noundef) unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3sfc5ImageC2ERKS0_RKNS_10SubpaletteE(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef nonnull align 8 dereferenceable(136) %1, ptr noundef nonnull align 8 dereferenceable(80) %2) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %16 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %17 = alloca %"struct.sfc::rgba_color", align 1
  %18 = alloca %"class.std::vector.0", align 8
  %19 = alloca %"class.std::set", align 8
  %20 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %21 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %22 = load ptr, ptr %4, align 8
  %23 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call noundef i32 @_ZNK3sfc5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(136) %24)
  store i32 %25, ptr %23, align 8, !tbaa !9
  %26 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 1
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call noundef i32 @_ZNK3sfc5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(136) %27)
  store i32 %28, ptr %26, align 4, !tbaa !29
  %29 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 4
  call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %29) #7
  %30 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 5
  call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %30) #7
  %31 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 6
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @_ZNK3sfc10Subpalette17normalized_colorsEv(ptr dead_on_unwind writable sret(%"class.std::vector.0") align 8 %31, ptr noundef nonnull align 8 dereferenceable(80) %32)
          to label %33 unwind label %40

33:                                               ; preds = %3
  %34 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 7
  call void @_ZNSt3setIjSt4lessIjESaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %34) #7
  %35 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 6
  %36 = call noundef zeroext i1 @_ZNKSt6vectorIjSaIjEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %35) #7
  br i1 %36, label %37, label %52

37:                                               ; preds = %33
  %38 = call ptr @__cxa_allocate_exception(i64 16) #7
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %38, ptr noundef @.str)
          to label %39 unwind label %44

39:                                               ; preds = %37
  invoke void @__cxa_throw(ptr %38, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #8
          to label %200 unwind label %48

40:                                               ; preds = %3
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %7, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %8, align 4
  br label %194

44:                                               ; preds = %37
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %7, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %8, align 4
  call void @__cxa_free_exception(ptr %38) #7
  br label %193

48:                                               ; preds = %39
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %7, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %8, align 4
  br label %193

52:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  %53 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 1
  %56 = load i32, ptr %55, align 4, !tbaa !29
  %57 = mul i32 %54, %56
  store i32 %57, ptr %9, align 4, !tbaa !30
  %58 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 5
  %59 = load i32, ptr %9, align 4, !tbaa !30
  %60 = zext i32 %59 to i64
  invoke void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %58, i64 noundef %60)
          to label %61 unwind label %72

61:                                               ; preds = %52
  %62 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 4
  %63 = load i32, ptr %9, align 4, !tbaa !30
  %64 = mul i32 %63, 4
  %65 = zext i32 %64 to i64
  invoke void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %65)
          to label %66 unwind label %72

66:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  store i32 0, ptr %10, align 4, !tbaa !30
  br label %67

67:                                               ; preds = %164, %66
  %68 = load i32, ptr %10, align 4, !tbaa !30
  %69 = load i32, ptr %9, align 4, !tbaa !30
  %70 = icmp ult i32 %68, %69
  br i1 %70, label %76, label %71

71:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %168

72:                                               ; preds = %61, %52
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %7, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %8, align 4
  br label %192

76:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load i32, ptr %10, align 4, !tbaa !30
  %79 = invoke noundef i32 @_ZNK3sfc5Image13rgba_color_atEj(ptr noundef nonnull align 8 dereferenceable(136) %77, i32 noundef %78)
          to label %80 unwind label %100

80:                                               ; preds = %76
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = invoke noundef i32 @_ZNK3sfc10Subpalette4modeEv(ptr noundef nonnull align 8 dereferenceable(80) %81)
          to label %83 unwind label %100

83:                                               ; preds = %80
  %84 = invoke noundef i32 @_ZN3sfc12reduce_colorEjNS_4ModeE(i32 noundef %79, i32 noundef %82)
          to label %85 unwind label %100

85:                                               ; preds = %83
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = invoke noundef i32 @_ZNK3sfc10Subpalette4modeEv(ptr noundef nonnull align 8 dereferenceable(80) %86)
          to label %88 unwind label %100

88:                                               ; preds = %85
  %89 = invoke noundef i32 @_ZN3sfc15normalize_colorEjNS_4ModeE(i32 noundef %84, i32 noundef %87)
          to label %90 unwind label %100

90:                                               ; preds = %88
  store i32 %89, ptr %11, align 4, !tbaa !30
  %91 = load i32, ptr %11, align 4, !tbaa !30
  %92 = icmp eq i32 %91, 0
  br i1 %92, label %93, label %104

93:                                               ; preds = %90
  %94 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 5
  %95 = load i32, ptr %10, align 4, !tbaa !30
  %96 = zext i32 %95 to i64
  %97 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %94, i64 noundef %96) #7
  store i8 0, ptr %97, align 1, !tbaa !31
  %98 = load i32, ptr %10, align 4, !tbaa !30
  invoke void @_ZN3sfc5Image9set_pixelEjj(ptr noundef nonnull align 8 dereferenceable(136) %22, i32 noundef 0, i32 noundef %98)
          to label %99 unwind label %100

99:                                               ; preds = %93
  br label %163

100:                                              ; preds = %93, %88, %85, %83, %80, %76
  %101 = landingpad { ptr, i32 }
          cleanup
  %102 = extractvalue { ptr, i32 } %101, 0
  store ptr %102, ptr %7, align 8
  %103 = extractvalue { ptr, i32 } %101, 1
  store i32 %103, ptr %8, align 4
  br label %167

104:                                              ; preds = %90
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %105 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 6
  %106 = call ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %105) #7
  %107 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %106, ptr %107, align 8
  %108 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 6
  %109 = call ptr @_ZNSt6vectorIjSaIjEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %108) #7
  %110 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %15, i32 0, i32 0
  store ptr %109, ptr %110, align 8
  %111 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8
  %113 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %15, i32 0, i32 0
  %114 = load ptr, ptr %113, align 8
  %115 = invoke ptr @_ZSt4findIN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjSaIjEEEEjET_S7_S7_RKT0_(ptr %112, ptr %114, ptr noundef nonnull align 4 dereferenceable(4) %11)
          to label %116 unwind label %142

116:                                              ; preds = %104
  %117 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %115, ptr %117, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %118 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 6
  %119 = call ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %118) #7
  %120 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %16, i32 0, i32 0
  store ptr %119, ptr %120, align 8
  %121 = call noundef i64 @_ZN9__gnu_cxxmiIPjSt6vectorIjSaIjEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  store i64 %121, ptr %12, align 8, !tbaa !32
  %122 = load i64, ptr %12, align 8, !tbaa !32
  %123 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 6
  %124 = call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %123) #7
  %125 = icmp ult i64 %122, %124
  br i1 %125, label %126, label %150

126:                                              ; preds = %116
  %127 = load i64, ptr %12, align 8, !tbaa !32
  %128 = trunc i64 %127 to i8
  %129 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 5
  %130 = load i32, ptr %10, align 4, !tbaa !30
  %131 = zext i32 %130 to i64
  %132 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %129, i64 noundef %131) #7
  store i8 %128, ptr %132, align 1, !tbaa !31
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  %133 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 6
  %134 = load i64, ptr %12, align 8, !tbaa !32
  %135 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %133, i64 noundef %134) #7
  %136 = load i32, ptr %135, align 4, !tbaa !30
  invoke void @_ZN3sfc10rgba_colorC2Ej(ptr noundef nonnull align 1 dereferenceable(4) %17, i32 noundef %136)
          to label %137 unwind label %146

137:                                              ; preds = %126
  %138 = invoke noundef i32 @_ZN3sfc10rgba_colorcvjEv(ptr noundef nonnull align 1 dereferenceable(4) %17)
          to label %139 unwind label %146

139:                                              ; preds = %137
  %140 = load i32, ptr %10, align 4, !tbaa !30
  invoke void @_ZN3sfc5Image9set_pixelEjj(ptr noundef nonnull align 8 dereferenceable(136) %22, i32 noundef %138, i32 noundef %140)
          to label %141 unwind label %146

141:                                              ; preds = %139
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %161

142:                                              ; preds = %104
  %143 = landingpad { ptr, i32 }
          cleanup
  %144 = extractvalue { ptr, i32 } %143, 0
  store ptr %144, ptr %7, align 8
  %145 = extractvalue { ptr, i32 } %143, 1
  store i32 %145, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %162

146:                                              ; preds = %139, %137, %126
  %147 = landingpad { ptr, i32 }
          cleanup
  %148 = extractvalue { ptr, i32 } %147, 0
  store ptr %148, ptr %7, align 8
  %149 = extractvalue { ptr, i32 } %147, 1
  store i32 %149, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %162

150:                                              ; preds = %116
  %151 = call ptr @__cxa_allocate_exception(i64 16) #7
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %151, ptr noundef @.str.1)
          to label %152 unwind label %153

152:                                              ; preds = %150
  invoke void @__cxa_throw(ptr %151, ptr @_ZTISt13runtime_error, ptr @_ZNSt13runtime_errorD1Ev) #8
          to label %200 unwind label %157

153:                                              ; preds = %150
  %154 = landingpad { ptr, i32 }
          cleanup
  %155 = extractvalue { ptr, i32 } %154, 0
  store ptr %155, ptr %7, align 8
  %156 = extractvalue { ptr, i32 } %154, 1
  store i32 %156, ptr %8, align 4
  call void @__cxa_free_exception(ptr %151) #7
  br label %162

157:                                              ; preds = %152
  %158 = landingpad { ptr, i32 }
          cleanup
  %159 = extractvalue { ptr, i32 } %158, 0
  store ptr %159, ptr %7, align 8
  %160 = extractvalue { ptr, i32 } %158, 1
  store i32 %160, ptr %8, align 4
  br label %162

161:                                              ; preds = %141
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %163

162:                                              ; preds = %157, %153, %146, %142
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %167

163:                                              ; preds = %161, %99
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %10, align 4, !tbaa !30
  %166 = add i32 %165, 1
  store i32 %166, ptr %10, align 4, !tbaa !30
  br label %67, !llvm.loop !33

167:                                              ; preds = %162, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %192

168:                                              ; preds = %71
  %169 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 3
  store i32 0, ptr %169, align 4, !tbaa !35
  %170 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 2
  store i32 0, ptr %170, align 8, !tbaa !36
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #7
  invoke void @_ZNK3sfc5Image9rgba_dataEv(ptr dead_on_unwind writable sret(%"class.std::vector.0") align 8 %18, ptr noundef nonnull align 8 dereferenceable(136) %22)
          to label %171 unwind label %183

171:                                              ; preds = %168
  call void @llvm.lifetime.start.p0(i64 48, ptr %19) #7
  %172 = call ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #7
  %173 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %20, i32 0, i32 0
  store ptr %172, ptr %173, align 8
  %174 = call ptr @_ZNSt6vectorIjSaIjEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #7
  %175 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  store ptr %174, ptr %175, align 8
  %176 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %20, i32 0, i32 0
  %177 = load ptr, ptr %176, align 8
  %178 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %21, i32 0, i32 0
  %179 = load ptr, ptr %178, align 8
  invoke void @_ZNSt3setIjSt4lessIjESaIjEEC2IN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjS2_EEEEET_SB_(ptr noundef nonnull align 8 dereferenceable(48) %19, ptr %177, ptr %179)
          to label %180 unwind label %187

180:                                              ; preds = %171
  %181 = getelementptr inbounds %"struct.sfc::Image", ptr %22, i32 0, i32 7
  %182 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3setIjSt4lessIjESaIjEEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(48) %181, ptr noundef nonnull align 8 dereferenceable(48) %19) #7
  call void @_ZNSt3setIjSt4lessIjESaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %19) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %19) #7
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %18) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  ret void

183:                                              ; preds = %168
  %184 = landingpad { ptr, i32 }
          cleanup
  %185 = extractvalue { ptr, i32 } %184, 0
  store ptr %185, ptr %7, align 8
  %186 = extractvalue { ptr, i32 } %184, 1
  store i32 %186, ptr %8, align 4
  br label %191

187:                                              ; preds = %171
  %188 = landingpad { ptr, i32 }
          cleanup
  %189 = extractvalue { ptr, i32 } %188, 0
  store ptr %189, ptr %7, align 8
  %190 = extractvalue { ptr, i32 } %188, 1
  store i32 %190, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 48, ptr %19) #7
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %18) #7
  br label %191

191:                                              ; preds = %187, %183
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #7
  br label %192

192:                                              ; preds = %191, %167, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %193

193:                                              ; preds = %192, %48, %44
  call void @_ZNSt3setIjSt4lessIjESaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %34) #7
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %31) #7
  br label %194

194:                                              ; preds = %193, %40
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %30) #7
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %29) #7
  br label %195

195:                                              ; preds = %194
  %196 = load ptr, ptr %7, align 8
  %197 = load i32, ptr %8, align 4
  %198 = insertvalue { ptr, i32 } poison, ptr %196, 0
  %199 = insertvalue { ptr, i32 } %198, i32 %197, 1
  resume { ptr, i32 } %199

200:                                              ; preds = %152, %39
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3sfc5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(136)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3sfc5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(136)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3sfc10Subpalette17normalized_colorsEv(ptr dead_on_unwind noalias writable sret(%"class.std::vector.0") align 8, ptr noundef nonnull align 8 dereferenceable(80)) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3sfc15normalize_colorEjNS_4ModeE(i32 noundef, i32 noundef) #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3sfc12reduce_colorEjNS_4ModeE(i32 noundef, i32 noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3sfc5Image13rgba_color_atEj(ptr noundef nonnull align 8 dereferenceable(136), i32 noundef) #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3sfc5Image9set_pixelEjj(ptr noundef nonnull align 8 dereferenceable(136), i32 noundef, i32 noundef) #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN9__gnu_cxxmiIPjSt6vectorIjSaIjEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #6

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4findIN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjSaIjEEEEjET_S7_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) #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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "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"="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 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { noreturn }

!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, !11, i64 0}
!10 = !{!"_ZTSN3sfc5ImageE", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 40, !16, i64 64, !20, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSSt6vectorIhSaIhEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"_ZTSSt6vectorIjSaIjEE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIjSaIjEE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTSSt3setIjSt4lessIjESaIjEE", !21, i64 0}
!21 = !{!"_ZTSSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE", !22, i64 0}
!22 = !{!"_ZTSNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE13_Rb_tree_implIS3_Lb1EEE", !23, i64 0, !25, i64 8}
!23 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIjEE", !24, i64 0}
!24 = !{!"_ZTSSt4lessIjE"}
!25 = !{!"_ZTSSt15_Rb_tree_header", !26, i64 0, !28, i64 32}
!26 = !{!"_ZTSSt18_Rb_tree_node_base", !27, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!27 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!28 = !{!"long", !7, i64 0}
!29 = !{!10, !11, i64 4}
!30 = !{!11, !11, i64 0}
!31 = !{!7, !7, i64 0}
!32 = !{!28, !28, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}
!35 = !{!10, !11, i64 12}
!36 = !{!10, !11, 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.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"struct.sfc::rgba_color" = type { i8, i8, i8, i8 }
%"class.std::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<unsigned int, unsigned int, std::_Identity<unsigned int>, std::less<unsigned int>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }

@_ZTISt13runtime_error = external constant ptr
@.str = external hidden unnamed_addr constant [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIjSt4lessIjESaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) 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

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt13runtime_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 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 nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3sfc5Image9rgba_dataEv(ptr dead_on_unwind noalias writable sret(%"class.std::vector.0") align 8, ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIjSaIjEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt3setIjSt4lessIjESaIjEEC2IN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjS2_EEEEET_SB_(ptr noundef nonnull align 8 dereferenceable(48), ptr, ptr) unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3setIjSt4lessIjESaIjEEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIjSt4lessIjESaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorIjSaIjEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3sfc10rgba_colorC2Ej(ptr noundef nonnull align 1 dereferenceable(4), i32 noundef) unnamed_addr #0 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3sfc5ImageC2ERKS0_RKNS_10SubpaletteE(ptr noundef nonnull align 8 dereferenceable(136) %0, ptr noundef nonnull align 8 dereferenceable(136) %1, ptr noundef nonnull align 8 dereferenceable(80) %2) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca i32, align 4
  %5 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"struct.sfc::rgba_color", align 1
  %8 = alloca %"class.std::vector.0", align 8
  %9 = alloca %"class.std::set", align 8
  %10 = tail call noundef i32 @_ZNK3sfc5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(136) %1)
  store i32 %10, ptr %0, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 4
  %12 = tail call noundef i32 @_ZNK3sfc5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(136) %1)
  store i32 %12, ptr %11, align 4, !tbaa !28
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %13) #7
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @_ZNSt6vectorIhSaIhEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %14) #7
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  invoke void @_ZNK3sfc10Subpalette17normalized_colorsEv(ptr dead_on_unwind nonnull writable sret(%"class.std::vector.0") align 8 %15, ptr noundef nonnull align 8 dereferenceable(80) %2)
          to label %16 unwind label %22

16:                                               ; preds = %3
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @_ZNSt3setIjSt4lessIjESaIjEEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %17) #7
  %18 = tail call noundef zeroext i1 @_ZNKSt6vectorIjSaIjEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #7
  br i1 %18, label %19, label %28

19:                                               ; preds = %16
  %20 = tail call ptr @__cxa_allocate_exception(i64 16) #7
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull @.str)
          to label %21 unwind label %24

21:                                               ; preds = %19
  invoke void @__cxa_throw(ptr nonnull %20, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #8
          to label %94 unwind label %26

22:                                               ; preds = %3
  %23 = landingpad { ptr, i32 }
          cleanup
  br label %93

24:                                               ; preds = %19
  %25 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %20) #7
  br label %92

26:                                               ; preds = %21
  %27 = landingpad { ptr, i32 }
          cleanup
  br label %92

28:                                               ; preds = %16
  %29 = load i32, ptr %0, align 8, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !28
  %31 = mul i32 %30, %29
  %32 = zext i32 %31 to i64
  invoke void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %32)
          to label %33 unwind label %38

33:                                               ; preds = %28
  %34 = shl i32 %31, 2
  %35 = zext i32 %34 to i64
  invoke void @_ZNSt6vectorIhSaIhEE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %35)
          to label %.preheader unwind label %38

.preheader:                                       ; preds = %33
  %.not = icmp eq i32 %31, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %80, %.preheader
  %36 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 0, ptr %36, align 4, !tbaa !29
  %37 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 0, ptr %37, align 8, !tbaa !30
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #7
  invoke void @_ZNK3sfc5Image9rgba_dataEv(ptr dead_on_unwind nonnull writable sret(%"class.std::vector.0") align 8 %8, ptr noundef nonnull align 8 dereferenceable(136) %0)
          to label %82 unwind label %87

38:                                               ; preds = %33, %28
  %39 = landingpad { ptr, i32 }
          cleanup
  br label %92

.lr.ph:                                           ; preds = %.preheader, %80
  %indvars.iv = phi i64 [ %indvars.iv.next, %80 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  %40 = trunc nuw i64 %indvars.iv to i32
  %41 = call noundef i32 @_ZNK3sfc5Image13rgba_color_atEj(ptr noundef nonnull align 8 dereferenceable(136) %1, i32 noundef %40)
  %42 = call noundef i32 @_ZNK3sfc10Subpalette4modeEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %43 = invoke noundef i32 @_ZN3sfc12reduce_colorEjNS_4ModeE(i32 noundef %41, i32 noundef %42)
          to label %44 unwind label %51

44:                                               ; preds = %.lr.ph
  %45 = call noundef i32 @_ZNK3sfc10Subpalette4modeEv(ptr noundef nonnull align 8 dereferenceable(80) %2)
  %46 = invoke noundef i32 @_ZN3sfc15normalize_colorEjNS_4ModeE(i32 noundef %43, i32 noundef %45)
          to label %47 unwind label %51

47:                                               ; preds = %44
  store i32 %46, ptr %4, align 4, !tbaa !31
  %48 = icmp eq i32 %46, 0
  br i1 %48, label %49, label %53

49:                                               ; preds = %47
  %50 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %indvars.iv) #7
  store i8 0, ptr %50, align 1, !tbaa !32
  invoke void @_ZN3sfc5Image9set_pixelEjj(ptr noundef nonnull align 8 dereferenceable(136) %0, i32 noundef 0, i32 noundef %40)
          to label %80 unwind label %51

51:                                               ; preds = %49, %44, %.lr.ph
  %52 = landingpad { ptr, i32 }
          cleanup
  br label %81

53:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %54 = call ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #7
  %55 = call ptr @_ZNSt6vectorIjSaIjEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #7
  %56 = invoke ptr @_ZSt4findIN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjSaIjEEEEjET_S7_S7_RKT0_(ptr %54, ptr %55, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %57 unwind label %69

57:                                               ; preds = %53
  store ptr %56, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  %58 = call ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #7
  store ptr %58, ptr %6, align 8
  %59 = call noundef i64 @_ZN9__gnu_cxxmiIPjSt6vectorIjSaIjEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  %60 = call noundef i64 @_ZNKSt6vectorIjSaIjEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #7
  %61 = icmp ult i64 %59, %60
  br i1 %61, label %62, label %73

62:                                               ; preds = %57
  %63 = trunc i64 %59 to i8
  %64 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt6vectorIhSaIhEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %indvars.iv) #7
  store i8 %63, ptr %64, align 1, !tbaa !32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  %65 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIjSaIjEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %59) #7
  %66 = load i32, ptr %65, align 4, !tbaa !31
  call void @_ZN3sfc10rgba_colorC2Ej(ptr noundef nonnull align 1 dereferenceable(4) %7, i32 noundef %66)
  %67 = call noundef i32 @_ZN3sfc10rgba_colorcvjEv(ptr noundef nonnull align 1 dereferenceable(4) %7)
  invoke void @_ZN3sfc5Image9set_pixelEjj(ptr noundef nonnull align 8 dereferenceable(136) %0, i32 noundef %67, i32 noundef %40)
          to label %68 unwind label %71

68:                                               ; preds = %62
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  br label %80

69:                                               ; preds = %53
  %70 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  br label %81

71:                                               ; preds = %62
  %72 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  br label %81

73:                                               ; preds = %57
  %74 = call ptr @__cxa_allocate_exception(i64 16) #7
  invoke void @_ZNSt13runtime_errorC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %74, ptr noundef nonnull @.str.1)
          to label %75 unwind label %76

75:                                               ; preds = %73
  invoke void @__cxa_throw(ptr nonnull %74, ptr nonnull @_ZTISt13runtime_error, ptr nonnull @_ZNSt13runtime_errorD1Ev) #8
          to label %94 unwind label %78

76:                                               ; preds = %73
  %77 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %74) #7
  br label %81

78:                                               ; preds = %75
  %79 = landingpad { ptr, i32 }
          cleanup
  br label %81

80:                                               ; preds = %49, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %32
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !33

81:                                               ; preds = %69, %71, %76, %78, %51
  %.pn35 = phi { ptr, i32 } [ %52, %51 ], [ %72, %71 ], [ %79, %78 ], [ %77, %76 ], [ %70, %69 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  br label %92

82:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %9) #7
  %83 = call ptr @_ZNSt6vectorIjSaIjEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #7
  %84 = call ptr @_ZNSt6vectorIjSaIjEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %8) #7
  invoke void @_ZNSt3setIjSt4lessIjESaIjEEC2IN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjS2_EEEEET_SB_(ptr noundef nonnull align 8 dereferenceable(48) %9, ptr %83, ptr %84)
          to label %85 unwind label %89

85:                                               ; preds = %82
  %86 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNSt3setIjSt4lessIjESaIjEEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(48) %17, ptr noundef nonnull align 8 dereferenceable(48) %9) #7
  call void @_ZNSt3setIjSt4lessIjESaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %9) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %9) #7
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #7
  ret void

87:                                               ; preds = %._crit_edge
  %88 = landingpad { ptr, i32 }
          cleanup
  br label %91

89:                                               ; preds = %82
  %90 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %9) #7
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #7
  br label %91

91:                                               ; preds = %89, %87
  %.pn = phi { ptr, i32 } [ %90, %89 ], [ %88, %87 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #7
  br label %92

92:                                               ; preds = %38, %81, %91, %26, %24
  %.pn38 = phi { ptr, i32 } [ %27, %26 ], [ %25, %24 ], [ %.pn35, %81 ], [ %.pn, %91 ], [ %39, %38 ]
  call void @_ZNSt3setIjSt4lessIjESaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %17) #7
  call void @_ZNSt6vectorIjSaIjEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %15) #7
  br label %93

93:                                               ; preds = %92, %22
  %.pn38.pn = phi { ptr, i32 } [ %.pn38, %92 ], [ %23, %22 ]
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %14) #7
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %13) #7
  resume { ptr, i32 } %.pn38.pn

94:                                               ; preds = %75, %21
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3sfc5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3sfc5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(136)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3sfc10Subpalette17normalized_colorsEv(ptr dead_on_unwind noalias writable sret(%"class.std::vector.0") align 8, ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3sfc15normalize_colorEjNS_4ModeE(i32 noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN3sfc12reduce_colorEjNS_4ModeE(i32 noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK3sfc5Image13rgba_color_atEj(ptr noundef nonnull align 8 dereferenceable(136), i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3sfc5Image9set_pixelEjj(ptr noundef nonnull align 8 dereferenceable(136), i32 noundef, i32 noundef) local_unnamed_addr #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN9__gnu_cxxmiIPjSt6vectorIjSaIjEEEENS_17__normal_iteratorIT_T0_E15difference_typeERKS8_SB_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #6

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZSt4findIN9__gnu_cxx17__normal_iteratorIPjSt6vectorIjSaIjEEEEjET_S7_S7_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(4)) 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "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"="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 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { noreturn }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTSN3sfc5ImageE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 40, !15, i64 64, !19, i64 88}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIhSaIhEE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTSSt6vectorIjSaIjEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIjSaIjEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIjSaIjEE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!19 = !{!"_ZTSSt3setIjSt4lessIjESaIjEE", !20, i64 0}
!20 = !{!"_ZTSSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE", !21, i64 0}
!21 = !{!"_ZTSNSt8_Rb_treeIjjSt9_IdentityIjESt4lessIjESaIjEE13_Rb_tree_implIS3_Lb1EEE", !22, i64 0, !24, i64 8}
!22 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIjEE", !23, i64 0}
!23 = !{!"_ZTSSt4lessIjE"}
!24 = !{!"_ZTSSt15_Rb_tree_header", !25, i64 0, !27, i64 32}
!25 = !{!"_ZTSSt18_Rb_tree_node_base", !26, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!26 = !{!"_ZTSSt14_Rb_tree_color", !8, i64 0}
!27 = !{!"long", !8, i64 0}
!28 = !{!6, !7, i64 4}
!29 = !{!6, !7, i64 12}
!30 = !{!6, !7, i64 8}
!31 = !{!7, !7, i64 0}
!32 = !{!8, !8, i64 0}
!33 = distinct !{!33, !34}
!34 = !{!"llvm.loop.mustprogress"}


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