; LLVM IR from gem5/gem5 :: ext/mcpat/cacti/subarray.ll (ZN8Subarray19get_total_cell_areaEv)

; 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.Subarray = type { %class.Component, ptr, i32, i32, i32, i32, %class.Area, %class.Area, i8, double, double, double, double, double, double, double, double }
%class.Component = type { %class.Area, %class.powerDef, %class.powerDef, double, double }
%class.powerDef = type { %class.powerComponents, %class.powerComponents, %class.powerComponents }
%class.powerComponents = type { double, double, double, double, double }
%class.Area = type { double, double, double }
%class.DynamicParameter = type <{ i8, i8, i8, i8, i32, i32, i32, double, 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, [7 x i8], double, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i8], double, i32, i32, i32, i32, i32, i32, i32, i8, [3 x i8], %class.Area, %class.Area, i8, [7 x i8] }>

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN8Subarray19get_total_cell_areaEv(ptr noundef nonnull align 8 dereferenceable(424) %0) #1 align 2 {
  %2 = alloca double, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 8
  %6 = load i8, ptr %5, align 8, !tbaa !9, !range !18, !noundef !19
  %7 = trunc i8 %6 to i1
  br i1 %7, label %25, label %8

8:                                                ; preds = %1
  %9 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !20
  %11 = getelementptr inbounds %class.DynamicParameter, ptr %10, i32 0, i32 2
  %12 = load i8, ptr %11, align 2, !tbaa !21, !range !18, !noundef !19
  %13 = trunc i8 %12 to i1
  br i1 %13, label %25, label %14

14:                                               ; preds = %8
  %15 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 6
  %16 = call noundef double @_ZNK4Area8get_areaEv(ptr noundef nonnull align 8 dereferenceable(24) %15)
  %17 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 2
  %18 = load i32, ptr %17, align 8, !tbaa !23
  %19 = uitofp i32 %18 to double
  %20 = fmul double %16, %19
  %21 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 3
  %22 = load i32, ptr %21, align 4, !tbaa !24
  %23 = uitofp i32 %22 to double
  %24 = fmul double %20, %23
  store double %24, ptr %2, align 8
  br label %65

25:                                               ; preds = %8, %1
  %26 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 8
  %27 = load i8, ptr %26, align 8, !tbaa !9, !range !18, !noundef !19
  %28 = trunc i8 %27 to i1
  br i1 %28, label %29, label %53

29:                                               ; preds = %25
  %30 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 7
  %31 = getelementptr inbounds %class.Area, ptr %30, i32 0, i32 1
  %32 = load double, ptr %31, align 8, !tbaa !25
  %33 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !23
  %35 = add i32 %34, 1
  %36 = uitofp i32 %35 to double
  %37 = fmul double %32, %36
  %38 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 7
  %39 = getelementptr inbounds %class.Area, ptr %38, i32 0, i32 0
  %40 = load double, ptr %39, align 8, !tbaa !26
  %41 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 4
  %42 = load i32, ptr %41, align 8, !tbaa !27
  %43 = sitofp i32 %42 to double
  %44 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 6
  %45 = getelementptr inbounds %class.Area, ptr %44, i32 0, i32 0
  %46 = load double, ptr %45, align 8, !tbaa !28
  %47 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 5
  %48 = load i32, ptr %47, align 4, !tbaa !29
  %49 = sitofp i32 %48 to double
  %50 = fmul double %46, %49
  %51 = call double @llvm.fmuladd.f64(double %40, double %43, double %50)
  %52 = fmul double %37, %51
  store double %52, ptr %2, align 8
  br label %65

53:                                               ; preds = %25
  %54 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 7
  %55 = call noundef double @_ZNK4Area8get_areaEv(ptr noundef nonnull align 8 dereferenceable(24) %54)
  %56 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 2
  %57 = load i32, ptr %56, align 8, !tbaa !23
  %58 = add i32 %57, 1
  %59 = uitofp i32 %58 to double
  %60 = fmul double %55, %59
  %61 = getelementptr inbounds %class.Subarray, ptr %4, i32 0, i32 4
  %62 = load i32, ptr %61, align 8, !tbaa !27
  %63 = sitofp i32 %62 to double
  %64 = fmul double %60, %63
  store double %64, ptr %2, align 8
  br label %65

65:                                               ; preds = %53, %29, %14
  %66 = load double, ptr %2, align 8
  ret double %66
}

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

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { 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" }

!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, !17, i64 352}
!10 = !{!"_ZTS8Subarray", !11, i64 0, !6, i64 280, !16, i64 288, !16, i64 292, !16, i64 296, !16, i64 300, !12, i64 304, !12, i64 328, !17, i64 352, !13, i64 360, !13, i64 368, !13, i64 376, !13, i64 384, !13, i64 392, !13, i64 400, !13, i64 408, !13, i64 416}
!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 = !{!"int", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!10, !6, i64 280}
!21 = !{!22, !17, i64 2}
!22 = !{!"_ZTS16DynamicParameter", !17, i64 0, !17, i64 1, !17, i64 2, !17, i64 3, !16, i64 4, !16, i64 8, !16, i64 12, !13, i64 16, !16, i64 24, !16, i64 28, !16, i64 32, !16, i64 36, !16, i64 40, !16, i64 44, !16, i64 48, !16, i64 52, !16, i64 56, !16, i64 60, !16, i64 64, !16, i64 68, !16, i64 72, !16, i64 76, !16, i64 80, !16, i64 84, !16, i64 88, !16, i64 92, !16, i64 96, !16, i64 100, !16, i64 104, !16, i64 108, !16, i64 112, !16, i64 116, !17, i64 120, !13, i64 128, !16, i64 136, !16, i64 140, !16, i64 144, !16, i64 148, !16, i64 152, !16, i64 156, !16, i64 160, !16, i64 164, !16, i64 168, !13, i64 176, !16, i64 184, !16, i64 188, !16, i64 192, !16, i64 196, !16, i64 200, !16, i64 204, !16, i64 208, !17, i64 212, !12, i64 216, !12, i64 240, !17, i64 264}
!23 = !{!10, !16, i64 288}
!24 = !{!10, !16, i64 292}
!25 = !{!10, !13, i64 336}
!26 = !{!10, !13, i64 328}
!27 = !{!10, !16, i64 296}
!28 = !{!10, !13, i64 304}
!29 = !{!10, !16, i64 300}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZN8Subarray19get_total_cell_areaEv(ptr noundef nonnull align 8 dereferenceable(424) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 352
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !17, !noundef !18
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %22, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 280
  %7 = load ptr, ptr %6, align 8, !tbaa !19
  %8 = getelementptr inbounds i8, ptr %7, i64 2
  %9 = load i8, ptr %8, align 2, !tbaa !20, !range !17, !noundef !18
  %10 = trunc nuw i8 %9 to i1
  %11 = getelementptr inbounds i8, ptr %0, i64 288
  br i1 %10, label %43, label %12

12:                                               ; preds = %5
  %13 = getelementptr inbounds i8, ptr %0, i64 304
  %14 = tail call noundef double @_ZNK4Area8get_areaEv(ptr noundef nonnull align 8 dereferenceable(24) %13)
  %15 = load i32, ptr %11, align 8, !tbaa !22
  %16 = uitofp i32 %15 to double
  %17 = fmul double %14, %16
  %18 = getelementptr inbounds i8, ptr %0, i64 292
  %19 = load i32, ptr %18, align 4, !tbaa !23
  %20 = uitofp i32 %19 to double
  %21 = fmul double %17, %20
  br label %54

22:                                               ; preds = %1
  %23 = getelementptr inbounds i8, ptr %0, i64 328
  %24 = getelementptr inbounds i8, ptr %0, i64 336
  %25 = load double, ptr %24, align 8, !tbaa !24
  %26 = getelementptr inbounds i8, ptr %0, i64 288
  %27 = load i32, ptr %26, align 8, !tbaa !22
  %28 = add i32 %27, 1
  %29 = uitofp i32 %28 to double
  %30 = fmul double %25, %29
  %31 = load double, ptr %23, align 8, !tbaa !25
  %32 = getelementptr inbounds i8, ptr %0, i64 296
  %33 = load i32, ptr %32, align 8, !tbaa !26
  %34 = sitofp i32 %33 to double
  %35 = getelementptr inbounds i8, ptr %0, i64 304
  %36 = load double, ptr %35, align 8, !tbaa !27
  %37 = getelementptr inbounds i8, ptr %0, i64 300
  %38 = load i32, ptr %37, align 4, !tbaa !28
  %39 = sitofp i32 %38 to double
  %40 = fmul double %36, %39
  %41 = tail call double @llvm.fmuladd.f64(double %31, double %34, double %40)
  %42 = fmul double %30, %41
  br label %54

43:                                               ; preds = %5
  %44 = getelementptr inbounds i8, ptr %0, i64 328
  %45 = tail call noundef double @_ZNK4Area8get_areaEv(ptr noundef nonnull align 8 dereferenceable(24) %44)
  %46 = load i32, ptr %11, align 8, !tbaa !22
  %47 = add i32 %46, 1
  %48 = uitofp i32 %47 to double
  %49 = fmul double %45, %48
  %50 = getelementptr inbounds i8, ptr %0, i64 296
  %51 = load i32, ptr %50, align 8, !tbaa !26
  %52 = sitofp i32 %51 to double
  %53 = fmul double %49, %52
  br label %54

54:                                               ; preds = %43, %22, %12
  %.0 = phi double [ %42, %22 ], [ %53, %43 ], [ %21, %12 ]
  ret double %.0
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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, !16, i64 352}
!6 = !{!"_ZTS8Subarray", !7, i64 0, !14, i64 280, !15, i64 288, !15, i64 292, !15, i64 296, !15, i64 300, !8, i64 304, !8, i64 328, !16, i64 352, !9, i64 360, !9, i64 368, !9, i64 376, !9, i64 384, !9, i64 392, !9, i64 400, !9, i64 408, !9, i64 416}
!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 = !{!"int", !10, i64 0}
!16 = !{!"bool", !10, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!6, !14, i64 280}
!20 = !{!21, !16, i64 2}
!21 = !{!"_ZTS16DynamicParameter", !16, i64 0, !16, i64 1, !16, i64 2, !16, i64 3, !15, i64 4, !15, i64 8, !15, i64 12, !9, i64 16, !15, i64 24, !15, i64 28, !15, i64 32, !15, i64 36, !15, i64 40, !15, i64 44, !15, i64 48, !15, i64 52, !15, i64 56, !15, i64 60, !15, i64 64, !15, i64 68, !15, i64 72, !15, i64 76, !15, i64 80, !15, i64 84, !15, i64 88, !15, i64 92, !15, i64 96, !15, i64 100, !15, i64 104, !15, i64 108, !15, i64 112, !15, i64 116, !16, i64 120, !9, i64 128, !15, i64 136, !15, i64 140, !15, i64 144, !15, i64 148, !15, i64 152, !15, i64 156, !15, i64 160, !15, i64 164, !15, i64 168, !9, i64 176, !15, i64 184, !15, i64 188, !15, i64 192, !15, i64 196, !15, i64 200, !15, i64 204, !15, i64 208, !16, i64 212, !8, i64 216, !8, i64 240, !16, i64 264}
!22 = !{!6, !15, i64 288}
!23 = !{!6, !15, i64 292}
!24 = !{!6, !9, i64 336}
!25 = !{!6, !9, i64 328}
!26 = !{!6, !15, i64 296}
!27 = !{!6, !9, i64 304}
!28 = !{!6, !15, i64 300}


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