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

; 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::EmbLayerNormVarSeqlenPluginLegacyBase" = 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.6", %"class.std::unique_ptr.6", %"class.std::unique_ptr.6", 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, 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.5" }
%"struct.std::_Head_base.5" = type { ptr }
%"class.std::unique_ptr.6" = type { %"struct.std::__uniq_ptr_data.7" }
%"struct.std::__uniq_ptr_data.7" = type { %"class.std::__uniq_ptr_impl.8" }
%"class.std::__uniq_ptr_impl.8" = type { %"class.std::tuple.9" }
%"class.std::tuple.9" = type { %"struct.std::_Tuple_impl.10" }
%"struct.std::_Tuple_impl.10" = type { %"struct.std::_Head_base.13" }
%"struct.std::_Head_base.13" = type { ptr }
%"struct.nvinfer1::plugin::bert::WeightsWithOwnership" = type { %"class.nvinfer1::Weights" }
%"class.nvinfer1::Weights" = type { i32, ptr, i64 }

@.str = external hidden unnamed_addr constant [113 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.44 = 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 @_ZNK8nvinfer16plugin4bert37EmbLayerNormVarSeqlenPluginLegacyBase17getOutputDataTypeEiPKNS_8DataTypeEi(ptr noundef nonnull align 8 dereferenceable(272) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %9 = load ptr, ptr %5, align 8
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %17, label %12

12:                                               ; preds = %4
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %17, label %15

15:                                               ; preds = %12
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.43, ptr noundef @.str, i32 noundef 482)
          to label %16 unwind label %38

16:                                               ; preds = %15
  br label %17

17:                                               ; preds = %16, %12, %4
  %18 = getelementptr inbounds %"class.nvinfer1::plugin::bert::EmbLayerNormVarSeqlenPluginLegacyBase", ptr %9, i32 0, i32 17
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %27, label %21

21:                                               ; preds = %17
  %22 = getelementptr inbounds %"class.nvinfer1::plugin::bert::EmbLayerNormVarSeqlenPluginLegacyBase", ptr %9, i32 0, i32 17
  %23 = load i32, ptr %22, align 8, !tbaa !11
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %27, label %25

25:                                               ; preds = %21
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.44, ptr noundef @.str, i32 noundef 483)
          to label %26 unwind label %38

26:                                               ; preds = %25
  br label %27

27:                                               ; preds = %26, %21, %17
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %33

30:                                               ; preds = %27
  %31 = getelementptr inbounds %"class.nvinfer1::plugin::bert::EmbLayerNormVarSeqlenPluginLegacyBase", ptr %9, i32 0, i32 17
  %32 = load i32, ptr %31, align 8, !tbaa !11
  br label %36

33:                                               ; preds = %27
  %34 = getelementptr inbounds %"class.nvinfer1::plugin::bert::EmbLayerNormVarSeqlenPluginLegacyBase", ptr %9, i32 0, i32 18
  %35 = load i32, ptr %34, align 4, !tbaa !34
  br label %36

36:                                               ; preds = %33, %30
  %37 = phi i32 [ %32, %30 ], [ %35, %33 ]
  ret i32 %37

38:                                               ; preds = %25, %15
  %39 = landingpad { ptr, i32 }
          catch ptr null
  %40 = extractvalue { ptr, i32 } %39, 0
  call void @__clang_call_terminate(ptr %40) #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 264}
!12 = !{!"_ZTSN8nvinfer16plugin4bert37EmbLayerNormVarSeqlenPluginLegacyBaseE", !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, !31, i64 144, !31, i64 168, !31, i64 192, !31, i64 216, !31, i64 240, !33, i64 264, !33, i64 268}
!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 = !{!12, !33, i64 268}


; 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 [113 x i8], align 1
@.str.43 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.44 = 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 @_ZNK8nvinfer16plugin4bert37EmbLayerNormVarSeqlenPluginLegacyBase17getOutputDataTypeEiPKNS_8DataTypeEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(272) %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.43, ptr noundef nonnull @.str, i32 noundef 482)
          to label %6 unwind label %14

6:                                                ; preds = %5, %4
  %7 = getelementptr inbounds i8, ptr %0, i64 264
  %8 = load i32, ptr %7, align 8
  %switch = icmp ult i32 %8, 2
  br i1 %switch, label %10, label %9

9:                                                ; preds = %6
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.44, ptr noundef nonnull @.str, i32 noundef 483)
          to label %._crit_edge unwind label %14

._crit_edge:                                      ; preds = %9
  %.val.pre = load i32, ptr %7, align 8
  br label %10

10:                                               ; preds = %._crit_edge, %6
  %.val = phi i32 [ %.val.pre, %._crit_edge ], [ %8, %6 ]
  %11 = icmp eq i32 %1, 0
  %12 = getelementptr inbounds i8, ptr %0, i64 268
  %.val4 = load i32, ptr %12, align 4
  %13 = select i1 %11, i32 %.val, i32 %.val4
  ret i32 %13

14:                                               ; preds = %9, %5
  %15 = landingpad { ptr, i32 }
          catch ptr null
  %16 = extractvalue { ptr, i32 } %15, 0
  tail call void @__clang_call_terminate(ptr %16) #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)"}


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