; LLVM IR from NVIDIA/TensorRT :: plugin/skipLayerNormPlugin (skipLayerNormPluginLegacy)

; 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.nvinfer1::plugin::bert::SkipLayerNormPluginDynamic" = type { %"class.nvinfer1::IPluginV2DynamicExt", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::unique_ptr", %"class.std::unique_ptr", i64, %"struct.nvinfer1::plugin::bert::WeightsWithOwnership", %"struct.nvinfer1::plugin::bert::WeightsWithOwnership", i32, i32, i8, %"class.std::unique_ptr", %"struct.nvinfer1::plugin::bert::WeightsWithOwnership", i64 }
%"class.nvinfer1::IPluginV2DynamicExt" = type { %"class.nvinfer1::IPluginV2Ext" }
%"class.nvinfer1::IPluginV2Ext" = type { %"class.nvinfer1::IPluginV2" }
%"class.nvinfer1::IPluginV2" = 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::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.5" }
%"struct.std::_Head_base.5" = type { ptr }
%"struct.nvinfer1::plugin::bert::WeightsWithOwnership" = type { %"class.nvinfer1::Weights" }
%"class.nvinfer1::Weights" = type { i32, ptr, i64 }

; 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 nounwind uwtable
define dso_local noundef i64 @_ZNK8nvinfer16plugin4bert26SkipLayerNormPluginDynamic20getSerializationSizeEv(ptr noundef nonnull align 8 dereferenceable(200) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %5 = getelementptr inbounds %"class.nvinfer1::plugin::bert::SkipLayerNormPluginDynamic", ptr %4, i32 0, i32 10
  %6 = load i8, ptr %5, align 8, !tbaa !9, !range !27, !noundef !28
  %7 = trunc i8 %6 to i1
  br i1 %7, label %8, label %14

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.nvinfer1::plugin::bert::SkipLayerNormPluginDynamic", ptr %4, i32 0, i32 5
  %10 = load i64, ptr %9, align 8, !tbaa !29
  %11 = getelementptr inbounds %"class.nvinfer1::plugin::bert::SkipLayerNormPluginDynamic", ptr %4, i32 0, i32 13
  %12 = load i64, ptr %11, align 8, !tbaa !30
  %13 = mul i64 %10, %12
  br label %15

14:                                               ; preds = %1
  br label %15

15:                                               ; preds = %14, %8
  %16 = phi i64 [ %13, %8 ], [ 0, %14 ]
  store i64 %16, ptr %3, align 8, !tbaa !31
  %17 = getelementptr inbounds %"class.nvinfer1::plugin::bert::SkipLayerNormPluginDynamic", ptr %4, i32 0, i32 13
  %18 = load i64, ptr %17, align 8, !tbaa !30
  %19 = mul i64 2, %18
  %20 = getelementptr inbounds %"class.nvinfer1::plugin::bert::SkipLayerNormPluginDynamic", ptr %4, i32 0, i32 5
  %21 = load i64, ptr %20, align 8, !tbaa !29
  %22 = mul i64 %19, %21
  %23 = add i64 %22, 8
  %24 = add i64 %23, 8
  %25 = load i64, ptr %3, align 8, !tbaa !31
  %26 = add i64 %24, %25
  %27 = add i64 %26, 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i64 %27
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !26, i64 152}
!10 = !{!"_ZTSN8nvinfer16plugin4bert26SkipLayerNormPluginDynamicE", !11, i64 0, !14, i64 8, !14, i64 40, !17, i64 72, !17, i64 80, !16, i64 88, !23, i64 96, !23, i64 120, !25, i64 144, !25, i64 148, !26, i64 152, !17, i64 160, !23, i64 168, !16, i64 192}
!11 = !{!"_ZTSN8nvinfer119IPluginV2DynamicExtE", !12, i64 0}
!12 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !13, i64 0}
!13 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSSt10unique_ptrIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_dataIvN8nvinfer114pluginInternal11CudaDeleterIvEELb1ELb1EE", !19, i64 0}
!19 = !{!"_ZTSSt15__uniq_ptr_implIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !20, i64 0}
!20 = !{!"_ZTSSt5tupleIJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !21, i64 0}
!21 = !{!"_ZTSSt11_Tuple_implILm0EJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !22, i64 0}
!22 = !{!"_ZTSSt10_Head_baseILm0EPvLb0EE", !6, i64 0}
!23 = !{!"_ZTSN8nvinfer16plugin4bert20WeightsWithOwnershipE", !24, i64 0}
!24 = !{!"_ZTSN8nvinfer17WeightsE", !25, i64 0, !6, i64 8, !16, i64 16}
!25 = !{!"_ZTSN8nvinfer18DataTypeE", !7, i64 0}
!26 = !{!"bool", !7, i64 0}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!10, !16, i64 88}
!30 = !{!10, !16, i64 192}
!31 = !{!16, !16, 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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef i64 @_ZNK8nvinfer16plugin4bert26SkipLayerNormPluginDynamic20getSerializationSizeEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(200) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 152
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !26, !noundef !27
  %4 = trunc nuw i8 %3 to i1
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 192
  %8 = load i64, ptr %7, align 8
  %9 = mul i64 %8, %6
  %10 = select i1 %4, i64 %9, i64 0
  %11 = shl i64 %6, 1
  %12 = mul i64 %11, %8
  %13 = add i64 %12, 17
  %14 = add i64 %13, %10
  ret i64 %14
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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" }

!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, !25, i64 152}
!6 = !{!"_ZTSN8nvinfer16plugin4bert26SkipLayerNormPluginDynamicE", !7, i64 0, !10, i64 8, !10, i64 40, !16, i64 72, !16, i64 80, !15, i64 88, !22, i64 96, !22, i64 120, !24, i64 144, !24, i64 148, !25, i64 152, !16, i64 160, !22, i64 168, !15, i64 192}
!7 = !{!"_ZTSN8nvinfer119IPluginV2DynamicExtE", !8, i64 0}
!8 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !9, i64 0}
!9 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!10 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !11, i64 0, !15, i64 8, !13, i64 16}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"long", !13, i64 0}
!16 = !{!"_ZTSSt10unique_ptrIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_dataIvN8nvinfer114pluginInternal11CudaDeleterIvEELb1ELb1EE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_implIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !19, i64 0}
!19 = !{!"_ZTSSt5tupleIJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !20, i64 0}
!20 = !{!"_ZTSSt11_Tuple_implILm0EJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !21, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm0EPvLb0EE", !12, i64 0}
!22 = !{!"_ZTSN8nvinfer16plugin4bert20WeightsWithOwnershipE", !23, i64 0}
!23 = !{!"_ZTSN8nvinfer17WeightsE", !24, i64 0, !12, i64 8, !15, i64 16}
!24 = !{!"_ZTSN8nvinfer18DataTypeE", !13, i64 0}
!25 = !{!"bool", !13, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass