; LLVM IR from NVIDIA/TensorRT :: plugin/common/checkMacrosPlugin.ll (ZN8nvinfer16plugin16throwCublasErrorEPKcS2_iiS2_)

; 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::LogStream" = type { %"class.std::basic_ostream.base", %"class.nvinfer1::plugin::LogStream<nvinfer1::ILogger::Severity::kERROR>::Buf", %"class.std::mutex", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.nvinfer1::plugin::LogStream<nvinfer1::ILogger::Severity::kERROR>::Buf" = type { %"class.std::__cxx11::basic_stringbuf" }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = 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::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.nvinfer1::plugin::CublasError" = type { %"class.nvinfer1::plugin::TRTException" }
%"class.nvinfer1::plugin::TRTException" = type { %"class.std::exception", ptr, ptr, i32, i32, ptr, ptr }
%"class.std::exception" = type { ptr }

@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [28 x i8], align 1
@_ZN8nvinfer16plugin9gLogErrorE = external global %"class.nvinfer1::plugin::LogStream", align 8
@_ZTIN8nvinfer16plugin11CublasErrorE = external dso_local constant { ptr, ptr, ptr }, align 8

; Function Attrs: mustprogress noreturn uwtable
define dso_local void @_ZN8nvinfer16plugin16throwCublasErrorEPKcS2_iiS2_(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #0 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %"class.nvinfer1::plugin::CublasError", align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !5
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %31

17:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %18 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %18, ptr %11, align 4, !tbaa !11
  %19 = load i32, ptr %11, align 4, !tbaa !11
  switch i32 %19, label %30 [
    i32 0, label %20
    i32 1, label %21
    i32 3, label %22
    i32 7, label %23
    i32 8, label %24
    i32 11, label %25
    i32 13, label %26
    i32 14, label %27
    i32 15, label %28
    i32 16, label %29
  ]

20:                                               ; preds = %17
  store ptr @.str, ptr %10, align 8, !tbaa !5
  br label %30

21:                                               ; preds = %17
  store ptr @.str.1, ptr %10, align 8, !tbaa !5
  br label %30

22:                                               ; preds = %17
  store ptr @.str.2, ptr %10, align 8, !tbaa !5
  br label %30

23:                                               ; preds = %17
  store ptr @.str.3, ptr %10, align 8, !tbaa !5
  br label %30

24:                                               ; preds = %17
  store ptr @.str.4, ptr %10, align 8, !tbaa !5
  br label %30

25:                                               ; preds = %17
  store ptr @.str.5, ptr %10, align 8, !tbaa !5
  br label %30

26:                                               ; preds = %17
  store ptr @.str.6, ptr %10, align 8, !tbaa !5
  br label %30

27:                                               ; preds = %17
  store ptr @.str.7, ptr %10, align 8, !tbaa !5
  br label %30

28:                                               ; preds = %17
  store ptr @.str.8, ptr %10, align 8, !tbaa !5
  br label %30

29:                                               ; preds = %17
  store ptr @.str.9, ptr %10, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %29, %28, %27, %26, %25, %24, %23, %22, %21, %20, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %31

31:                                               ; preds = %30, %5
  call void @llvm.lifetime.start.p0(i64 48, ptr %12) #6
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN8nvinfer16plugin11CublasErrorC2EPKcS3_iiS3_(ptr noundef nonnull align 8 dereferenceable(48) %12, ptr noundef %32, ptr noundef %33, i32 noundef %34, i32 noundef %35, ptr noundef %36)
  invoke void @_ZNK8nvinfer16plugin12TRTException3logERSo(ptr noundef nonnull align 8 dereferenceable(48) %12, ptr noundef nonnull align 8 dereferenceable(8) @_ZN8nvinfer16plugin9gLogErrorE)
          to label %37 unwind label %39

37:                                               ; preds = %31
  %38 = call ptr @__cxa_allocate_exception(i64 48) #6
  call void @_ZN8nvinfer16plugin11CublasErrorC2EOS1_(ptr noundef nonnull align 8 dereferenceable(48) %38, ptr noundef nonnull align 8 dereferenceable(48) %12) #6
  invoke void @__cxa_throw(ptr %38, ptr @_ZTIN8nvinfer16plugin11CublasErrorE, ptr @_ZNSt9exceptionD2Ev) #7
          to label %48 unwind label %39

39:                                               ; preds = %37, %31
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %13, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %14, align 4
  call void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %12) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %12) #6
  br label %43

43:                                               ; preds = %39
  %44 = load ptr, ptr %13, align 8
  %45 = load i32, ptr %14, align 4
  %46 = insertvalue { ptr, i32 } poison, ptr %44, 0
  %47 = insertvalue { ptr, i32 } %46, i32 %45, 1
  resume { ptr, i32 } %47

48:                                               ; preds = %37
  unreachable
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8nvinfer16plugin11CublasErrorC2EPKcS3_iiS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) unnamed_addr #2 align 2

declare void @_ZNK8nvinfer16plugin12TRTException3logERSo(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64)

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN8nvinfer16plugin11CublasErrorC2EOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5

attributes #0 = { mustprogress noreturn 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 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 = { nounwind "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 = { nounwind }
attributes #7 = { noreturn }

!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 = !{!"_ZTSN8nvinfer114pluginInternal12CublasStatusE", !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"

%"class.nvinfer1::plugin::LogStream" = type { %"class.std::basic_ostream.base", %"class.nvinfer1::plugin::LogStream<nvinfer1::ILogger::Severity::kERROR>::Buf", %"class.std::mutex", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.nvinfer1::plugin::LogStream<nvinfer1::ILogger::Severity::kERROR>::Buf" = type { %"class.std::__cxx11::basic_stringbuf" }
%"class.std::__cxx11::basic_stringbuf" = type { %"class.std::basic_streambuf", i32, %"class.std::__cxx11::basic_string" }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = 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::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.nvinfer1::plugin::CublasError" = type { %"class.nvinfer1::plugin::TRTException" }
%"class.nvinfer1::plugin::TRTException" = type { %"class.std::exception", ptr, ptr, i32, i32, ptr, ptr }
%"class.std::exception" = type { ptr }

@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [28 x i8], align 1
@_ZN8nvinfer16plugin9gLogErrorE = external global %"class.nvinfer1::plugin::LogStream", align 8
@_ZTIN8nvinfer16plugin11CublasErrorE = external dso_local constant { ptr, ptr, ptr }, align 8
@switch.table._ZN8nvinfer16plugin16throwCublasErrorEPKcS2_iiS2_ = private unnamed_addr constant [17 x ptr] [ptr @.str, ptr @.str.1, ptr null, ptr @.str.2, ptr null, ptr null, ptr null, ptr @.str.3, ptr @.str.4, ptr null, ptr null, ptr @.str.5, ptr null, ptr @.str.6, ptr @.str.7, ptr @.str.8, ptr @.str.9], align 8

; Function Attrs: mustprogress noreturn uwtable
define dso_local void @_ZN8nvinfer16plugin16throwCublasErrorEPKcS2_iiS2_(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.nvinfer1::plugin::CublasError", align 8
  %7 = icmp eq ptr %4, null
  br i1 %7, label %8, label %11

8:                                                ; preds = %5
  %9 = icmp ult i32 %3, 17
  br i1 %9, label %switch.lookup, label %11

switch.lookup:                                    ; preds = %8
  %10 = zext nneg i32 %3 to i64
  %switch.gep = getelementptr inbounds [17 x ptr], ptr @switch.table._ZN8nvinfer16plugin16throwCublasErrorEPKcS2_iiS2_, i64 0, i64 %10
  %switch.load = load ptr, ptr %switch.gep, align 8
  br label %11

11:                                               ; preds = %switch.lookup, %8, %5
  %.1 = phi ptr [ %4, %5 ], [ null, %8 ], [ %switch.load, %switch.lookup ]
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #6
  call void @_ZN8nvinfer16plugin11CublasErrorC2EPKcS3_iiS3_(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %.1)
  invoke void @_ZNK8nvinfer16plugin12TRTException3logERSo(ptr noundef nonnull align 8 dereferenceable(48) %6, ptr noundef nonnull align 8 dereferenceable(8) @_ZN8nvinfer16plugin9gLogErrorE)
          to label %12 unwind label %14

12:                                               ; preds = %11
  %13 = call ptr @__cxa_allocate_exception(i64 48) #6
  call void @_ZN8nvinfer16plugin11CublasErrorC2EOS1_(ptr noundef nonnull align 8 dereferenceable(48) %13, ptr noundef nonnull align 8 dereferenceable(48) %6) #6
  invoke void @__cxa_throw(ptr nonnull %13, ptr nonnull @_ZTIN8nvinfer16plugin11CublasErrorE, ptr nonnull @_ZNSt9exceptionD2Ev) #7
          to label %16 unwind label %14

14:                                               ; preds = %12, %11
  %15 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #6
  resume { ptr, i32 } %15

16:                                               ; preds = %12
  unreachable
}

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8nvinfer16plugin11CublasErrorC2EPKcS3_iiS3_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) unnamed_addr #2 align 2

declare void @_ZNK8nvinfer16plugin12TRTException3logERSo(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN8nvinfer16plugin11CublasErrorC2EOS1_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZNSt9exceptionD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #5

attributes #0 = { mustprogress noreturn 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 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 = { nounwind "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 = { nounwind }
attributes #7 = { noreturn }

!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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass