; 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 uwtable
define dso_local noundef ptr @_ZNK5DSENT20ElectricalTimingTree20findNodeForTimingOptEPNS_20ElectricalTimingNodeE(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  br label %73

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double -1.000000e+01, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds ptr, ptr %18, i64 5
  %20 = load ptr, ptr %19, align 8
  %21 = call noundef double %20(ptr noundef nonnull align 8 dereferenceable(88) %17)
  %22 = fmul double 1.000000e+03, %21
  store double %22, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store double 0.000000e+00, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !13
  br label %23

23:                                               ; preds = %70, %16
  %24 = load i32, ptr %11, align 4, !tbaa !13
  %25 = icmp sge i32 %24, 0
  br i1 %25, label %26, label %71

26:                                               ; preds = %23
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds ptr, ptr %28, i64 2
  %30 = load ptr, ptr %29, align 8
  %31 = call noundef double %30(ptr noundef nonnull align 8 dereferenceable(88) %27)
  store double %31, ptr %9, align 8, !tbaa !9
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = getelementptr inbounds ptr, ptr %33, i64 10
  %35 = load ptr, ptr %34, align 8
  %36 = call noundef zeroext i1 %35(ptr noundef nonnull align 8 dereferenceable(88) %32)
  br i1 %36, label %48, label %37

37:                                               ; preds = %26
  %38 = load double, ptr %9, align 8, !tbaa !9
  %39 = load double, ptr %8, align 8, !tbaa !9
  %40 = fdiv double %38, %39
  store double %40, ptr %7, align 8, !tbaa !9
  %41 = load double, ptr %7, align 8, !tbaa !9
  %42 = load double, ptr %6, align 8, !tbaa !9
  %43 = fcmp ogt double %41, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %37
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %45, ptr %10, align 8, !tbaa !5
  %46 = load double, ptr %7, align 8, !tbaa !9
  store double %46, ptr %6, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %44, %37
  br label %48

48:                                               ; preds = %47, %26
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = getelementptr inbounds ptr, ptr %50, i64 6
  %52 = load ptr, ptr %51, align 8
  %53 = call noundef zeroext i1 %52(ptr noundef nonnull align 8 dereferenceable(88) %49)
  br i1 %53, label %54, label %55

54:                                               ; preds = %48
  store double 0.000000e+00, ptr %8, align 8, !tbaa !9
  br label %55

55:                                               ; preds = %54, %48
  %56 = load double, ptr %9, align 8, !tbaa !9
  %57 = load double, ptr %8, align 8, !tbaa !9
  %58 = fadd double %57, %56
  store double %58, ptr %8, align 8, !tbaa !9
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call noundef i32 @_ZNK5DSENT20ElectricalTimingNode11getCritPathEv(ptr noundef nonnull align 8 dereferenceable(88) %59)
  store i32 %60, ptr %11, align 4, !tbaa !13
  %61 = load i32, ptr %11, align 4, !tbaa !13
  %62 = icmp sge i32 %61, 0
  br i1 %62, label %63, label %70

63:                                               ; preds = %55
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = call noundef ptr @_ZNK5DSENT20ElectricalTimingNode18getDownstreamNodesEv(ptr noundef nonnull align 8 dereferenceable(88) %64)
  %66 = load i32, ptr %11, align 4, !tbaa !13
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %65, i64 noundef %67)
  %69 = load ptr, ptr %68, align 8, !tbaa !5
  store ptr %69, ptr %5, align 8, !tbaa !5
  br label %70

70:                                               ; preds = %63, %55
  br label %23, !llvm.loop !15

71:                                               ; preds = %23
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %72, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %73

73:                                               ; preds = %71, %15
  %74 = load ptr, ptr %3, align 8
  ret ptr %74
}

declare noundef ptr @_ZNK5DSENT20ElectricalTimingNode18getDownstreamNodesEv(ptr noundef nonnull align 8 dereferenceable(88)) #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) #1 align 2

declare noundef i32 @_ZNK5DSENT20ElectricalTimingNode11getCritPathEv(ptr noundef nonnull align 8 dereferenceable(88)) #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 = { "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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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 uwtable
define dso_local noundef ptr @_ZNK5DSENT20ElectricalTimingTree20findNodeForTimingOptEPNS_20ElectricalTimingNodeE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(40) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = icmp eq ptr %1, null
  br i1 %3, label %.loopexit, label %4

4:                                                ; preds = %2
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 40
  %7 = load ptr, ptr %6, align 8
  %8 = tail call noundef double %7(ptr noundef nonnull align 8 dereferenceable(88) %1)
  %9 = fmul double %8, 1.000000e+03
  br label %10

10:                                               ; preds = %30, %4
  %.02034 = phi ptr [ null, %4 ], [ %.1, %30 ]
  %.02133 = phi double [ %9, %4 ], [ %31, %30 ]
  %.02332 = phi double [ -1.000000e+01, %4 ], [ %.124, %30 ]
  %.02531 = phi ptr [ %1, %4 ], [ %35, %30 ]
  %11 = load ptr, ptr %.02531, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  %13 = load ptr, ptr %12, align 8
  %14 = tail call noundef double %13(ptr noundef nonnull align 8 dereferenceable(88) %.02531)
  %15 = load ptr, ptr %.02531, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 80
  %17 = load ptr, ptr %16, align 8
  %18 = tail call noundef zeroext i1 %17(ptr noundef nonnull align 8 dereferenceable(88) %.02531)
  br i1 %18, label %23, label %19

19:                                               ; preds = %10
  %20 = fdiv double %14, %.02133
  %21 = fcmp ogt double %20, %.02332
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %23

23:                                               ; preds = %19, %22, %10
  %.124 = phi double [ %.02332, %10 ], [ %20, %22 ], [ %.02332, %19 ]
  %.1 = phi ptr [ %.02034, %10 ], [ %.02531, %22 ], [ %.02034, %19 ]
  %24 = load ptr, ptr %.02531, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 48
  %26 = load ptr, ptr %25, align 8
  %27 = tail call noundef zeroext i1 %26(ptr noundef nonnull align 8 dereferenceable(88) %.02531)
  %28 = tail call noundef i32 @_ZNK5DSENT20ElectricalTimingNode11getCritPathEv(ptr noundef nonnull align 8 dereferenceable(88) %.02531)
  %29 = icmp sgt i32 %28, -1
  br i1 %29, label %30, label %.loopexit

30:                                               ; preds = %23
  %.122 = select i1 %27, double 0.000000e+00, double %.02133
  %31 = fadd double %14, %.122
  %32 = tail call noundef ptr @_ZNK5DSENT20ElectricalTimingNode18getDownstreamNodesEv(ptr noundef nonnull align 8 dereferenceable(88) %.02531)
  %33 = zext nneg i32 %28 to i64
  %34 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN5DSENT20ElectricalTimingNodeESaIS2_EE2atEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %33)
  %35 = load ptr, ptr %34, align 8, !tbaa !8
  br label %10, !llvm.loop !11

.loopexit:                                        ; preds = %23, %2
  %.027 = phi ptr [ null, %2 ], [ %.1, %23 ]
  ret ptr %.027
}

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

; 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 #0 align 2

declare noundef i32 @_ZNK5DSENT20ElectricalTimingNode11getCritPathEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #1

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 = { "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, !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: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass