; LLVM IR from gem5/gem5 :: ext/mcpat/cacti/router.ll (ZN6Router8cb_statsEv)

; 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.TechnologyParameter = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, i64, %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::ScalingFactor", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType" }
%"class.TechnologyParameter::DeviceType" = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::InterconnectType" = type { double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::ScalingFactor" = type { double, double, double }
%"class.TechnologyParameter::MemoryType" = type { double, double, double, double, double, double }
%class.Crossbar = type { %class.Component, double, double, double, double, double, double, double, double, ptr, double, double, double, double }
%class.Component = type { %class.Area, %class.powerDef, %class.powerDef, double, double }
%class.Area = type { double, double, double }
%class.powerDef = type { %class.powerComponents, %class.powerComponents, %class.powerComponents }
%class.powerComponents = type { double, double, double, double, double }
%class.Router = type { %class.Component, %class.Component, %class.Component, %class.Component, double, double, double, double, double, ptr, double, i32, i32, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }

@g_tp = external global %class.TechnologyParameter, align 8

declare i32 @__gxx_personality_v0(...)

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Router8cb_statsEv(ptr noundef nonnull align 8 dereferenceable(1320) %0) #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %class.Crossbar, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 384, ptr %3) #5
  %7 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 17
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 18
  %10 = load double, ptr %9, align 8, !tbaa !18
  %11 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 6
  %12 = load double, ptr %11, align 8, !tbaa !19
  call void @_ZN8CrossbarC1EdddPN19TechnologyParameter10DeviceTypeE(ptr noundef nonnull align 8 dereferenceable(384) %3, double noundef %8, double noundef %10, double noundef %12, ptr noundef getelementptr inbounds (%class.TechnologyParameter, ptr @g_tp, i32 0, i32 48))
  invoke void @_ZN8Crossbar13compute_powerEv(ptr noundef nonnull align 8 dereferenceable(384) %3)
          to label %13 unwind label %45

13:                                               ; preds = %1
  %14 = getelementptr inbounds %class.Component, ptr %3, i32 0, i32 3
  %15 = load double, ptr %14, align 8, !tbaa !20
  %16 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 2
  %17 = getelementptr inbounds %class.Component, ptr %16, i32 0, i32 3
  store double %15, ptr %17, align 8, !tbaa !21
  %18 = getelementptr inbounds %class.Component, ptr %3, i32 0, i32 1
  %19 = getelementptr inbounds %class.powerDef, ptr %18, i32 0, i32 0
  %20 = getelementptr inbounds %class.powerComponents, ptr %19, i32 0, i32 0
  %21 = load double, ptr %20, align 8, !tbaa !22
  %22 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 2
  %23 = getelementptr inbounds %class.Component, ptr %22, i32 0, i32 1
  %24 = getelementptr inbounds %class.powerDef, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %class.powerComponents, ptr %24, i32 0, i32 0
  store double %21, ptr %25, align 8, !tbaa !23
  %26 = getelementptr inbounds %class.Component, ptr %3, i32 0, i32 1
  %27 = getelementptr inbounds %class.powerDef, ptr %26, i32 0, i32 0
  %28 = getelementptr inbounds %class.powerComponents, ptr %27, i32 0, i32 1
  %29 = load double, ptr %28, align 8, !tbaa !24
  %30 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 2
  %31 = getelementptr inbounds %class.Component, ptr %30, i32 0, i32 1
  %32 = getelementptr inbounds %class.powerDef, ptr %31, i32 0, i32 0
  %33 = getelementptr inbounds %class.powerComponents, ptr %32, i32 0, i32 1
  store double %29, ptr %33, align 8, !tbaa !25
  %34 = getelementptr inbounds %class.Component, ptr %3, i32 0, i32 1
  %35 = getelementptr inbounds %class.powerDef, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %class.powerComponents, ptr %35, i32 0, i32 2
  %37 = load double, ptr %36, align 8, !tbaa !26
  %38 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 2
  %39 = getelementptr inbounds %class.Component, ptr %38, i32 0, i32 1
  %40 = getelementptr inbounds %class.powerDef, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %class.powerComponents, ptr %40, i32 0, i32 2
  store double %37, ptr %41, align 8, !tbaa !27
  %42 = getelementptr inbounds %class.Component, ptr %3, i32 0, i32 0
  %43 = getelementptr inbounds %class.Router, ptr %6, i32 0, i32 2
  %44 = getelementptr inbounds %class.Component, ptr %43, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %44, ptr align 8 %42, i64 24, i1 false), !tbaa.struct !28
  call void @_ZN8CrossbarD1Ev(ptr noundef nonnull align 8 dereferenceable(384) %3) #5
  call void @llvm.lifetime.end.p0(i64 384, ptr %3) #5
  ret void

45:                                               ; preds = %1
  %46 = landingpad { ptr, i32 }
          cleanup
  %47 = extractvalue { ptr, i32 } %46, 0
  store ptr %47, ptr %4, align 8
  %48 = extractvalue { ptr, i32 } %46, 1
  store i32 %48, ptr %5, align 4
  call void @_ZN8CrossbarD1Ev(ptr noundef nonnull align 8 dereferenceable(384) %3) #5
  call void @llvm.lifetime.end.p0(i64 384, ptr %3) #5
  br label %49

49:                                               ; preds = %45
  %50 = load ptr, ptr %4, align 8
  %51 = load i32, ptr %5, align 4
  %52 = insertvalue { ptr, i32 } poison, ptr %50, 0
  %53 = insertvalue { ptr, i32 } %52, i32 %51, 1
  resume { ptr, i32 } %53
}

declare void @_ZN8CrossbarC1EdddPN19TechnologyParameter10DeviceTypeE(ptr noundef nonnull align 8 dereferenceable(384), double noundef, double noundef, double noundef, ptr noundef) unnamed_addr #3

declare void @_ZN8Crossbar13compute_powerEv(ptr noundef nonnull align 8 dereferenceable(384)) #3

; Function Attrs: nounwind
declare void @_ZN8CrossbarD1Ev(ptr noundef nonnull align 8 dereferenceable(384)) unnamed_addr #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 "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 #5 = { 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, !13, i64 1216}
!10 = !{!"_ZTS6Router", !11, i64 0, !11, i64 280, !11, i64 560, !11, i64 840, !13, i64 1120, !13, i64 1128, !13, i64 1136, !13, i64 1144, !13, i64 1152, !6, i64 1160, !13, i64 1168, !16, i64 1176, !17, i64 1180, !13, i64 1184, !13, i64 1192, !13, i64 1200, !13, i64 1208, !13, i64 1216, !13, i64 1224, !13, i64 1232, !13, i64 1240, !13, i64 1248, !13, i64 1256, !13, i64 1264, !13, i64 1272, !13, i64 1280, !13, i64 1288, !13, i64 1296, !13, i64 1304, !13, i64 1312}
!11 = !{!"_ZTS9Component", !12, i64 0, !14, i64 24, !14, i64 144, !13, i64 264, !13, i64 272}
!12 = !{!"_ZTS4Area", !13, i64 0, !13, i64 8, !13, i64 16}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTS8powerDef", !15, i64 0, !15, i64 40, !15, i64 80}
!15 = !{!"_ZTS15powerComponents", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!16 = !{!"_ZTS9Wire_type", !7, i64 0}
!17 = !{!"_ZTS14Wire_placement", !7, i64 0}
!18 = !{!10, !13, i64 1224}
!19 = !{!10, !13, i64 1136}
!20 = !{!11, !13, i64 264}
!21 = !{!10, !13, i64 824}
!22 = !{!11, !13, i64 24}
!23 = !{!10, !13, i64 584}
!24 = !{!11, !13, i64 32}
!25 = !{!10, !13, i64 592}
!26 = !{!11, !13, i64 40}
!27 = !{!10, !13, i64 600}
!28 = !{i64 0, i64 8, !29, i64 8, i64 8, !29, i64 16, i64 8, !29}
!29 = !{!13, !13, 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"

%class.TechnologyParameter = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, i64, %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::DeviceType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::InterconnectType", %"class.TechnologyParameter::ScalingFactor", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType", %"class.TechnologyParameter::MemoryType" }
%"class.TechnologyParameter::DeviceType" = type { double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::InterconnectType" = type { double, double, double, double, double, double, double, double }
%"class.TechnologyParameter::ScalingFactor" = type { double, double, double }
%"class.TechnologyParameter::MemoryType" = type { double, double, double, double, double, double }
%class.Crossbar = type { %class.Component, double, double, double, double, double, double, double, double, ptr, double, double, double, double }
%class.Component = type { %class.Area, %class.powerDef, %class.powerDef, double, double }
%class.Area = type { double, double, double }
%class.powerDef = type { %class.powerComponents, %class.powerComponents, %class.powerComponents }
%class.powerComponents = type { double, double, double, double, double }

@g_tp = external global %class.TechnologyParameter, align 8

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Router8cb_statsEv(ptr nocapture noundef nonnull align 8 dereferenceable(1320) %0) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %class.Crossbar, align 8
  call void @llvm.lifetime.start.p0(i64 384, ptr nonnull %2) #5
  %3 = getelementptr inbounds i8, ptr %0, i64 1216
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 1224
  %6 = load double, ptr %5, align 8, !tbaa !17
  %7 = getelementptr inbounds i8, ptr %0, i64 1136
  %8 = load double, ptr %7, align 8, !tbaa !18
  call void @_ZN8CrossbarC1EdddPN19TechnologyParameter10DeviceTypeE(ptr noundef nonnull align 8 dereferenceable(384) %2, double noundef %4, double noundef %6, double noundef %8, ptr noundef nonnull getelementptr inbounds (i8, ptr @g_tp, i64 864))
  invoke void @_ZN8Crossbar13compute_powerEv(ptr noundef nonnull align 8 dereferenceable(384) %2)
          to label %9 unwind label %20

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %2, i64 264
  %11 = load double, ptr %10, align 8, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %0, i64 560
  %13 = getelementptr inbounds i8, ptr %0, i64 824
  store double %11, ptr %13, align 8, !tbaa !20
  %14 = getelementptr inbounds i8, ptr %2, i64 24
  %15 = getelementptr inbounds i8, ptr %0, i64 584
  %16 = load <2 x double>, ptr %14, align 8, !tbaa !21
  store <2 x double> %16, ptr %15, align 8, !tbaa !21
  %17 = getelementptr inbounds i8, ptr %2, i64 40
  %18 = load double, ptr %17, align 8, !tbaa !22
  %19 = getelementptr inbounds i8, ptr %0, i64 600
  store double %18, ptr %19, align 8, !tbaa !23
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef nonnull align 8 dereferenceable(24) %2, i64 24, i1 false), !tbaa.struct !24
  call void @_ZN8CrossbarD1Ev(ptr noundef nonnull align 8 dereferenceable(384) %2) #5
  call void @llvm.lifetime.end.p0(i64 384, ptr nonnull %2) #5
  ret void

20:                                               ; preds = %1
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN8CrossbarD1Ev(ptr noundef nonnull align 8 dereferenceable(384) %2) #5
  call void @llvm.lifetime.end.p0(i64 384, ptr nonnull %2) #5
  resume { ptr, i32 } %21
}

declare void @_ZN8CrossbarC1EdddPN19TechnologyParameter10DeviceTypeE(ptr noundef nonnull align 8 dereferenceable(384), double noundef, double noundef, double noundef, ptr noundef) unnamed_addr #3

declare void @_ZN8Crossbar13compute_powerEv(ptr noundef nonnull align 8 dereferenceable(384)) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZN8CrossbarD1Ev(ptr noundef nonnull align 8 dereferenceable(384)) unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 "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 #5 = { 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, !9, i64 1216}
!6 = !{!"_ZTS6Router", !7, i64 0, !7, i64 280, !7, i64 560, !7, i64 840, !9, i64 1120, !9, i64 1128, !9, i64 1136, !9, i64 1144, !9, i64 1152, !14, i64 1160, !9, i64 1168, !15, i64 1176, !16, i64 1180, !9, i64 1184, !9, i64 1192, !9, i64 1200, !9, i64 1208, !9, i64 1216, !9, i64 1224, !9, i64 1232, !9, i64 1240, !9, i64 1248, !9, i64 1256, !9, i64 1264, !9, i64 1272, !9, i64 1280, !9, i64 1288, !9, i64 1296, !9, i64 1304, !9, i64 1312}
!7 = !{!"_ZTS9Component", !8, i64 0, !12, i64 24, !12, i64 144, !9, i64 264, !9, i64 272}
!8 = !{!"_ZTS4Area", !9, i64 0, !9, i64 8, !9, i64 16}
!9 = !{!"double", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTS8powerDef", !13, i64 0, !13, i64 40, !13, i64 80}
!13 = !{!"_ZTS15powerComponents", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24, !9, i64 32}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!"_ZTS9Wire_type", !10, i64 0}
!16 = !{!"_ZTS14Wire_placement", !10, i64 0}
!17 = !{!6, !9, i64 1224}
!18 = !{!6, !9, i64 1136}
!19 = !{!7, !9, i64 264}
!20 = !{!6, !9, i64 824}
!21 = !{!9, !9, i64 0}
!22 = !{!7, !9, i64 40}
!23 = !{!6, !9, i64 600}
!24 = !{i64 0, i64 8, !21, i64 8, i64 8, !21, i64 16, i64 8, !21}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass