; LLVM IR from gem5/gem5 :: ext/dsent/model/timing_graph (ElectricalTimingTree)

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

; 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 i32 @_ZN5DSENT20ElectricalTimingTree10getTreeNumEv() #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN5DSENT20ElectricalTimingTree20extractCritPathDelayEPNS_20ElectricalTimingNodeE(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %4, align 8
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call noundef i32 @_ZNK5DSENT20ElectricalTimingNode13getVisitedNumEv(ptr noundef nonnull align 8 dereferenceable(88) %12)
  %14 = call noundef i32 @_ZN5DSENT20ElectricalTimingTree10getTreeNumEv()
  %15 = icmp eq i32 %13, %14
  br i1 %15, label %16, label %19

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef double @_ZNK5DSENT20ElectricalTimingNode12getDelayLeftEv(ptr noundef nonnull align 8 dereferenceable(88) %17)
  store double %18, ptr %3, align 8
  br label %66

19:                                               ; preds = %2
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call noundef zeroext i1 @_ZNK5DSENT20ElectricalTimingNode12getFalsePathEv(ptr noundef nonnull align 8 dereferenceable(88) %20)
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  store double 0.000000e+00, ptr %3, align 8
  br label %66

23:                                               ; preds = %19
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call noundef i32 @_ZN5DSENT20ElectricalTimingTree10getTreeNumEv()
  call void @_ZN5DSENT20ElectricalTimingNode13setVisitedNumEi(ptr noundef nonnull align 8 dereferenceable(88) %25, i32 noundef %26)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN5DSENT20ElectricalTimingNode12setDelayLeftEd(ptr noundef nonnull align 8 dereferenceable(88) %27, double noundef 0.000000e+00)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef ptr @_ZNK5DSENT20ElectricalTimingNode18getDownstreamNodesEv(ptr noundef nonnull align 8 dereferenceable(88) %28)
  store ptr %29, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %52, %24
  %31 = load i32, ptr %9, align 4, !tbaa !11
  %32 = zext i32 %31 to i64
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = call noundef i64 @_ZNKSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %33) #4
  %35 = icmp ult i64 %32, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %55

37:                                               ; preds = %30
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !11
  %40 = zext i32 %39 to i64
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %40)
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = call noundef double @_ZN5DSENT20ElectricalTimingTree20extractCritPathDelayEPNS_20ElectricalTimingNodeE(ptr noundef nonnull align 8 dereferenceable(40) %11, ptr noundef %42)
  store double %43, ptr %7, align 8, !tbaa !9
  %44 = load double, ptr %7, align 8, !tbaa !9
  %45 = load double, ptr %6, align 8, !tbaa !9
  %46 = fcmp ogt double %44, %45
  br i1 %46, label %47, label %51

47:                                               ; preds = %37
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !11
  call void @_ZN5DSENT20ElectricalTimingNode11setCritPathEi(ptr noundef nonnull align 8 dereferenceable(88) %48, i32 noundef %49)
  %50 = load double, ptr %7, align 8, !tbaa !9
  store double %50, ptr %6, align 8, !tbaa !9
  br label %51

51:                                               ; preds = %47, %37
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %9, align 4, !tbaa !11
  %54 = add i32 %53, 1
  store i32 %54, ptr %9, align 4, !tbaa !11
  br label %30, !llvm.loop !13

55:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = getelementptr inbounds ptr, ptr %57, i64 2
  %59 = load ptr, ptr %58, align 8
  %60 = call noundef double %59(ptr noundef nonnull align 8 dereferenceable(88) %56)
  %61 = load double, ptr %6, align 8, !tbaa !9
  %62 = fadd double %60, %61
  store double %62, ptr %10, align 8, !tbaa !9
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load double, ptr %10, align 8, !tbaa !9
  call void @_ZN5DSENT20ElectricalTimingNode12setDelayLeftEd(ptr noundef nonnull align 8 dereferenceable(88) %63, double noundef %64)
  %65 = load double, ptr %10, align 8, !tbaa !9
  store double %65, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %66

66:                                               ; preds = %55, %22, %16
  %67 = load double, ptr %3, align 8
  ret double %67
}

declare noundef i32 @_ZNK5DSENT20ElectricalTimingNode13getVisitedNumEv(ptr noundef nonnull align 8 dereferenceable(88)) #3

declare noundef double @_ZNK5DSENT20ElectricalTimingNode12getDelayLeftEv(ptr noundef nonnull align 8 dereferenceable(88)) #3

declare noundef zeroext i1 @_ZNK5DSENT20ElectricalTimingNode12getFalsePathEv(ptr noundef nonnull align 8 dereferenceable(88)) #3

declare void @_ZN5DSENT20ElectricalTimingNode13setVisitedNumEi(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef) #3

declare void @_ZN5DSENT20ElectricalTimingNode12setDelayLeftEd(ptr noundef nonnull align 8 dereferenceable(88), double noundef) #3

declare noundef ptr @_ZNK5DSENT20ElectricalTimingNode18getDownstreamNodesEv(ptr noundef nonnull align 8 dereferenceable(88)) #3

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

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

declare void @_ZN5DSENT20ElectricalTimingNode11setCritPathEi(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef) #3

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 = { "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 = { 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 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, 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 nounwind uwtable
declare dso_local noundef i32 @_ZN5DSENT20ElectricalTimingTree10getTreeNumEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN5DSENT20ElectricalTimingTree20extractCritPathDelayEPNS_20ElectricalTimingNodeE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(40) %0, ptr noundef nonnull %1) local_unnamed_addr #1 align 2 {
  %3 = tail call noundef i32 @_ZNK5DSENT20ElectricalTimingNode13getVisitedNumEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %4 = tail call noundef i32 @_ZN5DSENT20ElectricalTimingTree10getTreeNumEv()
  %5 = icmp eq i32 %3, %4
  br i1 %5, label %6, label %8

6:                                                ; preds = %2
  %7 = tail call noundef double @_ZNK5DSENT20ElectricalTimingNode12getDelayLeftEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  br label %30

8:                                                ; preds = %2
  %9 = tail call noundef zeroext i1 @_ZNK5DSENT20ElectricalTimingNode12getFalsePathEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  br i1 %9, label %30, label %10

10:                                               ; preds = %8
  %11 = tail call noundef i32 @_ZN5DSENT20ElectricalTimingTree10getTreeNumEv()
  tail call void @_ZN5DSENT20ElectricalTimingNode13setVisitedNumEi(ptr noundef nonnull align 8 dereferenceable(88) %1, i32 noundef %11)
  tail call void @_ZN5DSENT20ElectricalTimingNode12setDelayLeftEd(ptr noundef nonnull align 8 dereferenceable(88) %1, double noundef 0.000000e+00)
  %12 = tail call noundef ptr @_ZNK5DSENT20ElectricalTimingNode18getDownstreamNodesEv(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %13 = tail call noundef i64 @_ZNKSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  %.not = icmp eq i64 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %25, %10
  %.023.lcssa = phi double [ 0.000000e+00, %10 ], [ %.1, %25 ]
  %14 = load ptr, ptr %1, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %16 = load ptr, ptr %15, align 8
  %17 = tail call noundef double %16(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %18 = fadd double %.023.lcssa, %17
  tail call void @_ZN5DSENT20ElectricalTimingNode12setDelayLeftEd(ptr noundef nonnull align 8 dereferenceable(88) %1, double noundef %18)
  br label %30

.lr.ph:                                           ; preds = %10, %25
  %19 = phi i64 [ %27, %25 ], [ 0, %10 ]
  %.02227 = phi i32 [ %26, %25 ], [ 0, %10 ]
  %.02326 = phi double [ %.1, %25 ], [ 0.000000e+00, %10 ]
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %19)
  %21 = load ptr, ptr %20, align 8, !tbaa !8
  %22 = tail call noundef double @_ZN5DSENT20ElectricalTimingTree20extractCritPathDelayEPNS_20ElectricalTimingNodeE(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %21)
  %23 = fcmp ogt double %22, %.02326
  br i1 %23, label %24, label %25

24:                                               ; preds = %.lr.ph
  tail call void @_ZN5DSENT20ElectricalTimingNode11setCritPathEi(ptr noundef nonnull align 8 dereferenceable(88) %1, i32 noundef %.02227)
  br label %25

25:                                               ; preds = %.lr.ph, %24
  %.1 = phi double [ %22, %24 ], [ %.02326, %.lr.ph ]
  %26 = add i32 %.02227, 1
  %27 = zext i32 %26 to i64
  %28 = tail call noundef i64 @_ZNKSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  %29 = icmp ugt i64 %28, %27
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !11

30:                                               ; preds = %8, %._crit_edge, %6
  %.0 = phi double [ %7, %6 ], [ %18, %._crit_edge ], [ 0.000000e+00, %8 ]
  ret double %.0
}

declare noundef i32 @_ZNK5DSENT20ElectricalTimingNode13getVisitedNumEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare noundef double @_ZNK5DSENT20ElectricalTimingNode12getDelayLeftEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare noundef zeroext i1 @_ZNK5DSENT20ElectricalTimingNode12getFalsePathEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare void @_ZN5DSENT20ElectricalTimingNode13setVisitedNumEi(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef) local_unnamed_addr #2

declare void @_ZN5DSENT20ElectricalTimingNode12setDelayLeftEd(ptr noundef nonnull align 8 dereferenceable(88), double noundef) local_unnamed_addr #2

declare noundef ptr @_ZNK5DSENT20ElectricalTimingNode18getDownstreamNodesEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE4sizeEv(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(8) ptr @_ZNSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

declare void @_ZN5DSENT20ElectricalTimingNode11setCritPathEi(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef) 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 = { "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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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