; LLVM IR from thekyria/elabtsaot2 :: ss_analysis (ssutils)

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

declare noundef i64 @_ZNK9elabtsaot11Powersystem14getBranchCountEv(ptr noundef nonnull align 8 dereferenceable(480)) #1

declare noundef ptr @_ZNK9elabtsaot11Powersystem9getBranchEm(ptr noundef nonnull align 8 dereferenceable(480), i64 noundef) #1

; 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 void @_ZN9elabtsaot7ssutils12buildBranchBERKNS_11PowersystemERN5boost7numeric5ublas6vectorIdNS6_15unbounded_arrayIdSaIdEEEEE(ptr noundef nonnull align 8 dereferenceable(480) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call noundef i64 @_ZNK9elabtsaot11Powersystem14getBranchCountEv(ptr noundef nonnull align 8 dereferenceable(480) %9)
  store i64 %10, ptr %5, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = load i64, ptr %5, align 8, !tbaa !9
  call void @_ZN5boost7numeric5ublas6vectorIdNS1_15unbounded_arrayIdSaIdEEEE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %12, i1 noundef zeroext true)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %38, %2
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = icmp ne i64 %14, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %41

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

27:                                               ; preds = %18
  store double 1.000000e+00, ptr %8, align 8, !tbaa !16
  br label %28

28:                                               ; preds = %27, %18
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.elabtsaot::Branch", ptr %29, i32 0, i32 5
  %31 = load double, ptr %30, align 8, !tbaa !17
  %32 = fdiv double 1.000000e+00, %31
  %33 = load double, ptr %8, align 8, !tbaa !16
  %34 = fdiv double %32, %33
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost7numeric5ublas6vectorIdNS1_15unbounded_arrayIdSaIdEEEEclEm(ptr noundef nonnull align 8 dereferenceable(24) %35, i64 noundef %36)
  store double %34, ptr %37, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %38

38:                                               ; preds = %28
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = add i64 %39, 1
  store i64 %40, ptr %6, align 8, !tbaa !9
  br label %13, !llvm.loop !18

41:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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

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

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

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

declare noundef i64 @_ZNK9elabtsaot11Powersystem14getBranchCountEv(ptr noundef nonnull align 8 dereferenceable(480)) local_unnamed_addr #0

declare noundef ptr @_ZNK9elabtsaot11Powersystem9getBranchEm(ptr noundef nonnull align 8 dereferenceable(480), i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9elabtsaot7ssutils12buildBranchBERKNS_11PowersystemERN5boost7numeric5ublas6vectorIdNS6_15unbounded_arrayIdSaIdEEEEE(ptr noundef nonnull align 8 dereferenceable(480) %0, ptr noundef nonnull align 8 dereferenceable(24) %1) local_unnamed_addr #1 {
  %3 = tail call noundef i64 @_ZNK9elabtsaot11Powersystem14getBranchCountEv(ptr noundef nonnull align 8 dereferenceable(480) %0)
  tail call void @_ZN5boost7numeric5ublas6vectorIdNS1_15unbounded_arrayIdSaIdEEEE6resizeEmb(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %3, i1 noundef zeroext true)
  %.not15 = icmp eq i64 %3, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret void

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.01316 = phi i64 [ %13, %.lr.ph ], [ 0, %2 ]
  %4 = tail call noundef ptr @_ZNK9elabtsaot11Powersystem9getBranchEm(ptr noundef nonnull align 8 dereferenceable(480) %0, i64 noundef %.01316)
  %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
  %.0 = 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 = fdiv double 1.000000e+00, %9
  %11 = fdiv double %10, %.0
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5boost7numeric5ublas6vectorIdNS1_15unbounded_arrayIdSaIdEEEEclEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.01316)
  store double %11, ptr %12, align 8, !tbaa !13
  %13 = add nuw i64 %.01316, 1
  %.not = icmp eq i64 %13, %3
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14
}

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

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

attributes #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" }

!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 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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