; LLVM IR from gem5/gem5 :: ext/mcpat/cacti/decoder.ll (ZN6DriverC2Edddb)

; 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.Driver = type <{ %class.Component, i32, i32, [20 x double], [20 x double], double, double, double, double, %class.powerDef, i8, [7 x i8] }>
%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 }

declare void @_ZN9ComponentC2Ev(ptr noundef nonnull align 8 dereferenceable(280)) unnamed_addr #0

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN9ComponentD2Ev(ptr noundef nonnull align 8 dereferenceable(280)) unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8powerDefC2Ev(ptr noundef nonnull align 8 dereferenceable(120)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6DriverC2Edddb(ptr noundef nonnull align 8 dereferenceable(761) %0, double noundef %1, double noundef %2, double noundef %3, i1 noundef zeroext %4) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  %14 = zext i1 %4 to i8
  store i8 %14, ptr %10, align 1, !tbaa !11
  %15 = load ptr, ptr %6, align 8
  call void @_ZN9ComponentC2Ev(ptr noundef nonnull align 8 dereferenceable(280) %15)
  %16 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 1
  store i32 0, ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 2
  store i32 2, ptr %17, align 4, !tbaa !20
  %18 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 5
  %19 = load double, ptr %7, align 8, !tbaa !9
  store double %19, ptr %18, align 8, !tbaa !21
  %20 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 6
  %21 = load double, ptr %8, align 8, !tbaa !9
  store double %21, ptr %20, align 8, !tbaa !22
  %22 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 7
  %23 = load double, ptr %9, align 8, !tbaa !9
  store double %23, ptr %22, align 8, !tbaa !23
  %24 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 8
  store double 0.000000e+00, ptr %24, align 8, !tbaa !24
  %25 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 9
  invoke void @_ZN8powerDefC2Ev(ptr noundef nonnull align 8 dereferenceable(120) %25)
          to label %26 unwind label %35

26:                                               ; preds = %5
  %27 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 10
  %28 = load i8, ptr %10, align 1, !tbaa !11, !range !25, !noundef !26
  %29 = trunc i8 %28 to i1
  %30 = zext i1 %29 to i8
  store i8 %30, ptr %27, align 8, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !28
  br label %31

31:                                               ; preds = %48, %26
  %32 = load i32, ptr %13, align 4, !tbaa !28
  %33 = icmp slt i32 %32, 20
  br i1 %33, label %39, label %34

34:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %51

35:                                               ; preds = %51, %5
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %11, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %12, align 4
  call void @_ZN9ComponentD2Ev(ptr noundef nonnull align 8 dereferenceable(280) %15) #4
  br label %53

39:                                               ; preds = %31
  %40 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 3
  %41 = load i32, ptr %13, align 4, !tbaa !28
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [20 x double], ptr %40, i64 0, i64 %42
  store double 0.000000e+00, ptr %43, align 8, !tbaa !9
  %44 = getelementptr inbounds %class.Driver, ptr %15, i32 0, i32 4
  %45 = load i32, ptr %13, align 4, !tbaa !28
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [20 x double], ptr %44, i64 0, i64 %46
  store double 0.000000e+00, ptr %47, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %39
  %49 = load i32, ptr %13, align 4, !tbaa !28
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %13, align 4, !tbaa !28
  br label %31, !llvm.loop !29

51:                                               ; preds = %34
  invoke void @_ZN6Driver14compute_widthsEv(ptr noundef nonnull align 8 dereferenceable(761) %15)
          to label %52 unwind label %35

52:                                               ; preds = %51
  ret void

53:                                               ; preds = %35
  %54 = load ptr, ptr %11, align 8
  %55 = load i32, ptr %12, align 4
  %56 = insertvalue { ptr, i32 } poison, ptr %54, 0
  %57 = insertvalue { ptr, i32 } %56, i32 %55, 1
  resume { ptr, i32 } %57
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Driver14compute_widthsEv(ptr noundef nonnull align 8 dereferenceable(761)) #3 align 2

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = !{!"bool", !7, i64 0}
!13 = !{!14, !19, i64 280}
!14 = !{!"_ZTS6Driver", !15, i64 0, !19, i64 280, !19, i64 284, !7, i64 288, !7, i64 448, !10, i64 608, !10, i64 616, !10, i64 624, !10, i64 632, !17, i64 640, !12, i64 760}
!15 = !{!"_ZTS9Component", !16, i64 0, !17, i64 24, !17, i64 144, !10, i64 264, !10, i64 272}
!16 = !{!"_ZTS4Area", !10, i64 0, !10, i64 8, !10, i64 16}
!17 = !{!"_ZTS8powerDef", !18, i64 0, !18, i64 40, !18, i64 80}
!18 = !{!"_ZTS15powerComponents", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!19 = !{!"int", !7, i64 0}
!20 = !{!14, !19, i64 284}
!21 = !{!14, !10, i64 608}
!22 = !{!14, !10, i64 616}
!23 = !{!14, !10, i64 624}
!24 = !{!14, !10, i64 632}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!14, !12, i64 760}
!28 = !{!19, !19, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"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"

declare void @_ZN9ComponentC2Ev(ptr noundef nonnull align 8 dereferenceable(280)) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN9ComponentD2Ev(ptr noundef nonnull align 8 dereferenceable(280)) unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8powerDefC2Ev(ptr noundef nonnull align 8 dereferenceable(120)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6DriverC2Edddb(ptr noundef nonnull align 8 dereferenceable(761) %0, double noundef %1, double noundef %2, double noundef %3, i1 noundef zeroext %4) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN9ComponentC2Ev(ptr noundef nonnull align 8 dereferenceable(280) %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 280
  store i32 0, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 284
  store i32 2, ptr %7, align 4, !tbaa !16
  %8 = getelementptr inbounds i8, ptr %0, i64 608
  store double %1, ptr %8, align 8, !tbaa !17
  %9 = getelementptr inbounds i8, ptr %0, i64 616
  store double %2, ptr %9, align 8, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 624
  store double %3, ptr %10, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 632
  store double 0.000000e+00, ptr %11, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %0, i64 640
  invoke void @_ZN8powerDefC2Ev(ptr noundef nonnull align 8 dereferenceable(120) %12)
          to label %13 unwind label %17

13:                                               ; preds = %5
  %14 = zext i1 %4 to i8
  %15 = getelementptr inbounds i8, ptr %0, i64 760
  store i8 %14, ptr %15, align 8, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %0, i64 288
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(320) %16, i8 0, i64 320, i1 false)
  invoke void @_ZN6Driver14compute_widthsEv(ptr noundef nonnull align 8 dereferenceable(761) %0)
          to label %19 unwind label %17

17:                                               ; preds = %13, %5
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN9ComponentD2Ev(ptr noundef nonnull align 8 dereferenceable(280) %0) #4
  resume { ptr, i32 } %18

19:                                               ; preds = %13
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6Driver14compute_widthsEv(ptr noundef nonnull align 8 dereferenceable(761)) local_unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #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 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !14, i64 280}
!6 = !{!"_ZTS6Driver", !7, i64 0, !14, i64 280, !14, i64 284, !10, i64 288, !10, i64 448, !9, i64 608, !9, i64 616, !9, i64 624, !9, i64 632, !12, i64 640, !15, i64 760}
!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 = !{!"int", !10, i64 0}
!15 = !{!"bool", !10, i64 0}
!16 = !{!6, !14, i64 284}
!17 = !{!6, !9, i64 608}
!18 = !{!6, !9, i64 616}
!19 = !{!6, !9, i64 624}
!20 = !{!6, !9, i64 632}
!21 = !{!6, !15, i64 760}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass