; LLVM IR from thekyria/elabtsaot2 :: powersystem/pwsmodel/pwsmodel.ll (ZN9elabtsaot8PwsModel10remElementEij)

; 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.boost::void_ptr_iterator" = type { %"class.__gnu_cxx::__normal_iterator" }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"class.elabtsaot::PwsModel" = type { ptr, ptr, %"class.boost::ptr_vector", %"class.boost::ptr_vector", %"class.boost::ptr_vector", %"class.boost::ptr_vector" }
%"class.boost::ptr_vector" = type { %"class.boost::ptr_sequence_adapter" }
%"class.boost::ptr_sequence_adapter" = type { %"class.boost::ptr_container_detail::reversible_ptr_container" }
%"class.boost::ptr_container_detail::reversible_ptr_container" = type { %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl" }
%"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl" = type { %"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<void *, std::allocator<void *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK9elabtsaot8PwsModel16getElement_mdlIdEij(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef, i32 noundef) #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 uwtable
define dso_local noundef i32 @_ZN9elabtsaot8PwsModel10remElementEij(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"class.boost::void_ptr_iterator", align 8
  %9 = alloca %"class.boost::void_ptr_iterator", align 8
  %10 = alloca %"class.boost::void_ptr_iterator", align 8
  %11 = alloca %"class.boost::void_ptr_iterator", align 8
  %12 = alloca %"class.boost::void_ptr_iterator", align 8
  %13 = alloca %"class.boost::void_ptr_iterator", align 8
  %14 = alloca %"class.boost::void_ptr_iterator", align 8
  %15 = alloca %"class.boost::void_ptr_iterator", align 8
  %16 = alloca %"class.boost::void_ptr_iterator", align 8
  %17 = alloca %"class.boost::void_ptr_iterator", align 8
  %18 = alloca %"class.boost::void_ptr_iterator", align 8
  %19 = alloca %"class.boost::void_ptr_iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %20 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = call noundef i32 @_ZNK9elabtsaot8PwsModel16getElement_mdlIdEij(ptr noundef nonnull align 8 dereferenceable(112) %20, i32 noundef %21, i32 noundef %22)
  store i32 %23, ptr %7, align 4, !tbaa !9
  %24 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %24, label %105 [
    i32 0, label %25
    i32 1, label %45
    i32 2, label %65
    i32 3, label %85
  ]

25:                                               ; preds = %3
  %26 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 2
  %27 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 2
  %28 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %27)
  %29 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %9, i32 0, i32 0
  %30 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %29, i32 0, i32 0
  store ptr %28, ptr %30, align 8
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %9, i32 0, i32 0
  %34 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8
  %36 = call ptr @_ZN5boostplIN9__gnu_cxx17__normal_iteratorIPPvSt6vectorIS3_SaIS3_EEEEN9elabtsaot15PwsModelElementEEENS_17void_ptr_iteratorIT_T0_EESE_NSE_15difference_typeE(ptr %35, i64 noundef %32)
  %37 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %8, i32 0, i32 0
  %38 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %37, i32 0, i32 0
  store ptr %36, ptr %38, align 8
  %39 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %8, i32 0, i32 0
  %40 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8
  %42 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5eraseENS_17void_ptr_iteratorIN9__gnu_cxx17__normal_iteratorIPS6_S8_EES4_EE(ptr noundef nonnull align 8 dereferenceable(24) %26, ptr %41)
  %43 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %10, i32 0, i32 0
  %44 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %43, i32 0, i32 0
  store ptr %42, ptr %44, align 8
  br label %105

45:                                               ; preds = %3
  %46 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 3
  %47 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 3
  %48 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %47)
  %49 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %12, i32 0, i32 0
  %50 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %49, i32 0, i32 0
  store ptr %48, ptr %50, align 8
  %51 = load i32, ptr %7, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %12, i32 0, i32 0
  %54 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8
  %56 = call ptr @_ZN5boostplIN9__gnu_cxx17__normal_iteratorIPPvSt6vectorIS3_SaIS3_EEEEN9elabtsaot15PwsModelElementEEENS_17void_ptr_iteratorIT_T0_EESE_NSE_15difference_typeE(ptr %55, i64 noundef %52)
  %57 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %11, i32 0, i32 0
  %58 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %57, i32 0, i32 0
  store ptr %56, ptr %58, align 8
  %59 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %11, i32 0, i32 0
  %60 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8
  %62 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5eraseENS_17void_ptr_iteratorIN9__gnu_cxx17__normal_iteratorIPS6_S8_EES4_EE(ptr noundef nonnull align 8 dereferenceable(24) %46, ptr %61)
  %63 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %13, i32 0, i32 0
  %64 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %63, i32 0, i32 0
  store ptr %62, ptr %64, align 8
  br label %105

65:                                               ; preds = %3
  %66 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 4
  %67 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 4
  %68 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %67)
  %69 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %15, i32 0, i32 0
  %70 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %69, i32 0, i32 0
  store ptr %68, ptr %70, align 8
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %15, i32 0, i32 0
  %74 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8
  %76 = call ptr @_ZN5boostplIN9__gnu_cxx17__normal_iteratorIPPvSt6vectorIS3_SaIS3_EEEEN9elabtsaot15PwsModelElementEEENS_17void_ptr_iteratorIT_T0_EESE_NSE_15difference_typeE(ptr %75, i64 noundef %72)
  %77 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %14, i32 0, i32 0
  %78 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %77, i32 0, i32 0
  store ptr %76, ptr %78, align 8
  %79 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %14, i32 0, i32 0
  %80 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8
  %82 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5eraseENS_17void_ptr_iteratorIN9__gnu_cxx17__normal_iteratorIPS6_S8_EES4_EE(ptr noundef nonnull align 8 dereferenceable(24) %66, ptr %81)
  %83 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %16, i32 0, i32 0
  %84 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %83, i32 0, i32 0
  store ptr %82, ptr %84, align 8
  br label %105

85:                                               ; preds = %3
  %86 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 5
  %87 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %20, i32 0, i32 5
  %88 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %87)
  %89 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %18, i32 0, i32 0
  %90 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %89, i32 0, i32 0
  store ptr %88, ptr %90, align 8
  %91 = load i32, ptr %7, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %18, i32 0, i32 0
  %94 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8
  %96 = call ptr @_ZN5boostplIN9__gnu_cxx17__normal_iteratorIPPvSt6vectorIS3_SaIS3_EEEEN9elabtsaot15PwsModelElementEEENS_17void_ptr_iteratorIT_T0_EESE_NSE_15difference_typeE(ptr %95, i64 noundef %92)
  %97 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %17, i32 0, i32 0
  %98 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %97, i32 0, i32 0
  store ptr %96, ptr %98, align 8
  %99 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %17, i32 0, i32 0
  %100 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8
  %102 = call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5eraseENS_17void_ptr_iteratorIN9__gnu_cxx17__normal_iteratorIPS6_S8_EES4_EE(ptr noundef nonnull align 8 dereferenceable(24) %86, ptr %101)
  %103 = getelementptr inbounds %"class.boost::void_ptr_iterator", ptr %19, i32 0, i32 0
  %104 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %103, i32 0, i32 0
  store ptr %102, ptr %104, align 8
  br label %105

105:                                              ; preds = %85, %65, %45, %25, %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 0
}

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5eraseENS_17void_ptr_iteratorIN9__gnu_cxx17__normal_iteratorIPS6_S8_EES4_EE(ptr noundef nonnull align 8 dereferenceable(24), ptr) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZN5boostplIN9__gnu_cxx17__normal_iteratorIPPvSt6vectorIS3_SaIS3_EEEEN9elabtsaot15PwsModelElementEEENS_17void_ptr_iteratorIT_T0_EESE_NSE_15difference_typeE(ptr, i64 noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9elabtsaot8PwsModel10remElementEij(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 {
  %4 = tail call noundef i32 @_ZNK9elabtsaot8PwsModel16getElement_mdlIdEij(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i32 noundef %2)
  %5 = icmp ult i32 %1, 4
  br i1 %5, label %switch.lookup, label %13

switch.lookup:                                    ; preds = %3
  %narrow = mul nuw nsw i32 %1, 24
  %6 = zext nneg i32 %narrow to i64
  %7 = getelementptr inbounds i8, ptr %0, i64 %6
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = tail call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %10 = sext i32 %4 to i64
  %11 = tail call ptr @_ZN5boostplIN9__gnu_cxx17__normal_iteratorIPPvSt6vectorIS3_SaIS3_EEEEN9elabtsaot15PwsModelElementEEENS_17void_ptr_iteratorIT_T0_EESE_NSE_15difference_typeE(ptr %9, i64 noundef %10)
  %12 = tail call ptr @_ZN5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE5eraseENS_17void_ptr_iteratorIN9__gnu_cxx17__normal_iteratorIPS6_S8_EES4_EE(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr %11)
  br label %13

13:                                               ; preds = %3, %switch.lookup
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local ptr @_ZN5boostplIN9__gnu_cxx17__normal_iteratorIPPvSt6vectorIS3_SaIS3_EEEEN9elabtsaot15PwsModelElementEEENS_17void_ptr_iteratorIT_T0_EESE_NSE_15difference_typeE(ptr, i64 noundef) local_unnamed_addr #1

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

attributes #0 = { 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 #1 = { 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" }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass