; LLVM IR from NVIDIA/TensorRT :: plugin/scatterPlugin (scatterPlugin)

; 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] }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8nvinfer16plugin9ScatterND25supportsFormatCombinationEiPKNS_16PluginTensorDescEii(ptr noundef nonnull align 8 dereferenceable(40) %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  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
  store i32 %4, ptr %10, align 4, !tbaa !9
  %13 = load ptr, ptr %6, align 8
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 4
  br i1 %15, label %18, label %16

16:                                               ; preds = %5
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 62)
          to label %17 unwind label %86

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17, %5
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 3
  br i1 %20, label %23, label %21

21:                                               ; preds = %18
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 63)
          to label %22 unwind label %86

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22, %18
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %28, label %26

26:                                               ; preds = %23
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 64)
          to label %27 unwind label %86

27:                                               ; preds = %26
  br label %28

28:                                               ; preds = %27, %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i32, ptr %7, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %29, i64 %31
  store ptr %32, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  store i8 0, ptr %12, align 1, !tbaa !11
  %33 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %33, label %83 [
    i32 0, label %34
    i32 2, label %34
    i32 1, label %52
    i32 3, label %65
  ]

34:                                               ; preds = %28, %28
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %44, label %39

39:                                               ; preds = %34
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 8, !tbaa !13
  %43 = icmp eq i32 %42, 3
  br i1 %43, label %44, label %49

44:                                               ; preds = %39, %34
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 4, !tbaa !19
  %48 = icmp eq i32 %47, 0
  br label %49

49:                                               ; preds = %44, %39
  %50 = phi i1 [ false, %39 ], [ %48, %44 ]
  %51 = zext i1 %50 to i8
  store i8 %51, ptr %12, align 1, !tbaa !11
  br label %83

52:                                               ; preds = %28
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 8, !tbaa !13
  %56 = icmp eq i32 %55, 3
  br i1 %56, label %57, label %62

57:                                               ; preds = %52
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %58, i32 0, i32 2
  %60 = load i32, ptr %59, align 4, !tbaa !19
  %61 = icmp eq i32 %60, 0
  br label %62

62:                                               ; preds = %57, %52
  %63 = phi i1 [ false, %52 ], [ %61, %57 ]
  %64 = zext i1 %63 to i8
  store i8 %64, ptr %12, align 1, !tbaa !11
  br label %83

65:                                               ; preds = %28
  %66 = load ptr, ptr %11, align 8, !tbaa !5
  %67 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %66, i32 0, i32 1
  %68 = load i32, ptr %67, align 8, !tbaa !13
  %69 = icmp eq i32 %68, 0
  br i1 %69, label %75, label %70

70:                                               ; preds = %65
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %71, i32 0, i32 1
  %73 = load i32, ptr %72, align 8, !tbaa !13
  %74 = icmp eq i32 %73, 3
  br i1 %74, label %75, label %80

75:                                               ; preds = %70, %65
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %76, i32 0, i32 2
  %78 = load i32, ptr %77, align 4, !tbaa !19
  %79 = icmp eq i32 %78, 0
  br label %80

80:                                               ; preds = %75, %70
  %81 = phi i1 [ false, %70 ], [ %79, %75 ]
  %82 = zext i1 %81 to i8
  store i8 %82, ptr %12, align 1, !tbaa !11
  br label %83

83:                                               ; preds = %80, %62, %49, %28
  %84 = load i8, ptr %12, align 1, !tbaa !11, !range !20, !noundef !21
  %85 = trunc i8 %84 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret i1 %85

86:                                               ; preds = %26, %21, %16
  %87 = landingpad { ptr, i32 }
          catch ptr null
  %88 = extractvalue { ptr, i32 } %87, 0
  call void @__clang_call_terminate(ptr %88) #5
  unreachable
}

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

declare i32 @__gxx_personality_v0(...)

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

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

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

attributes #0 = { 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 #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind }
attributes #5 = { 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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !16, i64 72}
!14 = !{!"_ZTSN8nvinfer116PluginTensorDescE", !15, i64 0, !16, i64 72, !17, i64 76, !18, i64 80}
!15 = !{!"_ZTSN8nvinfer16Dims64E", !10, i64 0, !7, i64 8}
!16 = !{!"_ZTSN8nvinfer18DataTypeE", !7, i64 0}
!17 = !{!"_ZTSN8nvinfer112TensorFormatE", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!14, !17, i64 76}
!20 = !{i8 0, i8 2}
!21 = !{}


; 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] }

@.str = external hidden unnamed_addr constant [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN8nvinfer16plugin9ScatterND25supportsFormatCombinationEiPKNS_16PluginTensorDescEii(ptr nocapture noundef nonnull readnone align 8 dereferenceable(40) %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %6 = icmp slt i32 %1, 4
  br i1 %6, label %8, label %7

7:                                                ; preds = %5
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 62)
          to label %8 unwind label %31

8:                                                ; preds = %7, %5
  %9 = icmp eq i32 %3, 3
  br i1 %9, label %11, label %10

10:                                               ; preds = %8
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 63)
          to label %11 unwind label %31

11:                                               ; preds = %10, %8
  %12 = icmp eq i32 %4, 1
  br i1 %12, label %14, label %13

13:                                               ; preds = %11
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 64)
          to label %14 unwind label %31

14:                                               ; preds = %13, %11
  %15 = sext i32 %1 to i64
  %16 = getelementptr inbounds %"struct.nvinfer1::PluginTensorDesc", ptr %2, i64 %15
  switch i32 %1, label %30 [
    i32 0, label %17
    i32 2, label %17
    i32 1, label %20
    i32 3, label %24
  ]

17:                                               ; preds = %14, %14
  %18 = getelementptr inbounds i8, ptr %16, i64 72
  %19 = load i32, ptr %18, align 8, !tbaa !5
  switch i32 %19, label %30 [
    i32 0, label %.sink.split
    i32 3, label %.sink.split
  ]

20:                                               ; preds = %14
  %21 = getelementptr inbounds i8, ptr %16, i64 72
  %22 = load i32, ptr %21, align 8, !tbaa !5
  %23 = icmp eq i32 %22, 3
  br i1 %23, label %.sink.split, label %30

24:                                               ; preds = %14
  %25 = getelementptr inbounds i8, ptr %16, i64 72
  %26 = load i32, ptr %25, align 8, !tbaa !5
  switch i32 %26, label %30 [
    i32 0, label %.sink.split
    i32 3, label %.sink.split
  ]

.sink.split:                                      ; preds = %24, %24, %20, %17, %17
  %27 = getelementptr inbounds i8, ptr %16, i64 76
  %28 = load i32, ptr %27, align 4, !tbaa !14
  %29 = icmp eq i32 %28, 0
  br label %30

30:                                               ; preds = %.sink.split, %24, %20, %17, %14
  %.0 = phi i1 [ false, %14 ], [ false, %17 ], [ false, %20 ], [ false, %24 ], [ %29, %.sink.split ]
  ret i1 %.0

31:                                               ; preds = %13, %10, %7
  %32 = landingpad { ptr, i32 }
          catch ptr null
  %33 = extractvalue { ptr, i32 } %32, 0
  tail call void @__clang_call_terminate(ptr %33) #3
  unreachable
}

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

declare i32 @__gxx_personality_v0(...)

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

attributes #0 = { 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 #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 = { 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 = { 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, !11, i64 72}
!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, !12, i64 76}


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