; LLVM IR from NVIDIA/TensorRT :: plugin/roiAlignPlugin/roiAlignPluginLegacy.ll (ZN8nvinfer16plugin8ROIAlign10initializeEv)

; 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::ROIAlign" = type { %"class.nvinfer1::IPluginV2DynamicExt", i32, i32, i32, float, i32, i32, i32, i32, i32, i32, i32, %"class.std::__cxx11::basic_string" }
%"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] }

; 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: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN8nvinfer16plugin8ROIAlign10initializeEv(ptr noundef nonnull align 8 dereferenceable(88) %0) unnamed_addr #2 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  br label %10

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %11 = invoke i32 @cudaGetDevice(ptr noundef %4)
          to label %12 unwind label %43

12:                                               ; preds = %10
  store i32 %11, ptr %5, align 4, !tbaa !9
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %12
  %16 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %16, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %18

17:                                               ; preds = %12
  store i32 0, ptr %6, align 4
  br label %18

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

20:                                               ; preds = %18
  br label %21

21:                                               ; preds = %20
  br label %22

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

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %24 = load i32, ptr %4, align 4, !tbaa !11
  %25 = invoke i32 @cudaGetDeviceProperties(ptr noundef %7, i32 noundef %24)
          to label %26 unwind label %43

26:                                               ; preds = %23
  store i32 %25, ptr %8, align 4, !tbaa !9
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %26
  %30 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %30, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %32

31:                                               ; preds = %26
  store i32 0, ptr %6, align 4
  br label %32

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

34:                                               ; preds = %32
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = getelementptr inbounds %struct.cudaDeviceProp, ptr %7, i32 0, i32 9
  %38 = load i32, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %"class.nvinfer1::plugin::ROIAlign", ptr %9, i32 0, i32 11
  store i32 %38, ptr %39, align 8, !tbaa !17
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %40

40:                                               ; preds = %36, %32
  call void @llvm.lifetime.end.p0(i64 728, ptr %7) #4
  br label %41

41:                                               ; preds = %40, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %42 = load i32, ptr %2, align 4
  ret i32 %42

43:                                               ; preds = %23, %10
  %44 = landingpad { ptr, i32 }
          catch ptr null
  %45 = extractvalue { ptr, i32 } %44, 0
  call void @__clang_call_terminate(ptr %45) #5
  unreachable
}

declare i32 @cudaGetDevice(ptr noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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, !10, i64 0}
!10 = !{!"_ZTS9cudaError", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 320}
!14 = !{!"_ZTS14cudaDeviceProp", !7, i64 0, !15, i64 256, !7, i64 272, !12, i64 280, !16, i64 288, !16, i64 296, !12, i64 304, !12, i64 308, !16, i64 312, !12, i64 320, !7, i64 324, !7, i64 336, !12, i64 348, !16, i64 352, !12, i64 360, !12, i64 364, !16, i64 368, !16, i64 376, !12, i64 384, !12, i64 388, !12, i64 392, !12, i64 396, !12, i64 400, !12, i64 404, !12, i64 408, !12, i64 412, !12, i64 416, !7, i64 420, !7, i64 428, !7, i64 436, !7, i64 448, !7, i64 456, !7, i64 468, !12, i64 480, !7, i64 484, !7, i64 492, !7, i64 504, !12, i64 512, !7, i64 516, !7, i64 524, !7, i64 536, !7, i64 544, !12, i64 556, !7, i64 560, !16, i64 568, !12, i64 576, !12, i64 580, !12, i64 584, !12, i64 588, !12, i64 592, !12, i64 596, !12, i64 600, !12, i64 604, !12, i64 608, !12, i64 612, !12, i64 616, !12, i64 620, !12, i64 624, !12, i64 628, !12, i64 632, !12, i64 636, !16, i64 640, !12, i64 648, !12, i64 652, !12, i64 656, !12, i64 660, !12, i64 664, !12, i64 668, !12, i64 672, !12, i64 676, !12, i64 680, !12, i64 684, !12, i64 688, !12, i64 692, !16, i64 696, !12, i64 704, !12, i64 708, !12, i64 712, !12, i64 716, !16, i64 720}
!15 = !{!"_ZTS9CUuuid_st", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !12, i64 48}
!18 = !{!"_ZTSN8nvinfer16plugin8ROIAlignE", !19, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !22, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !12, i64 48, !23, i64 56}
!19 = !{!"_ZTSN8nvinfer119IPluginV2DynamicExtE", !20, i64 0}
!20 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !21, i64 0}
!21 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!22 = !{!"float", !7, i64 0}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !24, i64 0, !16, i64 8, !7, i64 16}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, 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.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] }

; Function Attrs: mustprogress 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN8nvinfer16plugin8ROIAlign10initializeEv(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(88) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca i32, align 4
  %3 = alloca %struct.cudaDeviceProp, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %4 = invoke i32 @cudaGetDevice(ptr noundef nonnull %2)
          to label %5 unwind label %16

5:                                                ; preds = %1
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %6, label %15

6:                                                ; preds = %5
  call void @llvm.lifetime.start.p0(i64 728, ptr nonnull %3) #4
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = invoke i32 @cudaGetDeviceProperties(ptr noundef nonnull %3, i32 noundef %7)
          to label %9 unwind label %16

9:                                                ; preds = %6
  %.not10 = icmp eq i32 %8, 0
  br i1 %.not10, label %10, label %14

10:                                               ; preds = %9
  %11 = getelementptr inbounds i8, ptr %3, i64 320
  %12 = load i32, ptr %11, align 8, !tbaa !9
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %12, ptr %13, align 8, !tbaa !13
  br label %14

14:                                               ; preds = %9, %10
  call void @llvm.lifetime.end.p0(i64 728, ptr nonnull %3) #4
  br label %15

15:                                               ; preds = %5, %14
  %.3 = phi i32 [ %8, %14 ], [ %4, %5 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  ret i32 %.3

16:                                               ; preds = %6, %1
  %17 = landingpad { ptr, i32 }
          catch ptr null
  %18 = extractvalue { ptr, i32 } %17, 0
  call void @__clang_call_terminate(ptr %18) #5
  unreachable
}

declare i32 @cudaGetDevice(ptr noundef) local_unnamed_addr #3

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

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


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass