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

; 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.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 }
%struct.RUNTIME_FUNCTION = type { i32, i32, i32 }

@_ZTVN9NativeJIT14FunctionBufferE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8
@.str = external hidden unnamed_addr constant [84 x i8], align 1
@__FUNCTION__._ZN9NativeJIT14FunctionBufferC2ERN10Allocators10IAllocatorEj = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [39 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9NativeJIT14FunctionBufferC2ERN10Allocators10IAllocatorEj(ptr noundef nonnull align 8 dereferenceable(133) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load i32, ptr %6, align 4, !tbaa !9
  call void @_ZN9NativeJIT16X64CodeGeneratorC2ERN10Allocators10IAllocatorEj(ptr noundef nonnull align 8 dereferenceable(104) %9, ptr noundef nonnull align 8 dereferenceable(8) %10, i32 noundef %11)
  store ptr getelementptr inbounds inrange(-16, 32) ({ [6 x ptr] }, ptr @_ZTVN9NativeJIT14FunctionBufferE, i32 0, i32 0, i32 2), ptr %9, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %9, i32 0, i32 1
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 12, i1 false)
  %13 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %9, i32 0, i32 2
  store i32 0, ptr %13, align 4, !tbaa !13
  %14 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %9, i32 0, i32 3
  store i32 0, ptr %14, align 8, !tbaa !28
  %15 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %9, i32 0, i32 4
  store i32 0, ptr %15, align 4, !tbaa !29
  %16 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %9, i32 0, i32 5
  store i32 0, ptr %16, align 8, !tbaa !30
  %17 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %9, i32 0, i32 6
  store i8 0, ptr %17, align 4, !tbaa !31
  br label %18

18:                                               ; preds = %3
  %19 = getelementptr inbounds %"class.NativeJIT::FunctionBuffer", ptr %9, i32 0, i32 1
  %20 = ptrtoint ptr %19 to i64
  %21 = urem i64 %20, 4
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %29, label %23

23:                                               ; preds = %18
  invoke void (ptr, ptr, i32, ptr, ptr, ...) @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef @.str, ptr noundef @__FUNCTION__._ZN9NativeJIT14FunctionBufferC2ERN10Allocators10IAllocatorEj, i32 noundef 78, ptr noundef @.str.1, ptr noundef @.str.2)
          to label %24 unwind label %25

24:                                               ; preds = %23
  br label %29

25:                                               ; preds = %23
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %7, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %8, align 4
  call void @_ZN9NativeJIT10CodeBufferD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %9) #4
  br label %32

29:                                               ; preds = %24, %18
  br label %30

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30
  ret void

32:                                               ; preds = %25
  %33 = load ptr, ptr %7, align 8
  %34 = load i32, ptr %8, align 4
  %35 = insertvalue { ptr, i32 } poison, ptr %33, 0
  %36 = insertvalue { ptr, i32 } %35, i32 %34, 1
  resume { ptr, i32 } %36
}

declare void @_ZN9NativeJIT16X64CodeGeneratorC2ERN10Allocators10IAllocatorEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 8 dereferenceable(8), i32 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

declare void @_ZN9NativeJIT12LogThrowImplEPKcS1_jS1_S1_z(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN9NativeJIT10CodeBufferD2Ev(ptr noundef nonnull align 8 dereferenceable(96)) unnamed_addr #3

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


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

@_ZTVN9NativeJIT14FunctionBufferE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9NativeJIT14FunctionBufferC2ERN10Allocators10IAllocatorEj(ptr noundef nonnull align 8 dereferenceable(133) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN9NativeJIT16X64CodeGeneratorC2ERN10Allocators10IAllocatorEj(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2)
  store ptr getelementptr inbounds inrange(-16, 32) (i8, ptr @_ZTVN9NativeJIT14FunctionBufferE, i64 16), ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 104
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(29) %4, i8 0, i64 29, i1 false)
  ret void
}

declare void @_ZN9NativeJIT16X64CodeGeneratorC2ERN10Allocators10IAllocatorEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 8 dereferenceable(8), i32 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

declare i32 @__gxx_personality_v0(...)

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

!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: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass