; LLVM IR from gem5/gem5 :: ext/dsent/libutil (Calculator)

; 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.LibUtil::Calculator" = type { ptr, %"class.LibUtil::String", %"class.LibUtil::Map", i32, double, %"class.LibUtil::String" }
%"class.LibUtil::Map" = type { ptr, %"class.std::map" }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<LibUtil::String, std::pair<const LibUtil::String, double>, std::_Select1st<std::pair<const LibUtil::String, double>>, std::less<LibUtil::String>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<LibUtil::String, std::pair<const LibUtil::String, double>, std::_Select1st<std::pair<const LibUtil::String, double>>, std::less<LibUtil::String>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.LibUtil::String" = type { %"class.std::__cxx11::basic_string" }
%"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] }

; 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 double @_ZN7LibUtil10Calculator4exprERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(120) %1, i1 noundef zeroext %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  %12 = zext i1 %2 to i8
  store i8 %12, ptr %8, align 1, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %16 = trunc i8 %15 to i1
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %10, align 8, !tbaa !5
  %19 = call noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %13, ptr noundef nonnull align 8 dereferenceable(120) %14, i1 noundef zeroext %16, ptr noundef nonnull align 8 dereferenceable(48) %17, ptr noundef %18)
  store double %19, ptr %11, align 8, !tbaa !13
  br label %20

20:                                               ; preds = %40, %5
  br label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds %"class.LibUtil::Calculator", ptr %13, i32 0, i32 3
  %23 = load i32, ptr %22, align 8, !tbaa !15
  switch i32 %23, label %38 [
    i32 43, label %24
    i32 45, label %31
  ]

24:                                               ; preds = %21
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = call noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %13, ptr noundef nonnull align 8 dereferenceable(120) %25, i1 noundef zeroext true, ptr noundef nonnull align 8 dereferenceable(48) %26, ptr noundef %27)
  %29 = load double, ptr %11, align 8, !tbaa !13
  %30 = fadd double %29, %28
  store double %30, ptr %11, align 8, !tbaa !13
  br label %40

31:                                               ; preds = %21
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = call noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %13, ptr noundef nonnull align 8 dereferenceable(120) %32, i1 noundef zeroext true, ptr noundef nonnull align 8 dereferenceable(48) %33, ptr noundef %34)
  %36 = load double, ptr %11, align 8, !tbaa !13
  %37 = fsub double %36, %35
  store double %37, ptr %11, align 8, !tbaa !13
  br label %40

38:                                               ; preds = %21
  %39 = load double, ptr %11, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  ret double %39

40:                                               ; preds = %31, %24
  br label %20, !llvm.loop !31
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144), ptr noundef nonnull align 8 dereferenceable(120), i1 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) #1 align 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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !30, i64 96}
!16 = !{!"_ZTSN7LibUtil10CalculatorE", !17, i64 8, !21, i64 40, !30, i64 96, !14, i64 104, !17, i64 112}
!17 = !{!"_ZTSN7LibUtil6StringE", !18, i64 0}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !19, i64 0, !20, i64 8, !7, i64 16}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSN7LibUtil3MapIdEE", !22, i64 8}
!22 = !{!"_ZTSSt3mapIN7LibUtil6StringEdSt4lessIS1_ESaISt4pairIKS1_dEEE", !23, i64 0}
!23 = !{!"_ZTSSt8_Rb_treeIN7LibUtil6StringESt4pairIKS1_dESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE", !24, i64 0}
!24 = !{!"_ZTSNSt8_Rb_treeIN7LibUtil6StringESt4pairIKS1_dESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE13_Rb_tree_implIS8_Lb1EEE", !25, i64 0, !27, i64 8}
!25 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN7LibUtil6StringEEE", !26, i64 0}
!26 = !{!"_ZTSSt4lessIN7LibUtil6StringEE"}
!27 = !{!"_ZTSSt15_Rb_tree_header", !28, i64 0, !20, i64 32}
!28 = !{!"_ZTSSt18_Rb_tree_node_base", !29, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!29 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!30 = !{!"_ZTSN7LibUtil10Calculator5TokenE", !7, i64 0}
!31 = distinct !{!31, !32}
!32 = !{!"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 double @_ZN7LibUtil10Calculator4exprERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(120) %1, i1 noundef zeroext %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef %4) local_unnamed_addr #0 align 2 {
  %6 = tail call noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(120) %1, i1 noundef zeroext %2, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef %4)
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  br label %8

8:                                                ; preds = %.backedge, %5
  %.0 = phi double [ %6, %5 ], [ %.0.be, %.backedge ]
  %9 = load i32, ptr %7, align 8, !tbaa !5
  switch i32 %9, label %16 [
    i32 43, label %10
    i32 45, label %13
  ]

10:                                               ; preds = %8
  %11 = tail call noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(120) %1, i1 noundef zeroext true, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef %4)
  %12 = fadd double %.0, %11
  br label %.backedge

13:                                               ; preds = %8
  %14 = tail call noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144) %0, ptr noundef nonnull align 8 dereferenceable(120) %1, i1 noundef zeroext true, ptr noundef nonnull align 8 dereferenceable(48) %3, ptr noundef %4)
  %15 = fsub double %.0, %14
  br label %.backedge

.backedge:                                        ; preds = %13, %10
  %.0.be = phi double [ %15, %13 ], [ %12, %10 ]
  br label %8, !llvm.loop !25

16:                                               ; preds = %8
  ret double %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN7LibUtil10Calculator4termERNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEEbRKSt3mapINS_6StringES9_St4lessIS9_ESaISt4pairIKS9_S9_EEEPN5DSENT5ModelE(ptr noundef nonnull align 8 dereferenceable(144), ptr noundef nonnull align 8 dereferenceable(120), i1 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(48), ptr noundef) local_unnamed_addr #0 align 2

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" }

!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, !23, i64 96}
!6 = !{!"_ZTSN7LibUtil10CalculatorE", !7, i64 8, !14, i64 40, !23, i64 96, !24, i64 104, !7, i64 112}
!7 = !{!"_ZTSN7LibUtil6StringE", !8, i64 0}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !9, i64 0, !13, i64 8, !11, i64 16}
!9 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"long", !11, i64 0}
!14 = !{!"_ZTSN7LibUtil3MapIdEE", !15, i64 8}
!15 = !{!"_ZTSSt3mapIN7LibUtil6StringEdSt4lessIS1_ESaISt4pairIKS1_dEEE", !16, i64 0}
!16 = !{!"_ZTSSt8_Rb_treeIN7LibUtil6StringESt4pairIKS1_dESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE", !17, i64 0}
!17 = !{!"_ZTSNSt8_Rb_treeIN7LibUtil6StringESt4pairIKS1_dESt10_Select1stIS4_ESt4lessIS1_ESaIS4_EE13_Rb_tree_implIS8_Lb1EEE", !18, i64 0, !20, i64 8}
!18 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIN7LibUtil6StringEEE", !19, i64 0}
!19 = !{!"_ZTSSt4lessIN7LibUtil6StringEE"}
!20 = !{!"_ZTSSt15_Rb_tree_header", !21, i64 0, !13, i64 32}
!21 = !{!"_ZTSSt18_Rb_tree_node_base", !22, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!22 = !{!"_ZTSSt14_Rb_tree_color", !11, i64 0}
!23 = !{!"_ZTSN7LibUtil10Calculator5TokenE", !11, i64 0}
!24 = !{!"double", !11, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass