; LLVM IR from gem5/gem5 :: ext/systemc/src/sysc/tracing (sc_wif_trace)

; 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.sc_core::wif_enum_trace" = type { %"class.sc_core::wif_trace.base", ptr, i32, ptr, i32, %"class.std::__cxx11::basic_string" }
%"class.sc_core::wif_trace.base" = type <{ ptr, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", ptr, i32 }>
%"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.sc_core::wif_trace" = type <{ ptr, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", ptr, i32, [4 x i8] }>

@_ZTVN7sc_core14wif_enum_traceE = external dso_local unnamed_addr constant { [8 x ptr] }, align 8
@.str.17 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7sc_core9wif_traceC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7sc_core14wif_enum_traceC2ERKjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_PPKc(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  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
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN7sc_core9wif_traceC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_(ptr noundef nonnull align 8 dereferenceable(84) %13, ptr noundef nonnull align 8 dereferenceable(32) %14, ptr noundef nonnull align 8 dereferenceable(32) %15)
  store ptr getelementptr inbounds inrange(-16, 48) ({ [8 x ptr] }, ptr @_ZTVN7sc_core14wif_enum_traceE, i32 0, i32 0, i32 2), ptr %13, align 8, !tbaa !9
  %16 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 1
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %17, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 2
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load i32, ptr %19, align 4, !tbaa !11
  store i32 %20, ptr %18, align 8, !tbaa !13
  %21 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 3
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %22, ptr %21, align 8, !tbaa !19
  %23 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 4
  store i32 0, ptr %23, align 8, !tbaa !20
  %24 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_(ptr dead_on_unwind writable sret(%"class.std::__cxx11::basic_string") align 8 %24, ptr noundef nonnull align 8 dereferenceable(32) %25, ptr noundef @.str.17)
          to label %26 unwind label %37

26:                                               ; preds = %5
  %27 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 4
  store i32 0, ptr %27, align 8, !tbaa !20
  br label %28

28:                                               ; preds = %41, %26
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 4
  %31 = load i32, ptr %30, align 8, !tbaa !20
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds ptr, ptr %29, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %45

36:                                               ; preds = %28
  br label %41

37:                                               ; preds = %5
  %38 = landingpad { ptr, i32 }
          cleanup
  %39 = extractvalue { ptr, i32 } %38, 0
  store ptr %39, ptr %11, align 8
  %40 = extractvalue { ptr, i32 } %38, 1
  store i32 %40, ptr %12, align 4
  call void @_ZN7sc_core9wif_traceD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %13) #3
  br label %50

41:                                               ; preds = %36
  %42 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 4
  %43 = load i32, ptr %42, align 8, !tbaa !20
  %44 = add i32 %43, 1
  store i32 %44, ptr %42, align 8, !tbaa !20
  br label %28, !llvm.loop !21

45:                                               ; preds = %28
  %46 = getelementptr inbounds %"class.sc_core::wif_trace", ptr %13, i32 0, i32 4
  store i32 0, ptr %46, align 8, !tbaa !23
  %47 = getelementptr inbounds %"class.sc_core::wif_enum_trace", ptr %13, i32 0, i32 5
  %48 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %47) #3
  %49 = getelementptr inbounds %"class.sc_core::wif_trace", ptr %13, i32 0, i32 3
  store ptr %48, ptr %49, align 8, !tbaa !24
  ret void

50:                                               ; preds = %37
  %51 = load ptr, ptr %11, align 8
  %52 = load i32, ptr %12, align 4
  %53 = insertvalue { ptr, i32 } poison, ptr %51, 0
  %54 = insertvalue { ptr, i32 } %53, i32 %52, 1
  resume { ptr, i32 } %54
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7sc_core9wif_traceD2Ev(ptr noundef nonnull align 8 dereferenceable(84)) unnamed_addr #1 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" }
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 = { inlinehint 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 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 96}
!14 = !{!"_ZTSN7sc_core14wif_enum_traceE", !15, i64 0, !6, i64 88, !12, i64 96, !6, i64 104, !12, i64 112, !16, i64 120}
!15 = !{!"_ZTSN7sc_core9wif_traceE", !16, i64 8, !16, i64 40, !6, i64 72, !12, i64 80}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!14, !6, i64 104}
!20 = !{!14, !12, i64 112}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!15, !12, i64 80}
!24 = !{!15, !6, i64 72}


; 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.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] }

@_ZTVN7sc_core14wif_enum_traceE = external dso_local unnamed_addr constant { [8 x ptr] }, align 8
@.str.17 = external hidden unnamed_addr constant [9 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7sc_core9wif_traceC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_(ptr noundef nonnull align 8 dereferenceable(84), ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7sc_core14wif_enum_traceC2ERKjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_PPKc(ptr noundef nonnull align 8 dereferenceable(152) %0, ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN7sc_core9wif_traceC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_(ptr noundef nonnull align 8 dereferenceable(84) %0, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %3)
  store ptr getelementptr inbounds inrange(-16, 48) (i8, ptr @_ZTVN7sc_core14wif_enum_traceE, i64 16), ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %1, ptr %6, align 8, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 96
  %8 = load i32, ptr %1, align 4, !tbaa !11
  store i32 %8, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  store ptr %4, ptr %9, align 8, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %0, i64 112
  store i32 0, ptr %10, align 8, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 120
  invoke void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_(ptr dead_on_unwind nonnull writable sret(%"class.std::__cxx11::basic_string") align 8 %11, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull @.str.17)
          to label %.preheader unwind label %16

.preheader:                                       ; preds = %5, %.preheader
  %storemerge = phi i32 [ %15, %.preheader ], [ 0, %5 ]
  %12 = zext i32 %storemerge to i64
  %13 = getelementptr inbounds ptr, ptr %4, i64 %12
  %14 = load ptr, ptr %13, align 8, !tbaa !8
  %.not = icmp eq ptr %14, null
  %15 = add i32 %storemerge, 1
  br i1 %.not, label %18, label %.preheader, !llvm.loop !21

16:                                               ; preds = %5
  %17 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN7sc_core9wif_traceD2Ev(ptr noundef nonnull align 8 dereferenceable(84) %0) #3
  resume { ptr, i32 } %17

18:                                               ; preds = %.preheader
  store i32 %storemerge, ptr %10, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  store i32 0, ptr %19, align 8, !tbaa !23
  %20 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv(ptr noundef nonnull align 8 dereferenceable(32) %11) #3
  %21 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %20, ptr %21, align 8, !tbaa !24
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EERKS8_PKS5_(ptr dead_on_unwind noalias writable sret(%"class.std::__cxx11::basic_string") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7sc_core9wif_traceD2Ev(ptr noundef nonnull align 8 dereferenceable(84)) unnamed_addr #1 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" }
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 = { inlinehint 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 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !10, i64 0}
!13 = !{!14, !12, i64 96}
!14 = !{!"_ZTSN7sc_core14wif_enum_traceE", !15, i64 0, !9, i64 88, !12, i64 96, !9, i64 104, !12, i64 112, !16, i64 120}
!15 = !{!"_ZTSN7sc_core9wif_traceE", !16, i64 8, !16, i64 40, !9, i64 72, !12, i64 80}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !10, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !9, i64 0}
!18 = !{!"long", !10, i64 0}
!19 = !{!14, !9, i64 104}
!20 = !{!14, !12, i64 112}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!15, !12, i64 80}
!24 = !{!15, !9, i64 72}


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