; LLVM IR from buresjan/optim_lbm :: nomad/ext/sgtelib/src (Surrogate_Ensemble)

; 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.SGTELIB::Matrix" = type { ptr, %"class.std::__cxx11::basic_string", i32, i32, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::allocator" = type { i8 }
%"class.SGTELIB::Surrogate" = type <{ ptr, ptr, %"class.SGTELIB::Surrogate_Parameters", i32, i32, i32, i32, i32, i32, i8, [7 x i8], ptr, ptr, ptr, ptr, %"class.std::__cxx11::list", %"class.std::map", double, %"class.std::basic_ofstream", i8, [7 x i8] }>
%"class.SGTELIB::Surrogate_Parameters" = type { ptr, i32, i32, i32, i32, i32, double, i32, double, i32, i32, i32, %"class.SGTELIB::Matrix", i32, i32, i32, double, double, double, double, %"class.SGTELIB::Matrix", i32, i32, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i32 }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" }
%"struct.std::__cxx11::_List_base<int, std::allocator<int>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<SGTELIB::metric_t, std::pair<const SGTELIB::metric_t, SGTELIB::Matrix>, std::_Select1st<std::pair<const SGTELIB::metric_t, SGTELIB::Matrix>>, std::less<SGTELIB::metric_t>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<SGTELIB::metric_t, std::pair<const SGTELIB::metric_t, SGTELIB::Matrix>, std::_Select1st<std::pair<const SGTELIB::metric_t, SGTELIB::Matrix>>, std::less<SGTELIB::metric_t>>::_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 }
%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.6 }
%union.anon.6 = type { i32 }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.SGTELIB::Surrogate_Ensemble" = type { %"class.SGTELIB::Surrogate.base", i32, i32, %"class.std::vector", ptr, ptr }
%"class.SGTELIB::Surrogate.base" = type <{ ptr, ptr, %"class.SGTELIB::Surrogate_Parameters", i32, i32, i32, i32, i32, i32, i8, [7 x i8], ptr, ptr, ptr, ptr, %"class.std::__cxx11::list", %"class.std::map", double, %"class.std::basic_ofstream", i8 }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<SGTELIB::Surrogate *, std::allocator<SGTELIB::Surrogate *>>::_Vector_impl" }
%"struct.std::_Vector_base<SGTELIB::Surrogate *, std::allocator<SGTELIB::Surrogate *>>::_Vector_impl" = type { %"struct.std::_Vector_base<SGTELIB::Surrogate *, std::allocator<SGTELIB::Surrogate *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<SGTELIB::Surrogate *, std::allocator<SGTELIB::Surrogate *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.12 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [59 x i8], align 1
@_ZTIN7SGTELIB9ExceptionE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.14 = external hidden unnamed_addr constant [10 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7SGTELIB20Surrogate_Parameters10set_weightERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef nonnull align 8 dereferenceable(56)) #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7SGTELIB20Surrogate_Parameters10get_weightEv(ptr dead_on_unwind noalias writable sret(%"class.SGTELIB::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(312)) #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7SGTELIB18Surrogate_Ensemble13build_privateEv(ptr noundef nonnull align 8 dereferenceable(1040) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca %"class.SGTELIB::Matrix", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %"class.std::__cxx11::basic_string", align 8
  %9 = alloca %"class.std::allocator", align 1
  %10 = alloca %"class.std::__cxx11::basic_string", align 8
  %11 = alloca %"class.std::allocator", align 1
  %12 = alloca i1, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %16 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 2
  %17 = call noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_weight_typeEv(ptr noundef nonnull align 8 dereferenceable(312) %16)
  switch i32 %17, label %52 [
    i32 0, label %18
    i32 1, label %19
    i32 2, label %20
    i32 3, label %21
    i32 4, label %22
    i32 5, label %23
    i32 7, label %24
    i32 8, label %25
    i32 6, label %26
    i32 9, label %26
  ]

18:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble19compute_W_by_selectEv(ptr noundef nonnull align 8 dereferenceable(1040) %15)
  br label %74

19:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %15, i32 noundef 2)
  br label %74

20:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %15, i32 noundef 3)
  br label %74

21:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %15, i32 noundef 4)
  br label %74

22:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %15, i32 noundef 5)
  br label %74

23:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %15, i32 noundef 6)
  br label %74

24:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble17compute_W_by_wta1Ev(ptr noundef nonnull align 8 dereferenceable(1040) %15)
  br label %74

25:                                               ; preds = %1
  call void @_ZN7SGTELIB18Surrogate_Ensemble17compute_W_by_wta3Ev(ptr noundef nonnull align 8 dereferenceable(1040) %15)
  br label %74

26:                                               ; preds = %1, %1
  call void @llvm.lifetime.start.p0(i64 56, ptr %5) #6
  %27 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 2
  call void @_ZNK7SGTELIB20Surrogate_Parameters10get_weightEv(ptr dead_on_unwind writable sret(%"class.SGTELIB::Matrix") align 8 %5, ptr noundef nonnull align 8 dereferenceable(312) %27)
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %45, %26
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = getelementptr inbounds %"class.SGTELIB::Surrogate_Ensemble", ptr %15, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %32 = icmp slt i32 %29, %31
  br i1 %32, label %33, label %48

33:                                               ; preds = %28
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = invoke noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble8is_readyEi(ptr noundef nonnull align 8 dereferenceable(1040) %15, i32 noundef %34)
          to label %36 unwind label %40

36:                                               ; preds = %33
  br i1 %35, label %44, label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %4, align 4, !tbaa !9
  invoke void @_ZN7SGTELIB6Matrix7set_rowEdi(ptr noundef nonnull align 8 dereferenceable(56) %5, double noundef 0.000000e+00, i32 noundef %38)
          to label %39 unwind label %40

39:                                               ; preds = %37
  br label %44

40:                                               ; preds = %49, %48, %37, %33
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %6, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %7, align 4
  call void @_ZN7SGTELIB6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %5) #6
  call void @llvm.lifetime.end.p0(i64 56, ptr %5) #6
  br label %104

44:                                               ; preds = %39, %36
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %4, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %4, align 4, !tbaa !9
  br label %28, !llvm.loop !53

48:                                               ; preds = %28
  invoke void @_ZN7SGTELIB6Matrix14normalize_colsEv(ptr noundef nonnull align 8 dereferenceable(56) %5)
          to label %49 unwind label %40

49:                                               ; preds = %48
  %50 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 2
  invoke void @_ZN7SGTELIB20Surrogate_Parameters10set_weightERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(312) %50, ptr noundef nonnull align 8 dereferenceable(56) %5)
          to label %51 unwind label %40

51:                                               ; preds = %49
  call void @_ZN7SGTELIB6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %5) #6
  call void @llvm.lifetime.end.p0(i64 56, ptr %5) #6
  br label %74

52:                                               ; preds = %1
  store i1 true, ptr %12, align 1
  %53 = call ptr @__cxa_allocate_exception(i64 112) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef @.str.12, ptr noundef nonnull align 1 dereferenceable(1) %9)
          to label %54 unwind label %57

54:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef @.str.13, ptr noundef nonnull align 1 dereferenceable(1) %11)
          to label %55 unwind label %61

55:                                               ; preds = %54
  invoke void @_ZN7SGTELIB9ExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiS8_(ptr noundef nonnull align 8 dereferenceable(112) %53, ptr noundef nonnull align 8 dereferenceable(32) %8, i32 noundef 279, ptr noundef nonnull align 8 dereferenceable(32) %10)
          to label %56 unwind label %65

56:                                               ; preds = %55
  store i1 false, ptr %12, align 1
  invoke void @__cxa_throw(ptr %53, ptr @_ZTIN7SGTELIB9ExceptionE, ptr @_ZN7SGTELIB9ExceptionD2Ev) #7
          to label %110 unwind label %65

57:                                               ; preds = %52
  %58 = landingpad { ptr, i32 }
          cleanup
  %59 = extractvalue { ptr, i32 } %58, 0
  store ptr %59, ptr %6, align 8
  %60 = extractvalue { ptr, i32 } %58, 1
  store i32 %60, ptr %7, align 4
  br label %70

61:                                               ; preds = %54
  %62 = landingpad { ptr, i32 }
          cleanup
  %63 = extractvalue { ptr, i32 } %62, 0
  store ptr %63, ptr %6, align 8
  %64 = extractvalue { ptr, i32 } %62, 1
  store i32 %64, ptr %7, align 4
  br label %69

65:                                               ; preds = %56, %55
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %6, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %7, align 4
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #6
  br label %69

69:                                               ; preds = %65, %61
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %11) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #6
  br label %70

70:                                               ; preds = %69, %57
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %9) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #6
  %71 = load i1, ptr %12, align 1
  br i1 %71, label %72, label %73

72:                                               ; preds = %70
  call void @__cxa_free_exception(ptr %53) #6
  br label %73

73:                                               ; preds = %72, %70
  br label %104

74:                                               ; preds = %51, %25, %24, %23, %22, %21, %20, %19, %18
  %75 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 18
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %75, ptr noundef @.str.14)
  %77 = call noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble19check_weight_vectorEv(ptr noundef nonnull align 8 dereferenceable(1040) %15)
  br i1 %77, label %78, label %80

78:                                               ; preds = %74
  %79 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 9
  store i8 0, ptr %79, align 8, !tbaa !55
  store i1 false, ptr %2, align 1
  store i32 1, ptr %13, align 4
  br label %102

80:                                               ; preds = %74
  call void @_ZN7SGTELIB18Surrogate_Ensemble21compute_active_modelsEv(ptr noundef nonnull align 8 dereferenceable(1040) %15)
  %81 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 9
  store i8 1, ptr %81, align 8, !tbaa !55
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %98, %80
  %83 = load i32, ptr %14, align 4, !tbaa !9
  %84 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 4
  %85 = load i32, ptr %84, align 4, !tbaa !56
  %86 = icmp slt i32 %83, %85
  br i1 %86, label %88, label %87

87:                                               ; preds = %82
  store i32 6, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %101

88:                                               ; preds = %82
  %89 = getelementptr inbounds %"class.SGTELIB::Surrogate", ptr %15, i32 0, i32 2
  %90 = call noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_metric_typeEv(ptr noundef nonnull align 8 dereferenceable(312) %89)
  %91 = load i32, ptr %14, align 4, !tbaa !9
  %92 = call noundef double @_ZN7SGTELIB9Surrogate10get_metricENS_8metric_tEi(ptr noundef nonnull align 8 dereferenceable(985) %15, i32 noundef %90, i32 noundef %91)
  %93 = getelementptr inbounds %"class.SGTELIB::Surrogate_Ensemble", ptr %15, i32 0, i32 5
  %94 = load ptr, ptr %93, align 8, !tbaa !57
  %95 = load i32, ptr %14, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds double, ptr %94, i64 %96
  store double %92, ptr %97, align 8, !tbaa !58
  br label %98

98:                                               ; preds = %88
  %99 = load i32, ptr %14, align 4, !tbaa !9
  %100 = add nsw i32 %99, 1
  store i32 %100, ptr %14, align 4, !tbaa !9
  br label %82, !llvm.loop !59

101:                                              ; preds = %87
  store i1 true, ptr %2, align 1
  store i32 1, ptr %13, align 4
  br label %102

102:                                              ; preds = %101, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  %103 = load i1, ptr %2, align 1
  ret i1 %103

104:                                              ; preds = %73, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %105

105:                                              ; preds = %104
  %106 = load ptr, ptr %6, align 8
  %107 = load i32, ptr %7, align 4
  %108 = insertvalue { ptr, i32 } poison, ptr %106, 0
  %109 = insertvalue { ptr, i32 } %108, i32 %107, 1
  resume { ptr, i32 } %109

110:                                              ; preds = %56
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_weight_typeEv(ptr noundef nonnull align 8 dereferenceable(312)) #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble8is_readyEi(ptr noundef nonnull align 8 dereferenceable(1040), i32 noundef) #2 align 2

declare void @_ZN7SGTELIB6Matrix7set_rowEdi(ptr noundef nonnull align 8 dereferenceable(56), double noundef, i32 noundef) #5

declare void @_ZN7SGTELIB6Matrix14normalize_colsEv(ptr noundef nonnull align 8 dereferenceable(56)) #5

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7SGTELIB9ExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiS8_(ptr noundef nonnull align 8 dereferenceable(112), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7SGTELIB9ExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #1 align 2

declare void @__cxa_throw(ptr, ptr, ptr)

declare void @__cxa_free_exception(ptr)

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble19check_weight_vectorEv(ptr noundef nonnull align 8 dereferenceable(1040)) #2 align 2

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

declare noundef double @_ZN7SGTELIB9Surrogate10get_metricENS_8metric_tEi(ptr noundef nonnull align 8 dereferenceable(985), i32 noundef, i32 noundef) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_metric_typeEv(ptr noundef nonnull align 8 dereferenceable(312)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "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 = { "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 = { nounwind }
attributes #7 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 988}
!12 = !{!"_ZTSN7SGTELIB18Surrogate_EnsembleE", !13, i64 0, !10, i64 988, !10, i64 992, !49, i64 1000, !6, i64 1024, !6, i64 1032}
!13 = !{!"_ZTSN7SGTELIB9SurrogateE", !6, i64 8, !14, i64 16, !10, i64 328, !10, i64 332, !10, i64 336, !10, i64 340, !10, i64 344, !10, i64 348, !27, i64 352, !6, i64 360, !6, i64 368, !6, i64 376, !6, i64 384, !28, i64 392, !33, i64 416, !18, i64 464, !41, i64 472, !27, i64 984}
!14 = !{!"_ZTSN7SGTELIB20Surrogate_ParametersE", !15, i64 8, !10, i64 12, !16, i64 16, !17, i64 20, !16, i64 24, !18, i64 32, !16, i64 40, !18, i64 48, !16, i64 56, !19, i64 60, !16, i64 64, !20, i64 72, !24, i64 128, !16, i64 132, !25, i64 136, !18, i64 144, !18, i64 152, !18, i64 160, !18, i64 168, !20, i64 176, !16, i64 232, !26, i64 236, !21, i64 240, !21, i64 272, !10, i64 304, !10, i64 308}
!15 = !{!"_ZTSN7SGTELIB7model_tE", !7, i64 0}
!16 = !{!"_ZTSN7SGTELIB14param_status_tE", !7, i64 0}
!17 = !{!"_ZTSN7SGTELIB8kernel_tE", !7, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!"_ZTSN7SGTELIB10distance_tE", !7, i64 0}
!20 = !{!"_ZTSN7SGTELIB6MatrixE", !21, i64 8, !10, i64 40, !10, i64 44, !6, i64 48}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !22, i64 0, !23, i64 8, !7, i64 16}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!23 = !{!"long", !7, i64 0}
!24 = !{!"_ZTSN7SGTELIB8weight_tE", !7, i64 0}
!25 = !{!"_ZTSN7SGTELIB13uncertainty_tE", !7, i64 0}
!26 = !{!"_ZTSN7SGTELIB8metric_tE", !7, i64 0}
!27 = !{!"bool", !7, i64 0}
!28 = !{!"_ZTSNSt7__cxx114listIiSaIiEEE", !29, i64 0}
!29 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEEE", !30, i64 0}
!30 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEE10_List_implE", !31, i64 0}
!31 = !{!"_ZTSNSt8__detail17_List_node_headerE", !32, i64 0, !23, i64 16}
!32 = !{!"_ZTSNSt8__detail15_List_node_baseE", !6, i64 0, !6, i64 8}
!33 = !{!"_ZTSSt3mapIN7SGTELIB8metric_tENS0_6MatrixESt4lessIS1_ESaISt4pairIKS1_S2_EEE", !34, i64 0}
!34 = !{!"_ZTSSt8_Rb_treeIN7SGTELIB8metric_tESt4pairIKS1_NS0_6MatrixEESt10_Select1stIS5_ESt4lessIS1_ESaIS5_EE", !35, i64 0}
!35 = !{!"_ZTSNSt8_Rb_treeIN7SGTELIB8metric_tESt4pairIKS1_NS0_6MatrixEESt10_Select1stIS5_ESt4lessIS1_ESaIS5_EE13_Rb_tree_implIS9_Lb1EEE", !36, i64 0, !38, i64 8}
!36 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN7SGTELIB8metric_tEEE", !37, i64 0}
!37 = !{!"_ZTSSt4lessIN7SGTELIB8metric_tEE"}
!38 = !{!"_ZTSSt15_Rb_tree_header", !39, i64 0, !23, i64 32}
!39 = !{!"_ZTSSt18_Rb_tree_node_base", !40, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!40 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!41 = !{!"_ZTSSt14basic_ofstreamIcSt11char_traitsIcEE", !42, i64 0, !43, i64 8}
!42 = !{!"_ZTSSo"}
!43 = !{!"_ZTSSt13basic_filebufIcSt11char_traitsIcEE", !44, i64 0, !7, i64 64, !46, i64 104, !47, i64 120, !48, i64 124, !48, i64 132, !48, i64 140, !6, i64 152, !23, i64 160, !27, i64 168, !27, i64 169, !27, i64 170, !7, i64 171, !6, i64 176, !6, i64 184, !27, i64 192, !6, i64 200, !6, i64 208, !23, i64 216, !6, i64 224, !6, i64 232}
!44 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !45, i64 56}
!45 = !{!"_ZTSSt6locale", !6, i64 0}
!46 = !{!"_ZTSSt12__basic_fileIcE", !6, i64 0, !27, i64 8}
!47 = !{!"_ZTSSt13_Ios_Openmode", !7, i64 0}
!48 = !{!"_ZTS11__mbstate_t", !10, i64 0, !7, i64 4}
!49 = !{!"_ZTSSt6vectorIPN7SGTELIB9SurrogateESaIS2_EE", !50, i64 0}
!50 = !{!"_ZTSSt12_Vector_baseIPN7SGTELIB9SurrogateESaIS2_EE", !51, i64 0}
!51 = !{!"_ZTSNSt12_Vector_baseIPN7SGTELIB9SurrogateESaIS2_EE12_Vector_implE", !52, i64 0}
!52 = !{!"_ZTSNSt12_Vector_baseIPN7SGTELIB9SurrogateESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!53 = distinct !{!53, !54}
!54 = !{!"llvm.loop.mustprogress"}
!55 = !{!13, !27, i64 352}
!56 = !{!13, !10, i64 332}
!57 = !{!12, !6, i64 1032}
!58 = !{!18, !18, i64 0}
!59 = distinct !{!59, !54}


; 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.SGTELIB::Matrix" = type { ptr, %"class.std::__cxx11::basic_string", i32, i32, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::allocator" = type { i8 }

@.str.12 = external hidden unnamed_addr constant [97 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [59 x i8], align 1
@_ZTIN7SGTELIB9ExceptionE = external dso_local constant { ptr, ptr, ptr }, align 8
@.str.14 = external hidden unnamed_addr constant [10 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7SGTELIB20Surrogate_Parameters10set_weightERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK7SGTELIB20Surrogate_Parameters10get_weightEv(ptr dead_on_unwind noalias writable sret(%"class.SGTELIB::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(312)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7SGTELIB18Surrogate_Ensemble13build_privateEv(ptr noundef nonnull align 8 dereferenceable(1040) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.SGTELIB::Matrix", align 8
  %3 = alloca %"class.std::__cxx11::basic_string", align 8
  %4 = alloca %"class.std::allocator", align 1
  %5 = alloca %"class.std::__cxx11::basic_string", align 8
  %6 = alloca %"class.std::allocator", align 1
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = tail call noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_weight_typeEv(ptr noundef nonnull align 8 dereferenceable(312) %7)
  switch i32 %8, label %31 [
    i32 0, label %9
    i32 1, label %10
    i32 2, label %11
    i32 3, label %12
    i32 4, label %13
    i32 5, label %14
    i32 7, label %15
    i32 8, label %16
    i32 6, label %17
    i32 9, label %17
  ]

9:                                                ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble19compute_W_by_selectEv(ptr noundef nonnull align 8 dereferenceable(1040) %0)
  br label %43

10:                                               ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %0, i32 noundef 2)
  br label %43

11:                                               ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %0, i32 noundef 3)
  br label %43

12:                                               ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %0, i32 noundef 4)
  br label %43

13:                                               ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %0, i32 noundef 5)
  br label %43

14:                                               ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble22compute_W_by_select_nbEi(ptr noundef nonnull align 8 dereferenceable(1040) %0, i32 noundef 6)
  br label %43

15:                                               ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble17compute_W_by_wta1Ev(ptr noundef nonnull align 8 dereferenceable(1040) %0)
  br label %43

16:                                               ; preds = %1
  tail call void @_ZN7SGTELIB18Surrogate_Ensemble17compute_W_by_wta3Ev(ptr noundef nonnull align 8 dereferenceable(1040) %0)
  br label %43

17:                                               ; preds = %1, %1
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %2) #6
  call void @_ZNK7SGTELIB20Surrogate_Parameters10get_weightEv(ptr dead_on_unwind nonnull writable sret(%"class.SGTELIB::Matrix") align 8 %2, ptr noundef nonnull align 8 dereferenceable(312) %7)
  %18 = getelementptr inbounds i8, ptr %0, i64 988
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %17, %25
  %.01928 = phi i32 [ %26, %25 ], [ 0, %17 ]
  %21 = invoke noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble8is_readyEi(ptr noundef nonnull align 8 dereferenceable(1040) %0, i32 noundef %.01928)
          to label %22 unwind label %.loopexit27

22:                                               ; preds = %.lr.ph
  br i1 %21, label %25, label %23

23:                                               ; preds = %22
  invoke void @_ZN7SGTELIB6Matrix7set_rowEdi(ptr noundef nonnull align 8 dereferenceable(56) %2, double noundef 0.000000e+00, i32 noundef %.01928)
          to label %25 unwind label %.loopexit27

.loopexit27:                                      ; preds = %.lr.ph, %23
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %24

.loopexit.split-lp:                               ; preds = %._crit_edge, %29
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          cleanup
  br label %24

24:                                               ; preds = %.loopexit.split-lp, %.loopexit27
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit27 ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  call void @_ZN7SGTELIB6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %2) #6
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %2) #6
  br label %64

25:                                               ; preds = %22, %23
  %26 = add nuw nsw i32 %.01928, 1
  %27 = load i32, ptr %18, align 4, !tbaa !5
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !51

._crit_edge:                                      ; preds = %25, %17
  invoke void @_ZN7SGTELIB6Matrix14normalize_colsEv(ptr noundef nonnull align 8 dereferenceable(56) %2)
          to label %29 unwind label %.loopexit.split-lp

29:                                               ; preds = %._crit_edge
  invoke void @_ZN7SGTELIB20Surrogate_Parameters10set_weightERKNS_6MatrixE(ptr noundef nonnull align 8 dereferenceable(312) %7, ptr noundef nonnull align 8 dereferenceable(56) %2)
          to label %30 unwind label %.loopexit.split-lp

30:                                               ; preds = %29
  call void @_ZN7SGTELIB6MatrixD1Ev(ptr noundef nonnull align 8 dereferenceable(56) %2) #6
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %2) #6
  br label %43

31:                                               ; preds = %1
  %32 = tail call ptr @__cxa_allocate_exception(i64 112) #6
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull @.str.12, ptr noundef nonnull align 1 dereferenceable(1) %4)
          to label %33 unwind label %.thread

33:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #6
  call void @_ZNSaIcEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  invoke void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IS3_EEPKcRKS3_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull @.str.13, ptr noundef nonnull align 1 dereferenceable(1) %6)
          to label %34 unwind label %37

34:                                               ; preds = %33
  invoke void @_ZN7SGTELIB9ExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiS8_(ptr noundef nonnull align 8 dereferenceable(112) %32, ptr noundef nonnull align 8 dereferenceable(32) %3, i32 noundef 279, ptr noundef nonnull align 8 dereferenceable(32) %5)
          to label %35 unwind label %39

35:                                               ; preds = %34
  invoke void @__cxa_throw(ptr nonnull %32, ptr nonnull @_ZTIN7SGTELIB9ExceptionE, ptr nonnull @_ZN7SGTELIB9ExceptionD2Ev) #7
          to label %65 unwind label %39

.thread:                                          ; preds = %31
  %36 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  br label %42

37:                                               ; preds = %33
  %38 = landingpad { ptr, i32 }
          cleanup
  br label %41

39:                                               ; preds = %35, %34
  %.012 = phi i1 [ false, %35 ], [ true, %34 ]
  %40 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #6
  br label %41

41:                                               ; preds = %37, %39
  %.pn = phi { ptr, i32 } [ %40, %39 ], [ %38, %37 ]
  %.1 = phi i1 [ %.012, %39 ], [ true, %37 ]
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %6) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #6
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #6
  call void @_ZNSt15__new_allocatorIcED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #6
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #6
  br i1 %.1, label %42, label %64

42:                                               ; preds = %.thread, %41
  %.pn.pn26 = phi { ptr, i32 } [ %36, %.thread ], [ %.pn, %41 ]
  call void @__cxa_free_exception(ptr %32) #6
  br label %64

43:                                               ; preds = %30, %16, %15, %14, %13, %12, %11, %10, %9
  %44 = getelementptr inbounds i8, ptr %0, i64 472
  %45 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef nonnull @.str.14)
  %46 = call noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble19check_weight_vectorEv(ptr noundef nonnull align 8 dereferenceable(1040) %0)
  br i1 %46, label %47, label %49

47:                                               ; preds = %43
  %48 = getelementptr inbounds i8, ptr %0, i64 352
  store i8 0, ptr %48, align 8, !tbaa !53
  br label %.loopexit

49:                                               ; preds = %43
  call void @_ZN7SGTELIB18Surrogate_Ensemble21compute_active_modelsEv(ptr noundef nonnull align 8 dereferenceable(1040) %0)
  %50 = getelementptr inbounds i8, ptr %0, i64 352
  store i8 1, ptr %50, align 8, !tbaa !53
  %51 = getelementptr inbounds i8, ptr %0, i64 332
  %52 = load i32, ptr %51, align 4, !tbaa !54
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %.lr.ph31, label %.loopexit

.lr.ph31:                                         ; preds = %49
  %54 = getelementptr inbounds i8, ptr %0, i64 1032
  br label %55

55:                                               ; preds = %.lr.ph31, %55
  %indvars.iv = phi i64 [ 0, %.lr.ph31 ], [ %indvars.iv.next, %55 ]
  %56 = call noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_metric_typeEv(ptr noundef nonnull align 8 dereferenceable(312) %7)
  %57 = trunc nuw nsw i64 %indvars.iv to i32
  %58 = call noundef double @_ZN7SGTELIB9Surrogate10get_metricENS_8metric_tEi(ptr noundef nonnull align 8 dereferenceable(985) %0, i32 noundef %56, i32 noundef %57)
  %59 = load ptr, ptr %54, align 8, !tbaa !55
  %60 = getelementptr inbounds double, ptr %59, i64 %indvars.iv
  store double %58, ptr %60, align 8, !tbaa !56
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %61 = load i32, ptr %51, align 4, !tbaa !54
  %62 = sext i32 %61 to i64
  %63 = icmp slt i64 %indvars.iv.next, %62
  br i1 %63, label %55, label %.loopexit, !llvm.loop !57

.loopexit:                                        ; preds = %55, %49, %47
  %.020 = xor i1 %46, true
  ret i1 %.020

64:                                               ; preds = %41, %42, %24
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn26, %42 ], [ %.pn, %41 ], [ %lpad.phi, %24 ]
  resume { ptr, i32 } %.pn.pn.pn

65:                                               ; preds = %35
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_weight_typeEv(ptr noundef nonnull align 8 dereferenceable(312)) local_unnamed_addr #1 align 2

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble8is_readyEi(ptr noundef nonnull align 8 dereferenceable(1040), i32 noundef) local_unnamed_addr #2 align 2

declare void @_ZN7SGTELIB6Matrix7set_rowEdi(ptr noundef nonnull align 8 dereferenceable(56), double noundef, i32 noundef) local_unnamed_addr #5

declare void @_ZN7SGTELIB6Matrix14normalize_colsEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #5

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7SGTELIB9ExceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiS8_(ptr noundef nonnull align 8 dereferenceable(112), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7SGTELIB9ExceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(112)) unnamed_addr #1 align 2

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

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7SGTELIB18Surrogate_Ensemble19check_weight_vectorEv(ptr noundef nonnull align 8 dereferenceable(1040)) local_unnamed_addr #2 align 2

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

declare noundef double @_ZN7SGTELIB9Surrogate10get_metricENS_8metric_tEi(ptr noundef nonnull align 8 dereferenceable(985), i32 noundef, i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK7SGTELIB20Surrogate_Parameters15get_metric_typeEv(ptr noundef nonnull align 8 dereferenceable(312)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "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 = { "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 = { nounwind }
attributes #7 = { 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, !13, i64 988}
!6 = !{!"_ZTSN7SGTELIB18Surrogate_EnsembleE", !7, i64 0, !13, i64 988, !13, i64 992, !47, i64 1000, !8, i64 1024, !8, i64 1032}
!7 = !{!"_ZTSN7SGTELIB9SurrogateE", !8, i64 8, !11, i64 16, !13, i64 328, !13, i64 332, !13, i64 336, !13, i64 340, !13, i64 344, !13, i64 348, !25, i64 352, !8, i64 360, !8, i64 368, !8, i64 376, !8, i64 384, !26, i64 392, !31, i64 416, !16, i64 464, !39, i64 472, !25, i64 984}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN7SGTELIB20Surrogate_ParametersE", !12, i64 8, !13, i64 12, !14, i64 16, !15, i64 20, !14, i64 24, !16, i64 32, !14, i64 40, !16, i64 48, !14, i64 56, !17, i64 60, !14, i64 64, !18, i64 72, !22, i64 128, !14, i64 132, !23, i64 136, !16, i64 144, !16, i64 152, !16, i64 160, !16, i64 168, !18, i64 176, !14, i64 232, !24, i64 236, !19, i64 240, !19, i64 272, !13, i64 304, !13, i64 308}
!12 = !{!"_ZTSN7SGTELIB7model_tE", !9, i64 0}
!13 = !{!"int", !9, i64 0}
!14 = !{!"_ZTSN7SGTELIB14param_status_tE", !9, i64 0}
!15 = !{!"_ZTSN7SGTELIB8kernel_tE", !9, i64 0}
!16 = !{!"double", !9, i64 0}
!17 = !{!"_ZTSN7SGTELIB10distance_tE", !9, i64 0}
!18 = !{!"_ZTSN7SGTELIB6MatrixE", !19, i64 8, !13, i64 40, !13, i64 44, !8, i64 48}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !21, i64 8, !9, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !8, i64 0}
!21 = !{!"long", !9, i64 0}
!22 = !{!"_ZTSN7SGTELIB8weight_tE", !9, i64 0}
!23 = !{!"_ZTSN7SGTELIB13uncertainty_tE", !9, i64 0}
!24 = !{!"_ZTSN7SGTELIB8metric_tE", !9, i64 0}
!25 = !{!"bool", !9, i64 0}
!26 = !{!"_ZTSNSt7__cxx114listIiSaIiEEE", !27, i64 0}
!27 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEEE", !28, i64 0}
!28 = !{!"_ZTSNSt7__cxx1110_List_baseIiSaIiEE10_List_implE", !29, i64 0}
!29 = !{!"_ZTSNSt8__detail17_List_node_headerE", !30, i64 0, !21, i64 16}
!30 = !{!"_ZTSNSt8__detail15_List_node_baseE", !8, i64 0, !8, i64 8}
!31 = !{!"_ZTSSt3mapIN7SGTELIB8metric_tENS0_6MatrixESt4lessIS1_ESaISt4pairIKS1_S2_EEE", !32, i64 0}
!32 = !{!"_ZTSSt8_Rb_treeIN7SGTELIB8metric_tESt4pairIKS1_NS0_6MatrixEESt10_Select1stIS5_ESt4lessIS1_ESaIS5_EE", !33, i64 0}
!33 = !{!"_ZTSNSt8_Rb_treeIN7SGTELIB8metric_tESt4pairIKS1_NS0_6MatrixEESt10_Select1stIS5_ESt4lessIS1_ESaIS5_EE13_Rb_tree_implIS9_Lb1EEE", !34, i64 0, !36, i64 8}
!34 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN7SGTELIB8metric_tEEE", !35, i64 0}
!35 = !{!"_ZTSSt4lessIN7SGTELIB8metric_tEE"}
!36 = !{!"_ZTSSt15_Rb_tree_header", !37, i64 0, !21, i64 32}
!37 = !{!"_ZTSSt18_Rb_tree_node_base", !38, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!38 = !{!"_ZTSSt14_Rb_tree_color", !9, i64 0}
!39 = !{!"_ZTSSt14basic_ofstreamIcSt11char_traitsIcEE", !40, i64 0, !41, i64 8}
!40 = !{!"_ZTSSo"}
!41 = !{!"_ZTSSt13basic_filebufIcSt11char_traitsIcEE", !42, i64 0, !9, i64 64, !44, i64 104, !45, i64 120, !46, i64 124, !46, i64 132, !46, i64 140, !8, i64 152, !21, i64 160, !25, i64 168, !25, i64 169, !25, i64 170, !9, i64 171, !8, i64 176, !8, i64 184, !25, i64 192, !8, i64 200, !8, i64 208, !21, i64 216, !8, i64 224, !8, i64 232}
!42 = !{!"_ZTSSt15basic_streambufIcSt11char_traitsIcEE", !8, i64 8, !8, i64 16, !8, i64 24, !8, i64 32, !8, i64 40, !8, i64 48, !43, i64 56}
!43 = !{!"_ZTSSt6locale", !8, i64 0}
!44 = !{!"_ZTSSt12__basic_fileIcE", !8, i64 0, !25, i64 8}
!45 = !{!"_ZTSSt13_Ios_Openmode", !9, i64 0}
!46 = !{!"_ZTS11__mbstate_t", !13, i64 0, !9, i64 4}
!47 = !{!"_ZTSSt6vectorIPN7SGTELIB9SurrogateESaIS2_EE", !48, i64 0}
!48 = !{!"_ZTSSt12_Vector_baseIPN7SGTELIB9SurrogateESaIS2_EE", !49, i64 0}
!49 = !{!"_ZTSNSt12_Vector_baseIPN7SGTELIB9SurrogateESaIS2_EE12_Vector_implE", !50, i64 0}
!50 = !{!"_ZTSNSt12_Vector_baseIPN7SGTELIB9SurrogateESaIS2_EE17_Vector_impl_dataE", !8, i64 0, !8, i64 8, !8, i64 16}
!51 = distinct !{!51, !52}
!52 = !{!"llvm.loop.mustprogress"}
!53 = !{!7, !25, i64 352}
!54 = !{!7, !13, i64 332}
!55 = !{!6, !8, i64 1032}
!56 = !{!16, !16, i64 0}
!57 = distinct !{!57, !52}


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