; LLVM IR from BitFunnel/NativeJIT :: src/CodeGen/FunctionBuffer.ll (ZN9NativeJIT14FunctionBuffer5ResetEv)

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

%struct.RUNTIME_FUNCTION = type { i32, i32, i32 }
%"class.NativeJIT::FunctionBuffer" = type <{ %"class.NativeJIT::X64CodeGenerator", %struct.RUNTIME_FUNCTION, i32, i32, i32, i32, i8, [3 x i8] }>
%"class.NativeJIT::X64CodeGenerator" = type { %"class.NativeJIT::CodeBuffer", ptr }
%"class.NativeJIT::CodeBuffer" = type { ptr, ptr, i32, ptr, ptr, ptr, %"class.NativeJIT::JumpTable" }
%"class.NativeJIT::JumpTable" = type { %"class.std::vector", %"class.std::vector.0" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<const unsigned char *, std::allocator<const unsigned char *>>::_Vector_impl" }
%"struct.std::_Vector_base<const unsigned char *, std::allocator<const unsigned char *>>::_Vector_impl" = type { %"struct.std::_Vector_base<const unsigned char *, std::allocator<const unsigned char *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<const unsigned char *, std::allocator<const unsigned char *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<NativeJIT::CallSite, std::allocator<NativeJIT::CallSite>>::_Vector_impl" }
%"struct.std::_Vector_base<NativeJIT::CallSite, std::allocator<NativeJIT::CallSite>>::_Vector_impl" = type { %"struct.std::_Vector_base<NativeJIT::CallSite, std::allocator<NativeJIT::CallSite>>::_Vector_impl_data" }
%"struct.std::_Vector_base<NativeJIT::CallSite, std::allocator<NativeJIT::CallSite>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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 void @_ZN9NativeJIT14FunctionBuffer5ResetEv(ptr noundef nonnull align 8 dereferenceable(133) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %struct.RUNTIME_FUNCTION, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @_ZN9NativeJIT10CodeBuffer5ResetEv(ptr noundef nonnull align 8 dereferenceable(96) %4)
  %5 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %4, i32 0, i32 5
  store i32 0, ptr %5, align 8, !tbaa !9
  %6 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %4, i32 0, i32 4
  store i32 0, ptr %6, align 4, !tbaa !25
  %7 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %4, i32 0, i32 3
  store i32 0, ptr %7, align 8, !tbaa !26
  %8 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %4, i32 0, i32 2
  store i32 0, ptr %8, align 4, !tbaa !27
  %9 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %4, i32 0, i32 6
  store i8 0, ptr %9, align 4, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 12, ptr %3) #4
  %10 = getelementptr inbounds %struct.RUNTIME_FUNCTION, ptr %3, i32 0, i32 0
  store i32 0, ptr %10, align 4, !tbaa !29
  %11 = getelementptr inbounds %struct.RUNTIME_FUNCTION, ptr %3, i32 0, i32 1
  store i32 0, ptr %11, align 4, !tbaa !30
  %12 = getelementptr inbounds %struct.RUNTIME_FUNCTION, ptr %3, i32 0, i32 2
  store i32 0, ptr %12, align 4, !tbaa !31
  %13 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %4, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 4 %3, i64 12, i1 false), !tbaa.struct !32
  call void @llvm.lifetime.end.p0(i64 12, ptr %3) #4
  ret void
}

declare void @_ZN9NativeJIT10CodeBuffer5ResetEv(ptr noundef nonnull align 8 dereferenceable(96)) unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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 = { "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: readwrite) }
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, !13, i64 128}
!10 = !{!"_ZTSN9NativeJIT14FunctionBufferE", !11, i64 0, !23, i64 104, !13, i64 116, !13, i64 120, !13, i64 124, !13, i64 128, !24, i64 132}
!11 = !{!"_ZTSN9NativeJIT16X64CodeGeneratorE", !12, i64 0, !6, i64 96}
!12 = !{!"_ZTSN9NativeJIT10CodeBufferE", !6, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !14, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSN9NativeJIT9JumpTableE", !15, i64 0, !19, i64 24}
!15 = !{!"_ZTSSt6vectorIPKhSaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIPKhSaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIPKhSaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIPKhSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"_ZTSSt6vectorIN9NativeJIT8CallSiteESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIN9NativeJIT8CallSiteESaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN9NativeJIT8CallSiteESaIS1_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN9NativeJIT8CallSiteESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!"_ZTS16RUNTIME_FUNCTION", !13, i64 0, !13, i64 4, !13, i64 8}
!24 = !{!"bool", !7, i64 0}
!25 = !{!10, !13, i64 124}
!26 = !{!10, !13, i64 120}
!27 = !{!10, !13, i64 116}
!28 = !{!10, !24, i64 132}
!29 = !{!23, !13, i64 0}
!30 = !{!23, !13, i64 4}
!31 = !{!23, !13, i64 8}
!32 = !{i64 0, i64 4, !33, i64 4, i64 4, !33, i64 8, i64 4, !33}
!33 = !{!13, !13, i64 0}


; 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 void @_ZN9NativeJIT14FunctionBuffer5ResetEv(ptr noundef nonnull align 8 dereferenceable(133) %0) unnamed_addr #0 align 2 {
  tail call void @_ZN9NativeJIT10CodeBuffer5ResetEv(ptr noundef nonnull align 8 dereferenceable(96) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(29) %2, i8 0, i64 29, i1 false)
  ret void
}

declare void @_ZN9NativeJIT10CodeBuffer5ResetEv(ptr noundef nonnull align 8 dereferenceable(96)) 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

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

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


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