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

; 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.cudaDeviceProp = type { [256 x i8], %struct.CUuuid_st, [8 x i8], i32, i64, i64, i32, i32, i64, i32, [3 x i32], [3 x i32], i32, i64, i32, i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, [2 x i32], [2 x i32], [3 x i32], [2 x i32], [3 x i32], [3 x i32], i32, [2 x i32], [3 x i32], [2 x i32], i32, [2 x i32], [3 x i32], [2 x i32], [3 x i32], i32, [2 x i32], i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, i32, i64 }
%struct.CUuuid_st = type { [16 x i8] }
%"class.nvinfer1::plugin::EfficientNMSPlugin" = type { %"class.nvinfer1::IPluginV2DynamicExt", %"struct.nvinfer1::plugin::EfficientNMSParameters", i8, %"class.std::__cxx11::basic_string" }
%"class.nvinfer1::IPluginV2DynamicExt" = type { %"class.nvinfer1::IPluginV2Ext" }
%"class.nvinfer1::IPluginV2Ext" = type { %"class.nvinfer1::IPluginV2" }
%"class.nvinfer1::IPluginV2" = type { ptr }
%"struct.nvinfer1::plugin::EfficientNMSParameters" = type { float, float, i32, i32, i8, i32, i8, i8, i32, i8, i32, i32, i8, i32, i32, i32, i32, i32, i8, i8, i8, i32 }
%"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] }

declare i32 @__gxx_personality_v0(...)

; 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 i32 @_ZN8nvinfer16plugin18EfficientNMSPlugin10initializeEv(ptr noundef nonnull align 8 dereferenceable(120) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %struct.cudaDeviceProp, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = load ptr, ptr %3, align 8
  %10 = getelementptr inbounds %"class.nvinfer1::plugin::EfficientNMSPlugin", ptr %9, i32 0, i32 2
  %11 = load i8, ptr %10, align 4, !tbaa !9, !range !22, !noundef !23
  %12 = trunc i8 %11 to i1
  br i1 %12, label %54, label %13

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  br label %14

14:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %15 = invoke i32 @cudaGetDevice(ptr noundef %4)
          to label %16 unwind label %57

16:                                               ; preds = %14
  store i32 %15, ptr %5, align 4, !tbaa !24
  %17 = load i32, ptr %5, align 4, !tbaa !24
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %21

20:                                               ; preds = %16
  store i32 0, ptr %6, align 4
  br label %21

21:                                               ; preds = %20, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %22 = load i32, ptr %6, align 4
  switch i32 %22, label %51 [
    i32 0, label %23
  ]

23:                                               ; preds = %21
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 728, ptr %7) #4
  br label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %27 = load i32, ptr %4, align 4, !tbaa !26
  %28 = invoke i32 @cudaGetDeviceProperties(ptr noundef %7, i32 noundef %27)
          to label %29 unwind label %57

29:                                               ; preds = %26
  store i32 %28, ptr %8, align 4, !tbaa !24
  %30 = load i32, ptr %8, align 4, !tbaa !24
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %29
  store i32 1, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %34

33:                                               ; preds = %29
  store i32 0, ptr %6, align 4
  br label %34

34:                                               ; preds = %33, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %35 = load i32, ptr %6, align 4
  switch i32 %35, label %50 [
    i32 0, label %36
  ]

36:                                               ; preds = %34
  br label %37

37:                                               ; preds = %36
  br label %38

38:                                               ; preds = %37
  %39 = getelementptr inbounds %struct.cudaDeviceProp, ptr %7, i32 0, i32 6
  %40 = load i32, ptr %39, align 8, !tbaa !27
  %41 = icmp sge i32 %40, 65536
  br i1 %41, label %42, label %45

42:                                               ; preds = %38
  %43 = getelementptr inbounds %"class.nvinfer1::plugin::EfficientNMSPlugin", ptr %9, i32 0, i32 1
  %44 = getelementptr inbounds %"struct.nvinfer1::plugin::EfficientNMSParameters", ptr %43, i32 0, i32 10
  store i32 5000, ptr %44, align 4, !tbaa !30
  br label %48

45:                                               ; preds = %38
  %46 = getelementptr inbounds %"class.nvinfer1::plugin::EfficientNMSPlugin", ptr %9, i32 0, i32 1
  %47 = getelementptr inbounds %"struct.nvinfer1::plugin::EfficientNMSParameters", ptr %46, i32 0, i32 10
  store i32 2000, ptr %47, align 4, !tbaa !30
  br label %48

48:                                               ; preds = %45, %42
  %49 = getelementptr inbounds %"class.nvinfer1::plugin::EfficientNMSPlugin", ptr %9, i32 0, i32 2
  store i8 1, ptr %49, align 4, !tbaa !9
  store i32 0, ptr %6, align 4
  br label %50

50:                                               ; preds = %48, %34
  call void @llvm.lifetime.end.p0(i64 728, ptr %7) #4
  br label %51

51:                                               ; preds = %50, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %52 = load i32, ptr %6, align 4
  switch i32 %52, label %60 [
    i32 0, label %53
    i32 1, label %55
  ]

53:                                               ; preds = %51
  br label %54

54:                                               ; preds = %53, %1
  store i32 0, ptr %2, align 4
  br label %55

55:                                               ; preds = %54, %51
  %56 = load i32, ptr %2, align 4
  ret i32 %56

57:                                               ; preds = %26, %14
  %58 = landingpad { ptr, i32 }
          catch ptr null
  %59 = extractvalue { ptr, i32 } %58, 0
  call void @__clang_call_terminate(ptr %59) #5
  unreachable

60:                                               ; preds = %51
  unreachable
}

declare i32 @cudaGetDevice(ptr noundef) #2

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

declare i32 @cudaGetDeviceProperties(ptr noundef, i32 noundef) #2

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 = { "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 = { 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 = { 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, !17, i64 84}
!10 = !{!"_ZTSN8nvinfer16plugin18EfficientNMSPluginE", !11, i64 0, !14, i64 8, !17, i64 84, !19, i64 88}
!11 = !{!"_ZTSN8nvinfer119IPluginV2DynamicExtE", !12, i64 0}
!12 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !13, i64 0}
!13 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!14 = !{!"_ZTSN8nvinfer16plugin22EfficientNMSParametersE", !15, i64 0, !15, i64 4, !16, i64 8, !16, i64 12, !17, i64 16, !16, i64 20, !17, i64 24, !17, i64 25, !16, i64 28, !17, i64 32, !16, i64 36, !16, i64 40, !17, i64 44, !16, i64 48, !16, i64 52, !16, i64 56, !16, i64 60, !16, i64 64, !17, i64 68, !17, i64 69, !17, i64 70, !18, i64 72}
!15 = !{!"float", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSN8nvinfer18DataTypeE", !7, i64 0}
!19 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !20, i64 0, !21, i64 8, !7, i64 16}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = !{!25, !25, i64 0}
!25 = !{!"_ZTS9cudaError", !7, i64 0}
!26 = !{!16, !16, i64 0}
!27 = !{!28, !16, i64 304}
!28 = !{!"_ZTS14cudaDeviceProp", !7, i64 0, !29, i64 256, !7, i64 272, !16, i64 280, !21, i64 288, !21, i64 296, !16, i64 304, !16, i64 308, !21, i64 312, !16, i64 320, !7, i64 324, !7, i64 336, !16, i64 348, !21, i64 352, !16, i64 360, !16, i64 364, !21, i64 368, !21, i64 376, !16, i64 384, !16, i64 388, !16, i64 392, !16, i64 396, !16, i64 400, !16, i64 404, !16, i64 408, !16, i64 412, !16, i64 416, !7, i64 420, !7, i64 428, !7, i64 436, !7, i64 448, !7, i64 456, !7, i64 468, !16, i64 480, !7, i64 484, !7, i64 492, !7, i64 504, !16, i64 512, !7, i64 516, !7, i64 524, !7, i64 536, !7, i64 544, !16, i64 556, !7, i64 560, !21, i64 568, !16, i64 576, !16, i64 580, !16, i64 584, !16, i64 588, !16, i64 592, !16, i64 596, !16, i64 600, !16, i64 604, !16, i64 608, !16, i64 612, !16, i64 616, !16, i64 620, !16, i64 624, !16, i64 628, !16, i64 632, !16, i64 636, !21, i64 640, !16, i64 648, !16, i64 652, !16, i64 656, !16, i64 660, !16, i64 664, !16, i64 668, !16, i64 672, !16, i64 676, !16, i64 680, !16, i64 684, !16, i64 688, !16, i64 692, !21, i64 696, !16, i64 704, !16, i64 708, !16, i64 712, !16, i64 716, !21, i64 720}
!29 = !{!"_ZTS9CUuuid_st", !7, i64 0}
!30 = !{!10, !16, i64 44}


; 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.cudaDeviceProp = type { [256 x i8], %struct.CUuuid_st, [8 x i8], i32, i64, i64, i32, i32, i64, i32, [3 x i32], [3 x i32], i32, i64, i32, i32, i64, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, [2 x i32], [2 x i32], [3 x i32], [2 x i32], [3 x i32], [3 x i32], i32, [2 x i32], [3 x i32], [2 x i32], i32, [2 x i32], [3 x i32], [2 x i32], [3 x i32], i32, [2 x i32], i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, i32, i32, i32, i32, i64 }
%struct.CUuuid_st = type { [16 x i8] }

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress 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 range(i32 0, 2) i32 @_ZN8nvinfer16plugin18EfficientNMSPlugin10initializeEv(ptr nocapture noundef nonnull align 8 dereferenceable(120) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca %struct.cudaDeviceProp, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 84
  %5 = load i8, ptr %4, align 4, !tbaa !5, !range !21, !noundef !22
  %6 = trunc nuw i8 %5 to i1
  br i1 %6, label %19, label %7

7:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %8 = invoke i32 @cudaGetDevice(ptr noundef nonnull %2)
          to label %9 unwind label %20

9:                                                ; preds = %7
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %10, label %.thread

.thread:                                          ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  br label %19

10:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 728, ptr nonnull %3) #4
  %11 = load i32, ptr %2, align 4, !tbaa !23
  %12 = invoke i32 @cudaGetDeviceProperties(ptr noundef nonnull %3, i32 noundef %11)
          to label %13 unwind label %20

13:                                               ; preds = %10
  %.not11 = icmp eq i32 %12, 0
  br i1 %.not11, label %.thread14, label %18

.thread14:                                        ; preds = %13
  %14 = getelementptr inbounds i8, ptr %3, i64 304
  %15 = load i32, ptr %14, align 8, !tbaa !24
  %16 = icmp sgt i32 %15, 65535
  %spec.select = select i1 %16, i32 5000, i32 2000
  %17 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 %spec.select, ptr %17, align 4
  store i8 1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 728, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  br label %19

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 728, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  br label %19

19:                                               ; preds = %1, %.thread14, %18, %.thread
  %.3 = phi i32 [ 1, %18 ], [ 1, %.thread ], [ 0, %.thread14 ], [ 0, %1 ]
  ret i32 %.3

20:                                               ; preds = %10, %7
  %21 = landingpad { ptr, i32 }
          catch ptr null
  %22 = extractvalue { ptr, i32 } %21, 0
  call void @__clang_call_terminate(ptr %22) #5
  unreachable
}

declare i32 @cudaGetDevice(ptr noundef) local_unnamed_addr #2

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

declare i32 @cudaGetDeviceProperties(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { "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 = { 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 = { 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, !15, i64 84}
!6 = !{!"_ZTSN8nvinfer16plugin18EfficientNMSPluginE", !7, i64 0, !10, i64 8, !15, i64 84, !17, i64 88}
!7 = !{!"_ZTSN8nvinfer119IPluginV2DynamicExtE", !8, i64 0}
!8 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !9, i64 0}
!9 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!10 = !{!"_ZTSN8nvinfer16plugin22EfficientNMSParametersE", !11, i64 0, !11, i64 4, !14, i64 8, !14, i64 12, !15, i64 16, !14, i64 20, !15, i64 24, !15, i64 25, !14, i64 28, !15, i64 32, !14, i64 36, !14, i64 40, !15, i64 44, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60, !14, i64 64, !15, i64 68, !15, i64 69, !15, i64 70, !16, i64 72}
!11 = !{!"float", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"int", !12, i64 0}
!15 = !{!"bool", !12, i64 0}
!16 = !{!"_ZTSN8nvinfer18DataTypeE", !12, i64 0}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !20, i64 8, !12, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !19, i64 0}
!19 = !{!"any pointer", !12, i64 0}
!20 = !{!"long", !12, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!14, !14, i64 0}
!24 = !{!25, !14, i64 304}
!25 = !{!"_ZTS14cudaDeviceProp", !12, i64 0, !26, i64 256, !12, i64 272, !14, i64 280, !20, i64 288, !20, i64 296, !14, i64 304, !14, i64 308, !20, i64 312, !14, i64 320, !12, i64 324, !12, i64 336, !14, i64 348, !20, i64 352, !14, i64 360, !14, i64 364, !20, i64 368, !20, i64 376, !14, i64 384, !14, i64 388, !14, i64 392, !14, i64 396, !14, i64 400, !14, i64 404, !14, i64 408, !14, i64 412, !14, i64 416, !12, i64 420, !12, i64 428, !12, i64 436, !12, i64 448, !12, i64 456, !12, i64 468, !14, i64 480, !12, i64 484, !12, i64 492, !12, i64 504, !14, i64 512, !12, i64 516, !12, i64 524, !12, i64 536, !12, i64 544, !14, i64 556, !12, i64 560, !20, i64 568, !14, i64 576, !14, i64 580, !14, i64 584, !14, i64 588, !14, i64 592, !14, i64 596, !14, i64 600, !14, i64 604, !14, i64 608, !14, i64 612, !14, i64 616, !14, i64 620, !14, i64 624, !14, i64 628, !14, i64 632, !14, i64 636, !20, i64 640, !14, i64 648, !14, i64 652, !14, i64 656, !14, i64 660, !14, i64 664, !14, i64 668, !14, i64 672, !14, i64 676, !14, i64 680, !14, i64 684, !14, i64 688, !14, i64 692, !20, i64 696, !14, i64 704, !14, i64 708, !14, i64 712, !14, i64 716, !20, i64 720}
!26 = !{!"_ZTS9CUuuid_st", !12, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass