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

; 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::Powersystem" = type { %"class.std::__cxx11::basic_string", double, double, i32, %"class.std::vector", %"class.std::vector.3", %"class.std::vector.8", %"class.std::vector.13", %"class.boost::bimaps::bimap", %"class.boost::bimaps::bimap", %"class.boost::bimaps::bimap", %"class.boost::bimaps::bimap", %"class.std::vector.65", %"class.std::vector.65", %"class.std::vector.65" }
%"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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<elabtsaot::Bus, std::allocator<elabtsaot::Bus>>::_Vector_impl" }
%"struct.std::_Vector_base<elabtsaot::Bus, std::allocator<elabtsaot::Bus>>::_Vector_impl" = type { %"struct.std::_Vector_base<elabtsaot::Bus, std::allocator<elabtsaot::Bus>>::_Vector_impl_data" }
%"struct.std::_Vector_base<elabtsaot::Bus, std::allocator<elabtsaot::Bus>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<elabtsaot::Branch, std::allocator<elabtsaot::Branch>>::_Vector_impl" }
%"struct.std::_Vector_base<elabtsaot::Branch, std::allocator<elabtsaot::Branch>>::_Vector_impl" = type { %"struct.std::_Vector_base<elabtsaot::Branch, std::allocator<elabtsaot::Branch>>::_Vector_impl_data" }
%"struct.std::_Vector_base<elabtsaot::Branch, std::allocator<elabtsaot::Branch>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.8" = type { %"struct.std::_Vector_base.9" }
%"struct.std::_Vector_base.9" = type { %"struct.std::_Vector_base<elabtsaot::Generator, std::allocator<elabtsaot::Generator>>::_Vector_impl" }
%"struct.std::_Vector_base<elabtsaot::Generator, std::allocator<elabtsaot::Generator>>::_Vector_impl" = type { %"struct.std::_Vector_base<elabtsaot::Generator, std::allocator<elabtsaot::Generator>>::_Vector_impl_data" }
%"struct.std::_Vector_base<elabtsaot::Generator, std::allocator<elabtsaot::Generator>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.13" = type { %"struct.std::_Vector_base.14" }
%"struct.std::_Vector_base.14" = type { %"struct.std::_Vector_base<elabtsaot::Load, std::allocator<elabtsaot::Load>>::_Vector_impl" }
%"struct.std::_Vector_base<elabtsaot::Load, std::allocator<elabtsaot::Load>>::_Vector_impl" = type { %"struct.std::_Vector_base<elabtsaot::Load, std::allocator<elabtsaot::Load>>::_Vector_impl_data" }
%"struct.std::_Vector_base<elabtsaot::Load, std::allocator<elabtsaot::Load>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.boost::bimaps::bimap" = type { %"class.boost::bimaps::views::set_view", %"class.boost::multi_index::multi_index_container", %"class.boost::bimaps::views::map_view", %"class.boost::bimaps::views::map_view.42" }
%"class.boost::bimaps::views::set_view" = type { %"class.boost::bimaps::container_adaptor::set_adaptor" }
%"class.boost::bimaps::container_adaptor::set_adaptor" = type { %"class.boost::bimaps::container_adaptor::ordered_associative_container_adaptor" }
%"class.boost::bimaps::container_adaptor::ordered_associative_container_adaptor" = type { %"class.boost::bimaps::container_adaptor::associative_container_adaptor" }
%"class.boost::bimaps::container_adaptor::associative_container_adaptor" = type { %"class.boost::bimaps::container_adaptor::container_adaptor" }
%"class.boost::bimaps::container_adaptor::container_adaptor" = type { %"struct.boost::bimaps::container_adaptor::detail::data_with_functor_bag" }
%"struct.boost::bimaps::container_adaptor::detail::data_with_functor_bag" = type { [8 x i8], ptr }
%"class.boost::multi_index::multi_index_container" = type { [8 x i8], %"struct.boost::multi_index::detail::header_holder", [8 x i8], i64 }
%"struct.boost::multi_index::detail::header_holder" = type { ptr }
%"class.boost::bimaps::views::map_view" = type { %"class.boost::bimaps::container_adaptor::map_adaptor" }
%"class.boost::bimaps::container_adaptor::map_adaptor" = type { %"class.boost::bimaps::container_adaptor::ordered_associative_container_adaptor.25" }
%"class.boost::bimaps::container_adaptor::ordered_associative_container_adaptor.25" = type { %"class.boost::bimaps::container_adaptor::associative_container_adaptor.26" }
%"class.boost::bimaps::container_adaptor::associative_container_adaptor.26" = type { %"class.boost::bimaps::container_adaptor::container_adaptor.27" }
%"class.boost::bimaps::container_adaptor::container_adaptor.27" = type { %"struct.boost::bimaps::container_adaptor::detail::data_with_functor_bag.28" }
%"struct.boost::bimaps::container_adaptor::detail::data_with_functor_bag.28" = type { ptr }
%"class.boost::bimaps::views::map_view.42" = type { %"class.boost::bimaps::container_adaptor::map_adaptor.43" }
%"class.boost::bimaps::container_adaptor::map_adaptor.43" = type { %"class.boost::bimaps::container_adaptor::ordered_associative_container_adaptor.44" }
%"class.boost::bimaps::container_adaptor::ordered_associative_container_adaptor.44" = type { %"class.boost::bimaps::container_adaptor::associative_container_adaptor.45" }
%"class.boost::bimaps::container_adaptor::associative_container_adaptor.45" = type { %"class.boost::bimaps::container_adaptor::container_adaptor.46" }
%"class.boost::bimaps::container_adaptor::container_adaptor.46" = type { %"struct.boost::bimaps::container_adaptor::detail::data_with_functor_bag.47" }
%"struct.boost::bimaps::container_adaptor::detail::data_with_functor_bag.47" = type { ptr }
%"class.std::vector.65" = type { %"struct.std::_Vector_base.66" }
%"struct.std::_Vector_base.66" = type { %"struct.std::_Vector_base<std::set<unsigned long>, std::allocator<std::set<unsigned long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::set<unsigned long>, std::allocator<std::set<unsigned long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::set<unsigned long>, std::allocator<std::set<unsigned long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::set<unsigned long>, std::allocator<std::set<unsigned long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.elabtsaot::Branch" = type { i32, i8, i32, i32, double, double, double, double, double, double, double, double }

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK9elabtsaot11Powersystem15getMaxXTimesTapEv(ptr noundef nonnull align 8 dereferenceable(480) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca i64, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store double -1.000000e+00, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !11
  br label %9

9:                                                ; preds = %37, %1
  %10 = load i64, ptr %4, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.elabtsaot::Powersystem", ptr %8, i32 0, i32 5
  %12 = call noundef i64 @_ZNKSt6vectorIN9elabtsaot6BranchESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #2
  %13 = icmp ne i64 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %40

15:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %16 = getelementptr inbounds %"class.elabtsaot::Powersystem", ptr %8, i32 0, i32 5
  %17 = load i64, ptr %4, align 8, !tbaa !11
  %18 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNKSt6vectorIN9elabtsaot6BranchESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17) #2
  store ptr %18, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.elabtsaot::Branch", ptr %19, i32 0, i32 10
  %21 = load double, ptr %20, align 8, !tbaa !13
  store double %21, ptr %6, align 8, !tbaa !9
  %22 = load double, ptr %6, align 8, !tbaa !9
  %23 = fcmp oeq double %22, 0.000000e+00
  br i1 %23, label %24, label %25

24:                                               ; preds = %15
  store double 1.000000e+00, ptr %6, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %24, %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.elabtsaot::Branch", ptr %26, i32 0, i32 5
  %28 = load double, ptr %27, align 8, !tbaa !17
  %29 = load double, ptr %6, align 8, !tbaa !9
  %30 = fmul double %28, %29
  store double %30, ptr %7, align 8, !tbaa !9
  %31 = load double, ptr %7, align 8, !tbaa !9
  %32 = load double, ptr %3, align 8, !tbaa !9
  %33 = fcmp ogt double %31, %32
  br i1 %33, label %34, label %36

34:                                               ; preds = %25
  %35 = load double, ptr %7, align 8, !tbaa !9
  store double %35, ptr %3, align 8, !tbaa !9
  br label %36

36:                                               ; preds = %34, %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  br label %37

37:                                               ; preds = %36
  %38 = load i64, ptr %4, align 8, !tbaa !11
  %39 = add i64 %38, 1
  store i64 %39, ptr %4, align 8, !tbaa !11
  br label %9, !llvm.loop !18

40:                                               ; preds = %14
  %41 = load double, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret double %41
}

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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 64}
!14 = !{!"_ZTSN9elabtsaot6BranchE", !15, i64 0, !16, i64 4, !15, i64 8, !15, i64 12, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!15 = !{!"int", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!14, !10, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN9elabtsaot6BranchESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK9elabtsaot11Powersystem15getMaxXTimesTapEv(ptr noundef nonnull align 8 dereferenceable(480) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  %3 = tail call noundef i64 @_ZNKSt6vectorIN9elabtsaot6BranchESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %.not15 = icmp eq i64 %3, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.0.lcssa = phi double [ -1.000000e+00, %1 ], [ %.1, %.lr.ph ]
  ret double %.0.lcssa

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.017 = phi double [ %.1, %.lr.ph ], [ -1.000000e+00, %1 ]
  %.01216 = phi i64 [ %12, %.lr.ph ], [ 0, %1 ]
  %4 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNKSt6vectorIN9elabtsaot6BranchESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.01216) #1
  %5 = getelementptr inbounds i8, ptr %4, i64 64
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fcmp oeq double %6, 0.000000e+00
  %.011 = select i1 %7, double 1.000000e+00, double %6
  %8 = getelementptr inbounds i8, ptr %4, i64 24
  %9 = load double, ptr %8, align 8, !tbaa !12
  %10 = fmul double %9, %.011
  %11 = fcmp ogt double %10, %.017
  %.1 = select i1 %11, double %10, double %.017
  %12 = add i64 %.01216, 1
  %13 = tail call noundef i64 @_ZNKSt6vectorIN9elabtsaot6BranchESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #1
  %.not = icmp eq i64 %12, %13
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13
}

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 = { 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, !11, i64 64}
!6 = !{!"_ZTSN9elabtsaot6BranchE", !7, i64 0, !10, i64 4, !7, i64 8, !7, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !11, i64 24}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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