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

; 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_trace_file" = type { %"class.sc_core::sc_trace_file_base.base", i32, i32, i32, double, %"class.std::vector.0" }
%"class.sc_core::sc_trace_file_base.base" = type <{ %"class.sc_core::sc_trace_file", ptr, double, i8, [7 x i8], %"class.std::__cxx11::basic_string", i8, i8 }>
%"class.sc_core::sc_trace_file" = type { ptr }
%"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.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<sc_core::wif_trace *, std::allocator<sc_core::wif_trace *>>::_Vector_impl" }
%"struct.std::_Vector_base<sc_core::wif_trace *, std::allocator<sc_core::wif_trace *>>::_Vector_impl" = type { %"struct.std::_Vector_base<sc_core::wif_trace *, std::allocator<sc_core::wif_trace *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<sc_core::wif_trace *, std::allocator<sc_core::wif_trace *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.23 = external hidden unnamed_addr constant [5 x i8], align 1
@_ZTVN7sc_core14wif_trace_fileE = external dso_local unnamed_addr constant { [36 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7sc_core14wif_trace_fileC2EPKc(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN7sc_core18sc_trace_file_baseC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(66) %5, ptr noundef %6, ptr noundef @.str.23)
  store ptr getelementptr inbounds inrange(-16, 272) ({ [36 x ptr] }, ptr @_ZTVN7sc_core14wif_trace_fileE, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.sc_core::wif_trace_file", ptr %5, i32 0, i32 1
  store i32 0, ptr %7, align 4, !tbaa !11
  %8 = getelementptr inbounds %"class.sc_core::wif_trace_file", ptr %5, i32 0, i32 2
  store i32 0, ptr %8, align 8, !tbaa !25
  %9 = getelementptr inbounds %"class.sc_core::wif_trace_file", ptr %5, i32 0, i32 3
  store i32 0, ptr %9, align 4, !tbaa !26
  %10 = getelementptr inbounds %"class.sc_core::wif_trace_file", ptr %5, i32 0, i32 4
  store double 0.000000e+00, ptr %10, align 8, !tbaa !27
  %11 = getelementptr inbounds %"class.sc_core::wif_trace_file", ptr %5, i32 0, i32 5
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorIPN7sc_core9wif_traceESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %11) #4
  ret void
}

declare void @_ZN7sc_core18sc_trace_file_baseC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(66), ptr noundef, ptr noundef) unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIPN7sc_core9wif_traceESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !20, i64 68}
!12 = !{!"_ZTSN7sc_core14wif_trace_fileE", !13, i64 0, !20, i64 68, !20, i64 72, !20, i64 76, !15, i64 80, !21, i64 88}
!13 = !{!"_ZTSN7sc_core18sc_trace_file_baseE", !14, i64 0, !6, i64 8, !15, i64 16, !16, i64 24, !17, i64 32, !16, i64 64, !16, i64 65}
!14 = !{!"_ZTSN7sc_core13sc_trace_fileE"}
!15 = !{!"double", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !19, i64 8, !7, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!"_ZTSSt6vectorIPN7sc_core9wif_traceESaIS2_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseIPN7sc_core9wif_traceESaIS2_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIPN7sc_core9wif_traceESaIS2_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIPN7sc_core9wif_traceESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!12, !20, i64 72}
!26 = !{!12, !20, i64 76}
!27 = !{!12, !15, i64 80}


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

@.str.23 = external hidden unnamed_addr constant [5 x i8], align 1
@_ZTVN7sc_core14wif_trace_fileE = external dso_local unnamed_addr constant { [36 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7sc_core14wif_trace_fileC2EPKc(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef %1) unnamed_addr #0 align 2 {
  tail call void @_ZN7sc_core18sc_trace_file_baseC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(66) %0, ptr noundef %1, ptr noundef nonnull @.str.23)
  store ptr getelementptr inbounds inrange(-16, 272) (i8, ptr @_ZTVN7sc_core14wif_trace_fileE, i64 16), ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 68
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(44) %3, i8 0, i64 44, i1 false)
  tail call void @_ZNSt6vectorIPN7sc_core9wif_traceESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #4
  ret void
}

declare void @_ZN7sc_core18sc_trace_file_baseC2EPKcS2_(ptr noundef nonnull align 8 dereferenceable(66), ptr noundef, ptr noundef) unnamed_addr #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIPN7sc_core9wif_traceESaIS2_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 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 = { "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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass