; LLVM IR from gem5/gem5 :: ext/mcpat/iocontrollers.ll (ZN14PCIeController11computeAreaEv)

; 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.PCIeController = type { %class.McPATComponent, %class.PCIeParameters, %class.PCIeStatistics }
%class.McPATComponent = type { ptr, %class.Component, ptr, %class.InputParameter, %"class.std::__cxx11::basic_string", double, %"class.std::vector", %class.McPATOutput, %class.statsDef, %class.statsDef, %class.powerDef, %class.powerDef }
%class.Component = type { %class.Area, %class.powerDef, %class.powerDef, double, double }
%class.Area = type { double, double, double }
%class.InputParameter = type { i32, i32, i32, i32, i32, i8, i32, i32, i32, i32, i32, i32, double, double, i32, i32, i32, i32, i32, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i32, i32, i32, i32, i32, i32, i32, i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i32, i32, i32, i8, i8, i32, i32, i8, double, double, i8, i32, i32, i8 }
%"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<McPATComponent *, std::allocator<McPATComponent *>>::_Vector_impl" }
%"struct.std::_Vector_base<McPATComponent *, std::allocator<McPATComponent *>>::_Vector_impl" = type { %"struct.std::_Vector_base<McPATComponent *, std::allocator<McPATComponent *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<McPATComponent *, std::allocator<McPATComponent *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.McPATOutput = type { double, double, double, double, double, double }
%class.statsDef = type { %class.statsComponents, %class.statsComponents, %class.statsComponents, %class.statsComponents, %class.statsComponents, %class.statsComponents, %class.statsComponents }
%class.statsComponents = type { double, double, double }
%class.powerDef = type { %class.powerComponents, %class.powerComponents, %class.powerComponents }
%class.powerComponents = type { double, double, double, double, double }
%class.PCIeParameters = type { double, i32, i32, i8, i32 }
%class.PCIeStatistics = type { 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
define dso_local void @_ZN14PCIeController11computeAreaEv(ptr noundef nonnull align 8 dereferenceable(1392) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %6 = getelementptr inbounds %class.PCIeController, ptr %5, i32 0, i32 1
  %7 = getelementptr inbounds %class.PCIeParameters, ptr %6, i32 0, i32 4
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %26

10:                                               ; preds = %1
  %11 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 3
  %12 = getelementptr inbounds %class.InputParameter, ptr %11, i32 0, i32 13
  %13 = load double, ptr %12, align 8, !tbaa !33
  %14 = fdiv double %13, 6.500000e-02
  %15 = fmul double 2.850000e+00, %14
  %16 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 3
  %17 = getelementptr inbounds %class.InputParameter, ptr %16, i32 0, i32 13
  %18 = load double, ptr %17, align 8, !tbaa !33
  %19 = fdiv double %18, 6.500000e-02
  %20 = fmul double %15, %19
  store double %20, ptr %3, align 8, !tbaa !34
  %21 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 3
  %22 = getelementptr inbounds %class.InputParameter, ptr %21, i32 0, i32 13
  %23 = load double, ptr %22, align 8, !tbaa !33
  %24 = fdiv double %23, 6.500000e-02
  %25 = fmul double 0x400B1EB851EB851E, %24
  store double %25, ptr %4, align 8, !tbaa !34
  br label %47

26:                                               ; preds = %1
  %27 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 3
  %28 = getelementptr inbounds %class.InputParameter, ptr %27, i32 0, i32 13
  %29 = load double, ptr %28, align 8, !tbaa !33
  %30 = fdiv double %29, 6.500000e-02
  %31 = fmul double 4.120000e-01, %30
  %32 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 3
  %33 = getelementptr inbounds %class.InputParameter, ptr %32, i32 0, i32 13
  %34 = load double, ptr %33, align 8, !tbaa !33
  %35 = fdiv double %34, 6.500000e-02
  %36 = fmul double %31, %35
  store double %36, ptr %3, align 8, !tbaa !34
  %37 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 3
  %38 = getelementptr inbounds %class.InputParameter, ptr %37, i32 0, i32 13
  %39 = load double, ptr %38, align 8, !tbaa !33
  %40 = fdiv double %39, 6.500000e-02
  %41 = fmul double 3.600000e-01, %40
  %42 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 3
  %43 = getelementptr inbounds %class.InputParameter, ptr %42, i32 0, i32 13
  %44 = load double, ptr %43, align 8, !tbaa !33
  %45 = fdiv double %44, 6.500000e-02
  %46 = fmul double %41, %45
  store double %46, ptr %4, align 8, !tbaa !34
  br label %47

47:                                               ; preds = %26, %10
  %48 = load double, ptr %3, align 8, !tbaa !34
  %49 = getelementptr inbounds %class.PCIeController, ptr %5, i32 0, i32 1
  %50 = getelementptr inbounds %class.PCIeParameters, ptr %49, i32 0, i32 3
  %51 = load i8, ptr %50, align 8, !tbaa !35, !range !36, !noundef !37
  %52 = trunc i8 %51 to i1
  br i1 %52, label %53, label %55

53:                                               ; preds = %47
  %54 = load double, ptr %4, align 8, !tbaa !34
  br label %56

55:                                               ; preds = %47
  br label %56

56:                                               ; preds = %55, %53
  %57 = phi double [ %54, %53 ], [ 0.000000e+00, %55 ]
  %58 = fadd double %48, %57
  %59 = fdiv double %58, 8.000000e+00
  %60 = getelementptr inbounds %class.PCIeController, ptr %5, i32 0, i32 1
  %61 = getelementptr inbounds %class.PCIeParameters, ptr %60, i32 0, i32 1
  %62 = load i32, ptr %61, align 8, !tbaa !38
  %63 = sitofp i32 %62 to double
  %64 = fmul double %59, %63
  %65 = fmul double %64, 1.000000e+06
  %66 = getelementptr inbounds %class.McPATComponent, ptr %5, i32 0, i32 7
  %67 = getelementptr inbounds %class.McPATOutput, ptr %66, i32 0, i32 1
  store double %65, ptr %67, align 8, !tbaa !39
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

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, !18, i64 1372}
!10 = !{!"_ZTS14PCIeController", !11, i64 0, !31, i64 1352, !32, i64 1376}
!11 = !{!"_ZTS14McPATComponent", !12, i64 8, !6, i64 288, !17, i64 296, !21, i64 664, !14, i64 696, !24, i64 704, !28, i64 728, !29, i64 776, !29, i64 944, !15, i64 1112, !15, i64 1232}
!12 = !{!"_ZTS9Component", !13, i64 0, !15, i64 24, !15, i64 144, !14, i64 264, !14, i64 272}
!13 = !{!"_ZTS4Area", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTS8powerDef", !16, i64 0, !16, i64 40, !16, i64 80}
!16 = !{!"_ZTS15powerComponents", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!17 = !{!"_ZTS14InputParameter", !18, i64 0, !18, i64 4, !18, i64 8, !18, i64 12, !18, i64 16, !19, i64 20, !18, i64 24, !18, i64 28, !18, i64 32, !18, i64 36, !18, i64 40, !18, i64 44, !14, i64 48, !14, i64 56, !18, i64 64, !18, i64 68, !18, i64 72, !18, i64 76, !18, i64 80, !19, i64 84, !19, i64 85, !19, i64 86, !19, i64 87, !19, i64 88, !18, i64 92, !18, i64 96, !18, i64 100, !18, i64 104, !18, i64 108, !18, i64 112, !18, i64 116, !18, i64 120, !18, i64 124, !18, i64 128, !18, i64 132, !18, i64 136, !18, i64 140, !18, i64 144, !18, i64 148, !20, i64 152, !18, i64 156, !19, i64 160, !18, i64 164, !18, i64 168, !18, i64 172, !18, i64 176, !18, i64 180, !18, i64 184, !18, i64 188, !19, i64 192, !18, i64 196, !18, i64 200, !18, i64 204, !18, i64 208, !18, i64 212, !18, i64 216, !18, i64 220, !18, i64 224, !18, i64 228, !18, i64 232, !18, i64 236, !18, i64 240, !18, i64 244, !18, i64 248, !18, i64 252, !18, i64 256, !18, i64 260, !18, i64 264, !18, i64 268, !18, i64 272, !18, i64 276, !18, i64 280, !18, i64 284, !18, i64 288, !18, i64 292, !18, i64 296, !19, i64 300, !18, i64 304, !18, i64 308, !18, i64 312, !19, i64 316, !19, i64 317, !18, i64 320, !18, i64 324, !19, i64 328, !14, i64 336, !14, i64 344, !19, i64 352, !18, i64 356, !18, i64 360, !19, i64 364}
!18 = !{!"int", !7, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTS9Wire_type", !7, i64 0}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !22, i64 0, !23, i64 8, !7, i64 16}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!23 = !{!"long", !7, i64 0}
!24 = !{!"_ZTSSt6vectorIP14McPATComponentSaIS1_EE", !25, i64 0}
!25 = !{!"_ZTSSt12_Vector_baseIP14McPATComponentSaIS1_EE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIP14McPATComponentSaIS1_EE12_Vector_implE", !27, i64 0}
!27 = !{!"_ZTSNSt12_Vector_baseIP14McPATComponentSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!28 = !{!"_ZTS11McPATOutput", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !14, i64 40}
!29 = !{!"_ZTS8statsDef", !30, i64 0, !30, i64 24, !30, i64 48, !30, i64 72, !30, i64 96, !30, i64 120, !30, i64 144}
!30 = !{!"_ZTS15statsComponents", !14, i64 0, !14, i64 8, !14, i64 16}
!31 = !{!"_ZTS14PCIeParameters", !14, i64 0, !18, i64 8, !18, i64 12, !19, i64 16, !18, i64 20}
!32 = !{!"_ZTS14PCIeStatistics", !14, i64 0, !14, i64 8}
!33 = !{!11, !14, i64 352}
!34 = !{!14, !14, i64 0}
!35 = !{!10, !19, i64 1368}
!36 = !{i8 0, i8 2}
!37 = !{}
!38 = !{!10, !18, i64 1360}
!39 = !{!11, !14, i64 736}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN14PCIeController11computeAreaEv(ptr nocapture noundef nonnull align 8 dereferenceable(1392) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 1372
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp eq i32 %3, 0
  %5 = getelementptr inbounds i8, ptr %0, i64 352
  %6 = load double, ptr %5, align 8, !tbaa !32
  %7 = fdiv double %6, 6.500000e-02
  %8 = fmul double %7, 3.600000e-01
  %.sink = select i1 %4, double 0x400B1EB851EB851E, double %8
  %.pn.v = select i1 %4, double 2.850000e+00, double 4.120000e-01
  %.pn = fmul double %7, %.pn.v
  %.03 = fmul double %7, %.pn
  %9 = fmul double %7, %.sink
  %10 = getelementptr inbounds i8, ptr %0, i64 1368
  %11 = load i8, ptr %10, align 8, !tbaa !33, !range !34, !noundef !35
  %12 = trunc nuw i8 %11 to i1
  %13 = select i1 %12, double %9, double 0.000000e+00
  %14 = fadd double %.03, %13
  %15 = fmul double %14, 1.250000e-01
  %16 = getelementptr inbounds i8, ptr %0, i64 1360
  %17 = load i32, ptr %16, align 8, !tbaa !36
  %18 = sitofp i32 %17 to double
  %19 = fmul double %15, %18
  %20 = fmul double %19, 1.000000e+06
  %21 = getelementptr inbounds i8, ptr %0, i64 736
  store double %20, ptr %21, align 8, !tbaa !37
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !17, i64 1372}
!6 = !{!"_ZTS14PCIeController", !7, i64 0, !30, i64 1352, !31, i64 1376}
!7 = !{!"_ZTS14McPATComponent", !8, i64 8, !15, i64 288, !16, i64 296, !20, i64 664, !10, i64 696, !23, i64 704, !27, i64 728, !28, i64 776, !28, i64 944, !13, i64 1112, !13, i64 1232}
!8 = !{!"_ZTS9Component", !9, i64 0, !13, i64 24, !13, i64 144, !10, i64 264, !10, i64 272}
!9 = !{!"_ZTS4Area", !10, i64 0, !10, i64 8, !10, i64 16}
!10 = !{!"double", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTS8powerDef", !14, i64 0, !14, i64 40, !14, i64 80}
!14 = !{!"_ZTS15powerComponents", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!15 = !{!"any pointer", !11, i64 0}
!16 = !{!"_ZTS14InputParameter", !17, i64 0, !17, i64 4, !17, i64 8, !17, i64 12, !17, i64 16, !18, i64 20, !17, i64 24, !17, i64 28, !17, i64 32, !17, i64 36, !17, i64 40, !17, i64 44, !10, i64 48, !10, i64 56, !17, i64 64, !17, i64 68, !17, i64 72, !17, i64 76, !17, i64 80, !18, i64 84, !18, i64 85, !18, i64 86, !18, i64 87, !18, i64 88, !17, i64 92, !17, i64 96, !17, i64 100, !17, i64 104, !17, i64 108, !17, i64 112, !17, i64 116, !17, i64 120, !17, i64 124, !17, i64 128, !17, i64 132, !17, i64 136, !17, i64 140, !17, i64 144, !17, i64 148, !19, i64 152, !17, i64 156, !18, i64 160, !17, i64 164, !17, i64 168, !17, i64 172, !17, i64 176, !17, i64 180, !17, i64 184, !17, i64 188, !18, i64 192, !17, i64 196, !17, i64 200, !17, i64 204, !17, i64 208, !17, i64 212, !17, i64 216, !17, i64 220, !17, i64 224, !17, i64 228, !17, i64 232, !17, i64 236, !17, i64 240, !17, i64 244, !17, i64 248, !17, i64 252, !17, i64 256, !17, i64 260, !17, i64 264, !17, i64 268, !17, i64 272, !17, i64 276, !17, i64 280, !17, i64 284, !17, i64 288, !17, i64 292, !17, i64 296, !18, i64 300, !17, i64 304, !17, i64 308, !17, i64 312, !18, i64 316, !18, i64 317, !17, i64 320, !17, i64 324, !18, i64 328, !10, i64 336, !10, i64 344, !18, i64 352, !17, i64 356, !17, i64 360, !18, i64 364}
!17 = !{!"int", !11, i64 0}
!18 = !{!"bool", !11, i64 0}
!19 = !{!"_ZTS9Wire_type", !11, i64 0}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !21, i64 0, !22, i64 8, !11, i64 16}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !15, i64 0}
!22 = !{!"long", !11, i64 0}
!23 = !{!"_ZTSSt6vectorIP14McPATComponentSaIS1_EE", !24, i64 0}
!24 = !{!"_ZTSSt12_Vector_baseIP14McPATComponentSaIS1_EE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIP14McPATComponentSaIS1_EE12_Vector_implE", !26, i64 0}
!26 = !{!"_ZTSNSt12_Vector_baseIP14McPATComponentSaIS1_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!27 = !{!"_ZTS11McPATOutput", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40}
!28 = !{!"_ZTS8statsDef", !29, i64 0, !29, i64 24, !29, i64 48, !29, i64 72, !29, i64 96, !29, i64 120, !29, i64 144}
!29 = !{!"_ZTS15statsComponents", !10, i64 0, !10, i64 8, !10, i64 16}
!30 = !{!"_ZTS14PCIeParameters", !10, i64 0, !17, i64 8, !17, i64 12, !18, i64 16, !17, i64 20}
!31 = !{!"_ZTS14PCIeStatistics", !10, i64 0, !10, i64 8}
!32 = !{!7, !10, i64 352}
!33 = !{!6, !18, i64 1368}
!34 = !{i8 0, i8 2}
!35 = !{}
!36 = !{!6, !17, i64 1360}
!37 = !{!7, !10, i64 736}


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