; LLVM IR from balintbalazs/B3D :: source/src/B3D_cudaCompress/profiler/profiler.ll (ZN8ProfilerC2Ev)

; 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.Profiler = type { [100 x %"struct.Profiler::sample"], %"class.std::set", i32, i32, i32, i32, i32, i64, i64, i32, i64, i64, i32, i64, i8, i64, i64, i64 }
%"struct.Profiler::sample" = type { i8, %"class.std::__cxx11::basic_string", i32, i32, i8, i64, i64, i64, i64, i64, i32, i32, i32, i32, i64 }
%"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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<IProfilerOutputHandler *, IProfilerOutputHandler *, std::_Identity<IProfilerOutputHandler *>, std::less<IProfilerOutputHandler *>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<IProfilerOutputHandler *, IProfilerOutputHandler *, std::_Identity<IProfilerOutputHandler *>, std::less<IProfilerOutputHandler *>>::_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 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8ProfilerC2Ev(ptr noundef nonnull align 8 dereferenceable(12160) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 0
  %7 = getelementptr inbounds [100 x %"struct.Profiler::sample"], ptr %6, i32 0, i32 0
  %8 = getelementptr inbounds %"struct.Profiler::sample", ptr %7, i64 100
  br label %9

9:                                                ; preds = %11, %1
  %10 = phi ptr [ %7, %1 ], [ %12, %11 ]
  invoke void @_ZN8Profiler6sampleC2Ev(ptr noundef nonnull align 8 dereferenceable(120) %10)
          to label %11 unwind label %36

11:                                               ; preds = %9
  %12 = getelementptr inbounds %"struct.Profiler::sample", ptr %10, i64 1
  %13 = icmp eq ptr %12, %8
  br i1 %13, label %14, label %9

14:                                               ; preds = %11
  %15 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 1
  call void @_ZNSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %15) #3
  %16 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 2
  store i32 8, ptr %16, align 8, !tbaa !9
  %17 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 3
  store i32 -1, ptr %17, align 4, !tbaa !23
  %18 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 4
  store i32 0, ptr %18, align 8, !tbaa !24
  %19 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 5
  store i32 0, ptr %19, align 4, !tbaa !25
  %20 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 6
  store i32 0, ptr %20, align 8, !tbaa !26
  %21 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 8
  store i64 0, ptr %21, align 8, !tbaa !27
  %22 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 9
  store i32 0, ptr %22, align 8, !tbaa !28
  %23 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 10
  store i64 0, ptr %23, align 8, !tbaa !29
  %24 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 11
  store i64 0, ptr %24, align 8, !tbaa !30
  %25 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 12
  store i32 0, ptr %25, align 8, !tbaa !31
  %26 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 13
  store i64 0, ptr %26, align 8, !tbaa !32
  %27 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 14
  store i8 0, ptr %27, align 8, !tbaa !33
  %28 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 15
  store i64 0, ptr %28, align 8, !tbaa !34
  %29 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 16
  store i64 0, ptr %29, align 8, !tbaa !35
  %30 = invoke noundef i64 @_ZN12_GLOBAL__N_117getTimerFrequencyEv()
          to label %31 unwind label %46

31:                                               ; preds = %14
  %32 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 17
  store i64 %30, ptr %32, align 8, !tbaa !36
  %33 = invoke noundef i64 @_ZN12_GLOBAL__N_17getTimeEv()
          to label %34 unwind label %46

34:                                               ; preds = %31
  %35 = getelementptr inbounds %class.Profiler, ptr %5, i32 0, i32 7
  store i64 %33, ptr %35, align 8, !tbaa !37
  ret void

36:                                               ; preds = %9
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %3, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %4, align 4
  %40 = icmp eq ptr %7, %10
  br i1 %40, label %45, label %41

41:                                               ; preds = %41, %36
  %42 = phi ptr [ %10, %36 ], [ %43, %41 ]
  %43 = getelementptr inbounds %"struct.Profiler::sample", ptr %42, i64 -1
  call void @_ZN8Profiler6sampleD2Ev(ptr noundef nonnull align 8 dereferenceable(120) %43) #3
  %44 = icmp eq ptr %43, %7
  br i1 %44, label %45, label %41

45:                                               ; preds = %41, %36
  br label %57

46:                                               ; preds = %31, %14
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %3, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %4, align 4
  call void @_ZNSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48) %15) #3
  %50 = getelementptr inbounds [100 x %"struct.Profiler::sample"], ptr %6, i32 0, i32 0
  %51 = getelementptr inbounds %"struct.Profiler::sample", ptr %50, i64 100
  br label %52

52:                                               ; preds = %52, %46
  %53 = phi ptr [ %51, %46 ], [ %54, %52 ]
  %54 = getelementptr inbounds %"struct.Profiler::sample", ptr %53, i64 -1
  call void @_ZN8Profiler6sampleD2Ev(ptr noundef nonnull align 8 dereferenceable(120) %54) #3
  %55 = icmp eq ptr %54, %50
  br i1 %55, label %56, label %52

56:                                               ; preds = %52
  br label %57

57:                                               ; preds = %56, %45
  %58 = load ptr, ptr %3, align 8
  %59 = load i32, ptr %4, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN12_GLOBAL__N_117getTimerFrequencyEv() #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN12_GLOBAL__N_17getTimeEv() #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(48)) 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 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 #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, !20, i64 12048}
!10 = !{!"_ZTS8Profiler", !7, i64 0, !11, i64 12000, !20, i64 12048, !20, i64 12052, !20, i64 12056, !20, i64 12060, !20, i64 12064, !21, i64 12072, !21, i64 12080, !20, i64 12088, !21, i64 12096, !21, i64 12104, !20, i64 12112, !21, i64 12120, !22, i64 12128, !21, i64 12136, !21, i64 12144, !21, i64 12152}
!11 = !{!"_ZTSSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt8_Rb_treeIP22IProfilerOutputHandlerS1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt8_Rb_treeIP22IProfilerOutputHandlerS1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE13_Rb_tree_implIS5_Lb1EEE", !14, i64 0, !16, i64 8}
!14 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIP22IProfilerOutputHandlerEE", !15, i64 0}
!15 = !{!"_ZTSSt4lessIP22IProfilerOutputHandlerE"}
!16 = !{!"_ZTSSt15_Rb_tree_header", !17, i64 0, !19, i64 32}
!17 = !{!"_ZTSSt18_Rb_tree_node_base", !18, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!"long long", !7, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{!10, !20, i64 12052}
!24 = !{!10, !20, i64 12056}
!25 = !{!10, !20, i64 12060}
!26 = !{!10, !20, i64 12064}
!27 = !{!10, !21, i64 12080}
!28 = !{!10, !20, i64 12088}
!29 = !{!10, !21, i64 12096}
!30 = !{!10, !21, i64 12104}
!31 = !{!10, !20, i64 12112}
!32 = !{!10, !21, i64 12120}
!33 = !{!10, !22, i64 12128}
!34 = !{!10, !21, i64 12136}
!35 = !{!10, !21, i64 12144}
!36 = !{!10, !21, i64 12152}
!37 = !{!10, !21, i64 12072}


; 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 nounwind uwtable
define dso_local void @_ZN8ProfilerC2Ev(ptr noundef nonnull align 8 dereferenceable(12160) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  br label %2

2:                                                ; preds = %2, %1
  %.idx = phi i64 [ 0, %1 ], [ %.add, %2 ]
  %.ptr = getelementptr inbounds i8, ptr %0, i64 %.idx
  tail call void @_ZN8Profiler6sampleC2Ev(ptr noundef nonnull align 8 dereferenceable(120) %.ptr)
  %.add = add nuw nsw i64 %.idx, 120
  %3 = icmp eq i64 %.add, 12000
  br i1 %3, label %4, label %2

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 12000
  tail call void @_ZNSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48) %5) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 12048
  store <4 x i32> <i32 8, i32 -1, i32 0, i32 0>, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 12064
  store i32 0, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds i8, ptr %0, i64 12080
  store i64 0, ptr %8, align 8, !tbaa !23
  %9 = getelementptr inbounds i8, ptr %0, i64 12088
  store i32 0, ptr %9, align 8, !tbaa !24
  %10 = getelementptr inbounds i8, ptr %0, i64 12096
  %11 = getelementptr inbounds i8, ptr %0, i64 12120
  store i64 0, ptr %11, align 8, !tbaa !25
  %12 = getelementptr inbounds i8, ptr %0, i64 12128
  store i8 0, ptr %12, align 8, !tbaa !26
  %13 = getelementptr inbounds i8, ptr %0, i64 12136
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(20) %10, i8 0, i64 20, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %13, i8 0, i64 16, i1 false)
  %14 = tail call noundef i64 @_ZN12_GLOBAL__N_117getTimerFrequencyEv()
  %15 = getelementptr inbounds i8, ptr %0, i64 12152
  store i64 %14, ptr %15, align 8, !tbaa !27
  %16 = tail call noundef i64 @_ZN12_GLOBAL__N_17getTimeEv()
  %17 = getelementptr inbounds i8, ptr %0, i64 12072
  store i64 %16, ptr %17, align 8, !tbaa !28
  ret void
}

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN12_GLOBAL__N_117getTimerFrequencyEv() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN12_GLOBAL__N_17getTimeEv() local_unnamed_addr #0

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

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 12064}
!10 = !{!"_ZTS8Profiler", !7, i64 0, !11, i64 12000, !6, i64 12048, !6, i64 12052, !6, i64 12056, !6, i64 12060, !6, i64 12064, !21, i64 12072, !21, i64 12080, !6, i64 12088, !21, i64 12096, !21, i64 12104, !6, i64 12112, !21, i64 12120, !22, i64 12128, !21, i64 12136, !21, i64 12144, !21, i64 12152}
!11 = !{!"_ZTSSt3setIP22IProfilerOutputHandlerSt4lessIS1_ESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt8_Rb_treeIP22IProfilerOutputHandlerS1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt8_Rb_treeIP22IProfilerOutputHandlerS1_St9_IdentityIS1_ESt4lessIS1_ESaIS1_EE13_Rb_tree_implIS5_Lb1EEE", !14, i64 0, !16, i64 8}
!14 = !{!"_ZTSSt20_Rb_tree_key_compareISt4lessIP22IProfilerOutputHandlerEE", !15, i64 0}
!15 = !{!"_ZTSSt4lessIP22IProfilerOutputHandlerE"}
!16 = !{!"_ZTSSt15_Rb_tree_header", !17, i64 0, !20, i64 32}
!17 = !{!"_ZTSSt18_Rb_tree_node_base", !18, i64 0, !19, i64 8, !19, i64 16, !19, i64 24}
!18 = !{!"_ZTSSt14_Rb_tree_color", !7, i64 0}
!19 = !{!"any pointer", !7, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"long long", !7, i64 0}
!22 = !{!"bool", !7, i64 0}
!23 = !{!10, !21, i64 12080}
!24 = !{!10, !6, i64 12088}
!25 = !{!10, !21, i64 12120}
!26 = !{!10, !22, i64 12128}
!27 = !{!10, !21, i64 12152}
!28 = !{!10, !21, i64 12072}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass