; LLVM IR from thekyria/elabtsaot2 :: gui/powersystem_editor/powersystem_model (pwsschematicmodel)

; 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.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 }

@_ZTIN9elabtsaot15PwsModelElementE = external dso_local constant { ptr, ptr }, align 8
@_ZTIN9elabtsaot24PwsSchematicModelElementE = external dso_local constant { ptr, ptr, ptr }, align 8

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i64 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !11
  %8 = load ptr, ptr %5, align 8
  %9 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %9, label %74 [
    i32 0, label %10
    i32 1, label %26
    i32 2, label %42
    i32 3, label %58
  ]

10:                                               ; preds = %3
  %11 = load i64, ptr %7, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 2
  %13 = call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12)
  %14 = icmp ult i64 %11, %13
  br i1 %14, label %15, label %25

15:                                               ; preds = %10
  %16 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 2
  %17 = load i64, ptr %7, align 8, !tbaa !11
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN5boost20ptr_sequence_adapterIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS4_EENS_20heap_clone_allocatorEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17)
  %19 = icmp eq ptr %18, null
  br i1 %19, label %22, label %20

20:                                               ; preds = %15
  %21 = call ptr @__dynamic_cast(ptr %18, ptr @_ZTIN9elabtsaot15PwsModelElementE, ptr @_ZTIN9elabtsaot24PwsSchematicModelElementE, i64 0) #3
  br label %23

22:                                               ; preds = %15
  br label %23

23:                                               ; preds = %22, %20
  %24 = phi ptr [ %21, %20 ], [ null, %22 ]
  store ptr %24, ptr %4, align 8
  br label %75

25:                                               ; preds = %10
  store ptr null, ptr %4, align 8
  br label %75

26:                                               ; preds = %3
  %27 = load i64, ptr %7, align 8, !tbaa !11
  %28 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 3
  %29 = call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %28)
  %30 = icmp ult i64 %27, %29
  br i1 %30, label %31, label %41

31:                                               ; preds = %26
  %32 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 3
  %33 = load i64, ptr %7, align 8, !tbaa !11
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN5boost20ptr_sequence_adapterIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS4_EENS_20heap_clone_allocatorEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %33)
  %35 = icmp eq ptr %34, null
  br i1 %35, label %38, label %36

36:                                               ; preds = %31
  %37 = call ptr @__dynamic_cast(ptr %34, ptr @_ZTIN9elabtsaot15PwsModelElementE, ptr @_ZTIN9elabtsaot24PwsSchematicModelElementE, i64 0) #3
  br label %39

38:                                               ; preds = %31
  br label %39

39:                                               ; preds = %38, %36
  %40 = phi ptr [ %37, %36 ], [ null, %38 ]
  store ptr %40, ptr %4, align 8
  br label %75

41:                                               ; preds = %26
  store ptr null, ptr %4, align 8
  br label %75

42:                                               ; preds = %3
  %43 = load i64, ptr %7, align 8, !tbaa !11
  %44 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 4
  %45 = call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %44)
  %46 = icmp ult i64 %43, %45
  br i1 %46, label %47, label %57

47:                                               ; preds = %42
  %48 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 4
  %49 = load i64, ptr %7, align 8, !tbaa !11
  %50 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN5boost20ptr_sequence_adapterIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS4_EENS_20heap_clone_allocatorEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %48, i64 noundef %49)
  %51 = icmp eq ptr %50, null
  br i1 %51, label %54, label %52

52:                                               ; preds = %47
  %53 = call ptr @__dynamic_cast(ptr %50, ptr @_ZTIN9elabtsaot15PwsModelElementE, ptr @_ZTIN9elabtsaot24PwsSchematicModelElementE, i64 0) #3
  br label %55

54:                                               ; preds = %47
  br label %55

55:                                               ; preds = %54, %52
  %56 = phi ptr [ %53, %52 ], [ null, %54 ]
  store ptr %56, ptr %4, align 8
  br label %75

57:                                               ; preds = %42
  store ptr null, ptr %4, align 8
  br label %75

58:                                               ; preds = %3
  %59 = load i64, ptr %7, align 8, !tbaa !11
  %60 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 5
  %61 = call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %60)
  %62 = icmp ult i64 %59, %61
  br i1 %62, label %63, label %73

63:                                               ; preds = %58
  %64 = getelementptr inbounds %"class.elabtsaot::PwsModel", ptr %8, i32 0, i32 5
  %65 = load i64, ptr %7, align 8, !tbaa !11
  %66 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN5boost20ptr_sequence_adapterIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS4_EENS_20heap_clone_allocatorEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %64, i64 noundef %65)
  %67 = icmp eq ptr %66, null
  br i1 %67, label %70, label %68

68:                                               ; preds = %63
  %69 = call ptr @__dynamic_cast(ptr %66, ptr @_ZTIN9elabtsaot15PwsModelElementE, ptr @_ZTIN9elabtsaot24PwsSchematicModelElementE, i64 0) #3
  br label %71

70:                                               ; preds = %63
  br label %71

71:                                               ; preds = %70, %68
  %72 = phi ptr [ %69, %68 ], [ null, %70 ]
  store ptr %72, ptr %4, align 8
  br label %75

73:                                               ; preds = %58
  store ptr null, ptr %4, align 8
  br label %75

74:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %75

75:                                               ; preds = %74, %73, %71, %57, %55, %41, %39, %25, %23
  %76 = load ptr, ptr %4, align 8
  ret ptr %76
}

; Function Attrs: nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) #2

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 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 = { nounwind willreturn memory(read) }
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}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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"

@_ZTIN9elabtsaot15PwsModelElementE = external dso_local constant { ptr, ptr }, align 8
@_ZTIN9elabtsaot24PwsSchematicModelElementE = external dso_local constant { ptr, ptr, ptr }, align 8

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN9elabtsaot17PwsSchematicModel14elementByIndexEim(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i64 noundef %2) local_unnamed_addr #1 align 2 {
  switch i32 %1, label %22 [
    i32 0, label %4
    i32 1, label %8
    i32 2, label %12
    i32 3, label %16
  ]

4:                                                ; preds = %3
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = tail call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %7 = icmp ugt i64 %6, %2
  br i1 %7, label %.sink.split, label %22

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = tail call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9)
  %11 = icmp ugt i64 %10, %2
  br i1 %11, label %.sink.split, label %22

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  %14 = tail call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13)
  %15 = icmp ugt i64 %14, %2
  br i1 %15, label %.sink.split, label %22

16:                                               ; preds = %3
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  %18 = tail call noundef i64 @_ZNK5boost20ptr_container_detail24reversible_ptr_containerINS0_15sequence_configIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS6_EEEENS_20heap_clone_allocatorEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  %19 = icmp ugt i64 %18, %2
  br i1 %19, label %.sink.split, label %22

.sink.split:                                      ; preds = %16, %12, %8, %4
  %.sink11 = phi ptr [ %5, %4 ], [ %9, %8 ], [ %13, %12 ], [ %17, %16 ]
  %20 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZN5boost20ptr_sequence_adapterIN9elabtsaot15PwsModelElementESt6vectorIPvSaIS4_EENS_20heap_clone_allocatorEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %.sink11, i64 noundef %2)
  %21 = tail call ptr @__dynamic_cast(ptr nonnull %20, ptr nonnull @_ZTIN9elabtsaot15PwsModelElementE, ptr nonnull @_ZTIN9elabtsaot24PwsSchematicModelElementE, i64 0) #3
  br label %22

22:                                               ; preds = %.sink.split, %3, %16, %12, %8, %4
  %.0 = phi ptr [ null, %4 ], [ null, %8 ], [ null, %12 ], [ null, %16 ], [ null, %3 ], [ %21, %.sink.split ]
  ret ptr %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) local_unnamed_addr #2

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 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 nofree nounwind willreturn memory(read) }
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)"}


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