; LLVM IR from NVIDIA/TensorRT :: plugin/embLayerNormPlugin (embLayerNormPluginLegacy)

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

@.str = external hidden unnamed_addr constant [104 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [54 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #0

declare void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK8nvinfer16plugin4bert31EmbLayerNormPluginDynamicLegacy17getOutputDataTypeEiPKNS_8DataTypeEi(ptr noundef nonnull align 8 dereferenceable(288) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %10 = load ptr, ptr %6, align 8
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %18, label %13

13:                                               ; preds = %4
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 1
  br i1 %15, label %18, label %16

16:                                               ; preds = %13
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.39, ptr noundef @.str, i32 noundef 403)
          to label %17 unwind label %37

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17, %13, %4
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %34

21:                                               ; preds = %18
  %22 = getelementptr inbounds %"class.nvinfer1::plugin::bert::EmbLayerNormPluginDynamicLegacy", ptr %10, i32 0, i32 18
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %31, label %25

25:                                               ; preds = %21
  %26 = getelementptr inbounds %"class.nvinfer1::plugin::bert::EmbLayerNormPluginDynamicLegacy", ptr %10, i32 0, i32 18
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %31, label %29

29:                                               ; preds = %25
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.40, ptr noundef @.str, i32 noundef 406)
          to label %30 unwind label %37

30:                                               ; preds = %29
  br label %31

31:                                               ; preds = %30, %25, %21
  %32 = getelementptr inbounds %"class.nvinfer1::plugin::bert::EmbLayerNormPluginDynamicLegacy", ptr %10, i32 0, i32 18
  %33 = load i32, ptr %32, align 8, !tbaa !11
  store i32 %33, ptr %5, align 4
  br label %35

34:                                               ; preds = %18
  store i32 3, ptr %5, align 4
  br label %35

35:                                               ; preds = %34, %31
  %36 = load i32, ptr %5, align 4
  ret i32 %36

37:                                               ; preds = %29, %16
  %38 = landingpad { ptr, i32 }
          catch ptr null
  %39 = extractvalue { ptr, i32 } %38, 0
  call void @__clang_call_terminate(ptr %39) #3
  unreachable
}

attributes #0 = { noinline noreturn nounwind uwtable "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 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 = { noreturn 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, !33, i64 272}
!12 = !{!"_ZTSN8nvinfer16plugin4bert31EmbLayerNormPluginDynamicLegacyE", !13, i64 0, !16, i64 8, !16, i64 40, !19, i64 72, !19, i64 80, !25, i64 88, !25, i64 96, !25, i64 104, !18, i64 112, !18, i64 120, !18, i64 128, !18, i64 136, !18, i64 144, !31, i64 152, !31, i64 176, !31, i64 200, !31, i64 224, !31, i64 248, !33, i64 272, !34, i64 276, !33, i64 280, !10, i64 284}
!13 = !{!"_ZTSN8nvinfer119IPluginV2DynamicExtE", !14, i64 0}
!14 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !15, i64 0}
!15 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSSt10unique_ptrIfN8nvinfer114pluginInternal11CudaDeleterIfEEE", !20, i64 0}
!20 = !{!"_ZTSSt15__uniq_ptr_dataIfN8nvinfer114pluginInternal11CudaDeleterIfEELb1ELb1EE", !21, i64 0}
!21 = !{!"_ZTSSt15__uniq_ptr_implIfN8nvinfer114pluginInternal11CudaDeleterIfEEE", !22, i64 0}
!22 = !{!"_ZTSSt5tupleIJPfN8nvinfer114pluginInternal11CudaDeleterIfEEEE", !23, i64 0}
!23 = !{!"_ZTSSt11_Tuple_implILm0EJPfN8nvinfer114pluginInternal11CudaDeleterIfEEEE", !24, i64 0}
!24 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !6, i64 0}
!25 = !{!"_ZTSSt10unique_ptrIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !26, i64 0}
!26 = !{!"_ZTSSt15__uniq_ptr_dataIvN8nvinfer114pluginInternal11CudaDeleterIvEELb1ELb1EE", !27, i64 0}
!27 = !{!"_ZTSSt15__uniq_ptr_implIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !28, i64 0}
!28 = !{!"_ZTSSt5tupleIJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !29, i64 0}
!29 = !{!"_ZTSSt11_Tuple_implILm0EJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !30, i64 0}
!30 = !{!"_ZTSSt10_Head_baseILm0EPvLb0EE", !6, i64 0}
!31 = !{!"_ZTSN8nvinfer16plugin4bert20WeightsWithOwnershipE", !32, i64 0}
!32 = !{!"_ZTSN8nvinfer17WeightsE", !33, i64 0, !6, i64 8, !18, i64 16}
!33 = !{!"_ZTSN8nvinfer18DataTypeE", !7, i64 0}
!34 = !{!"bool", !7, 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"

@.str = external hidden unnamed_addr constant [104 x i8], align 1
@.str.39 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.40 = external hidden unnamed_addr constant [54 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #0

declare void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK8nvinfer16plugin4bert31EmbLayerNormPluginDynamicLegacy17getOutputDataTypeEiPKNS_8DataTypeEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(288) %0, i32 noundef %1, ptr nocapture noundef readnone %2, i32 noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %or.cond = icmp ult i32 %1, 2
  br i1 %or.cond, label %6, label %5

5:                                                ; preds = %4
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.39, ptr noundef nonnull @.str, i32 noundef 403)
          to label %.thread unwind label %12

6:                                                ; preds = %4
  %7 = icmp eq i32 %1, 0
  br i1 %7, label %8, label %.thread

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 272
  %10 = load i32, ptr %9, align 8, !tbaa !5
  %switch = icmp ult i32 %10, 2
  br i1 %switch, label %.thread, label %11

11:                                               ; preds = %8
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.40, ptr noundef nonnull @.str, i32 noundef 406)
          to label %._crit_edge unwind label %12

._crit_edge:                                      ; preds = %11
  %.pre = load i32, ptr %9, align 8, !tbaa !5
  br label %.thread

.thread:                                          ; preds = %8, %._crit_edge, %5, %6
  %.0 = phi i32 [ 3, %6 ], [ 3, %5 ], [ %.pre, %._crit_edge ], [ %10, %8 ]
  ret i32 %.0

12:                                               ; preds = %11, %5
  %13 = landingpad { ptr, i32 }
          catch ptr null
  %14 = extractvalue { ptr, i32 } %13, 0
  tail call void @__clang_call_terminate(ptr %14) #3
  unreachable
}

attributes #0 = { noinline noreturn nounwind uwtable "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 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 = { noreturn 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, !30, i64 272}
!6 = !{!"_ZTSN8nvinfer16plugin4bert31EmbLayerNormPluginDynamicLegacyE", !7, i64 0, !10, i64 8, !10, i64 40, !16, i64 72, !16, i64 80, !22, i64 88, !22, i64 96, !22, i64 104, !15, i64 112, !15, i64 120, !15, i64 128, !15, i64 136, !15, i64 144, !28, i64 152, !28, i64 176, !28, i64 200, !28, i64 224, !28, i64 248, !30, i64 272, !31, i64 276, !30, i64 280, !32, i64 284}
!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_ptrIfN8nvinfer114pluginInternal11CudaDeleterIfEEE", !17, i64 0}
!17 = !{!"_ZTSSt15__uniq_ptr_dataIfN8nvinfer114pluginInternal11CudaDeleterIfEELb1ELb1EE", !18, i64 0}
!18 = !{!"_ZTSSt15__uniq_ptr_implIfN8nvinfer114pluginInternal11CudaDeleterIfEEE", !19, i64 0}
!19 = !{!"_ZTSSt5tupleIJPfN8nvinfer114pluginInternal11CudaDeleterIfEEEE", !20, i64 0}
!20 = !{!"_ZTSSt11_Tuple_implILm0EJPfN8nvinfer114pluginInternal11CudaDeleterIfEEEE", !21, i64 0}
!21 = !{!"_ZTSSt10_Head_baseILm0EPfLb0EE", !12, i64 0}
!22 = !{!"_ZTSSt10unique_ptrIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !23, i64 0}
!23 = !{!"_ZTSSt15__uniq_ptr_dataIvN8nvinfer114pluginInternal11CudaDeleterIvEELb1ELb1EE", !24, i64 0}
!24 = !{!"_ZTSSt15__uniq_ptr_implIvN8nvinfer114pluginInternal11CudaDeleterIvEEE", !25, i64 0}
!25 = !{!"_ZTSSt5tupleIJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !26, i64 0}
!26 = !{!"_ZTSSt11_Tuple_implILm0EJPvN8nvinfer114pluginInternal11CudaDeleterIvEEEE", !27, i64 0}
!27 = !{!"_ZTSSt10_Head_baseILm0EPvLb0EE", !12, i64 0}
!28 = !{!"_ZTSN8nvinfer16plugin4bert20WeightsWithOwnershipE", !29, i64 0}
!29 = !{!"_ZTSN8nvinfer17WeightsE", !30, i64 0, !12, i64 8, !15, i64 16}
!30 = !{!"_ZTSN8nvinfer18DataTypeE", !13, i64 0}
!31 = !{!"bool", !13, i64 0}
!32 = !{!"int", !13, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass