; LLVM IR from NVIDIA/TensorRT :: plugin/scatterElementsPlugin (scatterElementsPluginLegacy)

; 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.nvinfer1::PluginTensorDesc" = type { %"class.nvinfer1::Dims64", i32, i32, float }
%"class.nvinfer1::Dims64" = type { i32, [8 x i64] }

@_ZTISt9exception = external constant ptr
@.str.9 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__._ZN8nvinfer16plugin23ScatterElementsPluginV225supportsFormatCombinationEiPKNS_16PluginTensorDescEii = external hidden unnamed_addr constant [26 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: noreturn
declare void @_ZN8nvinfer16plugin16throwPluginErrorEPKcS2_iiS2_(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #2

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

declare ptr @__cxa_begin_catch(ptr)

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8nvinfer16plugin11caughtErrorERKSt9exception(ptr noundef nonnull align 8 dereferenceable(8)) #4

declare void @__cxa_end_catch()

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8nvinfer16plugin23ScatterElementsPluginV225supportsFormatCombinationEiPKNS_16PluginTensorDescEii(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #5 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  %17 = load ptr, ptr %7, align 8
  %18 = load ptr, ptr %9, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %26

20:                                               ; preds = %5
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = add nsw i32 %22, %23
  %25 = icmp slt i32 %21, %24
  br i1 %25, label %32, label %26

26:                                               ; preds = %20, %5
  invoke void @_ZN8nvinfer16plugin16throwPluginErrorEPKcS2_iiS2_(ptr noundef @.str.9, ptr noundef @__func__._ZN8nvinfer16plugin23ScatterElementsPluginV225supportsFormatCombinationEiPKNS_16PluginTensorDescEii, i32 noundef 143, i32 noundef 0, ptr noundef @.str.14) #7
          to label %27 unwind label %28

27:                                               ; preds = %26
  unreachable

28:                                               ; preds = %26
  %29 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %12, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %13, align 4
  br label %89

32:                                               ; preds = %20
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %33, i64 %35
  %37 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !11
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %32
  store i1 false, ptr %6, align 1
  br label %100

41:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #8
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %42, i64 %44
  %46 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 8, !tbaa !17
  store i32 %47, ptr %14, align 4, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #8
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %48, i64 0
  %50 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %49, i32 0, i32 1
  %51 = load i32, ptr %50, align 8, !tbaa !17
  store i32 %51, ptr %15, align 4, !tbaa !18
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %54, label %57

54:                                               ; preds = %41
  %55 = load i32, ptr %14, align 4, !tbaa !18
  %56 = icmp eq i32 %55, 8
  br label %83

57:                                               ; preds = %41
  %58 = load i32, ptr %14, align 4, !tbaa !18
  %59 = load i32, ptr %15, align 4, !tbaa !18
  %60 = icmp eq i32 %58, %59
  br i1 %60, label %61, label %81

61:                                               ; preds = %57
  %62 = load i32, ptr %14, align 4, !tbaa !18
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %79, label %64

64:                                               ; preds = %61
  %65 = load i32, ptr %14, align 4, !tbaa !18
  %66 = icmp eq i32 %65, 1
  br i1 %66, label %79, label %67

67:                                               ; preds = %64
  %68 = invoke noundef zeroext i1 @_ZN8nvinfer16plugin20hasBfloat16AtomicAddEv()
          to label %69 unwind label %85

69:                                               ; preds = %67
  br i1 %68, label %70, label %73

70:                                               ; preds = %69
  %71 = load i32, ptr %14, align 4, !tbaa !18
  %72 = icmp eq i32 %71, 7
  br i1 %72, label %79, label %73

73:                                               ; preds = %70, %69
  %74 = load i32, ptr %14, align 4, !tbaa !18
  %75 = icmp eq i32 %74, 3
  br i1 %75, label %79, label %76

76:                                               ; preds = %73
  %77 = load i32, ptr %14, align 4, !tbaa !18
  %78 = icmp eq i32 %77, 8
  br label %79

79:                                               ; preds = %76, %73, %70, %64, %61
  %80 = phi i1 [ true, %73 ], [ true, %70 ], [ true, %64 ], [ true, %61 ], [ %78, %76 ]
  br label %81

81:                                               ; preds = %79, %57
  %82 = phi i1 [ false, %57 ], [ %80, %79 ]
  br label %83

83:                                               ; preds = %81, %54
  %84 = phi i1 [ %56, %54 ], [ %82, %81 ]
  store i1 %84, ptr %6, align 1
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %100

85:                                               ; preds = %67
  %86 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %87 = extractvalue { ptr, i32 } %86, 0
  store ptr %87, ptr %12, align 8
  %88 = extractvalue { ptr, i32 } %86, 1
  store i32 %88, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #8
  br label %89

89:                                               ; preds = %85, %28
  %90 = load i32, ptr %13, align 4
  %91 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9exception) #8
  %92 = icmp eq i32 %90, %91
  br i1 %92, label %93, label %105

93:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #8
  %94 = load ptr, ptr %12, align 8
  %95 = call ptr @__cxa_begin_catch(ptr %94) #8
  store ptr %95, ptr %16, align 8
  %96 = load ptr, ptr %16, align 8, !tbaa !5
  invoke void @_ZN8nvinfer16plugin11caughtErrorERKSt9exception(ptr noundef nonnull align 8 dereferenceable(8) %96)
          to label %97 unwind label %102

97:                                               ; preds = %93
  store i1 false, ptr %6, align 1
  invoke void @__cxa_end_catch()
          to label %98 unwind label %102

98:                                               ; preds = %97
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #8
  br label %100

99:                                               ; No predecessors!
  unreachable

100:                                              ; preds = %98, %83, %40
  %101 = load i1, ptr %6, align 1
  ret i1 %101

102:                                              ; preds = %97, %93
  %103 = landingpad { ptr, i32 }
          catch ptr null
  %104 = extractvalue { ptr, i32 } %103, 0
  call void @__clang_call_terminate(ptr %104) #9
  unreachable

105:                                              ; preds = %89
  %106 = load ptr, ptr %12, align 8
  call void @__clang_call_terminate(ptr %106) #9
  unreachable
}

declare noundef zeroext i1 @_ZN8nvinfer16plugin20hasBfloat16AtomicAddEv() #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn "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 memory(none) }
attributes #3 = { 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 #4 = { inlinehint 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 #5 = { 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 #6 = { "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 #7 = { noreturn }
attributes #8 = { nounwind }
attributes #9 = { 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, !15, i64 76}
!12 = !{!"_ZTSN8nvinfer116PluginTensorDescE", !13, i64 0, !14, i64 72, !15, i64 76, !16, i64 80}
!13 = !{!"_ZTSN8nvinfer16Dims64E", !10, i64 0, !7, i64 8}
!14 = !{!"_ZTSN8nvinfer18DataTypeE", !7, i64 0}
!15 = !{!"_ZTSN8nvinfer112TensorFormatE", !7, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = !{!12, !14, i64 72}
!18 = !{!14, !14, 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"

%"struct.nvinfer1::PluginTensorDesc" = type { %"class.nvinfer1::Dims64", i32, i32, float }
%"class.nvinfer1::Dims64" = type { i32, [8 x i64] }

@_ZTISt9exception = external constant ptr
@.str.9 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__._ZN8nvinfer16plugin23ScatterElementsPluginV225supportsFormatCombinationEiPKNS_16PluginTensorDescEii = external hidden unnamed_addr constant [26 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [38 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: noreturn
declare void @_ZN8nvinfer16plugin16throwPluginErrorEPKcS2_iiS2_(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #1

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

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8nvinfer16plugin11caughtErrorERKSt9exception(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

declare void @__cxa_end_catch() local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8nvinfer16plugin23ScatterElementsPluginV225supportsFormatCombinationEiPKNS_16PluginTensorDescEii(ptr nocapture noundef nonnull readnone align 8 dereferenceable(48) %0, i32 noundef %1, ptr noundef readonly %2, i32 noundef %3, i32 noundef %4) unnamed_addr #4 align 2 personality ptr @__gxx_personality_v0 {
  %.not = icmp ne ptr %2, null
  %6 = add nsw i32 %4, %3
  %7 = icmp sgt i32 %6, %1
  %or.cond36 = select i1 %.not, i1 %7, i1 false
  br i1 %or.cond36, label %12, label %8

8:                                                ; preds = %5
  invoke void @_ZN8nvinfer16plugin16throwPluginErrorEPKcS2_iiS2_(ptr noundef nonnull @.str.9, ptr noundef nonnull @__func__._ZN8nvinfer16plugin23ScatterElementsPluginV225supportsFormatCombinationEiPKNS_16PluginTensorDescEii, i32 noundef 143, i32 noundef 0, ptr noundef nonnull @.str.14) #6
          to label %9 unwind label %10

9:                                                ; preds = %8
  unreachable

10:                                               ; preds = %8
  %11 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  br label %37

12:                                               ; preds = %5
  %13 = sext i32 %1 to i64
  %14 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %2, i64 %13
  %15 = getelementptr inbounds i8, ptr %14, i64 76
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %.not33 = icmp eq i32 %16, 0
  br i1 %.not33, label %17, label %43

17:                                               ; preds = %12
  %18 = getelementptr inbounds i8, ptr %14, i64 72
  %19 = load i32, ptr %18, align 8, !tbaa !14
  %20 = icmp eq i32 %1, 1
  br i1 %20, label %21, label %23

21:                                               ; preds = %17
  %22 = icmp eq i32 %19, 8
  br label %43

23:                                               ; preds = %17
  %24 = getelementptr inbounds i8, ptr %2, i64 72
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = icmp eq i32 %19, %25
  br i1 %26, label %27, label %43

27:                                               ; preds = %23
  %or.cond = icmp ult i32 %19, 2
  br i1 %or.cond, label %43, label %28

28:                                               ; preds = %27
  %29 = invoke noundef zeroext i1 @_ZN8nvinfer16plugin20hasBfloat16AtomicAddEv()
          to label %30 unwind label %35

30:                                               ; preds = %28
  %31 = icmp eq i32 %19, 7
  %or.cond3 = select i1 %29, i1 %31, i1 false
  %32 = icmp eq i32 %19, 3
  %33 = icmp eq i32 %19, 8
  %34 = or i1 %32, %33
  %spec.select = select i1 %or.cond3, i1 true, i1 %34
  br label %43

35:                                               ; preds = %28
  %36 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  br label %37

37:                                               ; preds = %35, %10
  %.pn = phi { ptr, i32 } [ %36, %35 ], [ %11, %10 ]
  %.028 = extractvalue { ptr, i32 } %.pn, 0
  %.029 = extractvalue { ptr, i32 } %.pn, 1
  %38 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9exception) #7
  %39 = icmp eq i32 %.029, %38
  br i1 %39, label %40, label %47

40:                                               ; preds = %37
  %41 = tail call ptr @__cxa_begin_catch(ptr %.028) #7
  invoke void @_ZN8nvinfer16plugin11caughtErrorERKSt9exception(ptr noundef nonnull align 8 dereferenceable(8) %41)
          to label %42 unwind label %44

42:                                               ; preds = %40
  invoke void @__cxa_end_catch()
          to label %43 unwind label %44

43:                                               ; preds = %30, %42, %21, %27, %23, %12
  %.0 = phi i1 [ false, %12 ], [ %22, %21 ], [ false, %23 ], [ true, %27 ], [ %spec.select, %30 ], [ false, %42 ]
  ret i1 %.0

44:                                               ; preds = %42, %40
  %45 = landingpad { ptr, i32 }
          catch ptr null
  %46 = extractvalue { ptr, i32 } %45, 0
  tail call void @__clang_call_terminate(ptr %46) #8
  unreachable

47:                                               ; preds = %37
  tail call void @__clang_call_terminate(ptr %.028) #8
  unreachable
}

declare noundef zeroext i1 @_ZN8nvinfer16plugin20hasBfloat16AtomicAddEv() local_unnamed_addr #5

attributes #0 = { noreturn "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 = { nofree nosync nounwind memory(none) }
attributes #2 = { 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 #3 = { inlinehint 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 #4 = { 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 #5 = { "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 #6 = { noreturn }
attributes #7 = { nounwind }
attributes #8 = { 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, !12, i64 76}
!6 = !{!"_ZTSN8nvinfer116PluginTensorDescE", !7, i64 0, !11, i64 72, !12, i64 76, !13, i64 80}
!7 = !{!"_ZTSN8nvinfer16Dims64E", !8, i64 0, !9, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN8nvinfer18DataTypeE", !9, i64 0}
!12 = !{!"_ZTSN8nvinfer112TensorFormatE", !9, i64 0}
!13 = !{!"float", !9, i64 0}
!14 = !{!6, !11, i64 72}


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