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

; 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::GridAnchorGenerator" = type { %"class.nvinfer1::IPluginV2Ext", %"class.std::__cxx11::basic_string", i32, %"class.std::vector.3", ptr, ptr, ptr, %"class.std::__cxx11::basic_string" }
%"class.nvinfer1::IPluginV2Ext" = type { %"class.nvinfer1::IPluginV2" }
%"class.nvinfer1::IPluginV2" = type { ptr }
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<nvinfer1::plugin::GridAnchorParameters, std::allocator<nvinfer1::plugin::GridAnchorParameters>>::_Vector_impl" }
%"struct.std::_Vector_base<nvinfer1::plugin::GridAnchorParameters, std::allocator<nvinfer1::plugin::GridAnchorParameters>>::_Vector_impl" = type { %"struct.std::_Vector_base<nvinfer1::plugin::GridAnchorParameters, std::allocator<nvinfer1::plugin::GridAnchorParameters>>::_Vector_impl_data" }
%"struct.std::_Vector_base<nvinfer1::plugin::GridAnchorParameters, std::allocator<nvinfer1::plugin::GridAnchorParameters>>::_Vector_impl_data" = type { ptr, ptr, 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] }
%"struct.nvinfer1::plugin::GridAnchorParameters" = type { float, float, ptr, i32, i32, i32, [4 x float] }
%"class.nvinfer1::Weights" = type { i32, ptr, i64 }

; 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 i64 @_ZNK8nvinfer16plugin19GridAnchorGenerator20getSerializationSizeEv(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  store i64 4, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !11
  br label %6

6:                                                ; preds = %46, %1
  %7 = load i32, ptr %4, align 4, !tbaa !11
  %8 = getelementptr inbounds %"class.nvinfer1::plugin::GridAnchorGenerator", ptr %5, i32 0, i32 2
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = icmp slt i32 %7, %9
  br i1 %10, label %12, label %11

11:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %49

12:                                               ; preds = %6
  %13 = load i64, ptr %3, align 8, !tbaa !9
  %14 = add i64 %13, 16
  store i64 %14, ptr %3, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.nvinfer1::plugin::GridAnchorGenerator", ptr %5, i32 0, i32 3
  %16 = load i32, ptr %4, align 4, !tbaa !11
  %17 = sext i32 %16 to i64
  %18 = call noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorIN8nvinfer16plugin20GridAnchorParametersESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %17) #2
  %19 = getelementptr inbounds %"struct.nvinfer1::plugin::GridAnchorParameters", ptr %18, i32 0, i32 3
  %20 = load i32, ptr %19, align 8, !tbaa !23
  %21 = add nsw i32 6, %20
  %22 = sext i32 %21 to i64
  %23 = mul i64 %22, 4
  %24 = load i64, ptr %3, align 8, !tbaa !9
  %25 = add i64 %24, %23
  store i64 %25, ptr %3, align 8, !tbaa !9
  %26 = getelementptr inbounds %"class.nvinfer1::plugin::GridAnchorGenerator", ptr %5, i32 0, i32 5
  %27 = load ptr, ptr %26, align 8, !tbaa !26
  %28 = load i32, ptr %4, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %"class.nvinfer1::Weights", ptr %27, i64 %29
  %31 = getelementptr inbounds %"class.nvinfer1::Weights", ptr %30, i32 0, i32 2
  %32 = load i64, ptr %31, align 8, !tbaa !27
  %33 = mul i64 %32, 4
  %34 = load i64, ptr %3, align 8, !tbaa !9
  %35 = add i64 %34, %33
  store i64 %35, ptr %3, align 8, !tbaa !9
  %36 = getelementptr inbounds %"class.nvinfer1::plugin::GridAnchorGenerator", ptr %5, i32 0, i32 6
  %37 = load ptr, ptr %36, align 8, !tbaa !30
  %38 = load i32, ptr %4, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds %"class.nvinfer1::Weights", ptr %37, i64 %39
  %41 = getelementptr inbounds %"class.nvinfer1::Weights", ptr %40, i32 0, i32 2
  %42 = load i64, ptr %41, align 8, !tbaa !27
  %43 = mul i64 %42, 4
  %44 = load i64, ptr %3, align 8, !tbaa !9
  %45 = add i64 %44, %43
  store i64 %45, ptr %3, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %12
  %47 = load i32, ptr %4, align 4, !tbaa !11
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %4, align 4, !tbaa !11
  br label %6, !llvm.loop !31

49:                                               ; preds = %11
  %50 = load i64, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i64 %50
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorIN8nvinfer16plugin20GridAnchorParametersESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 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 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 40}
!14 = !{!"_ZTSN8nvinfer16plugin19GridAnchorGeneratorE", !15, i64 0, !17, i64 8, !12, i64 40, !19, i64 48, !6, i64 72, !6, i64 80, !6, i64 88, !17, i64 96}
!15 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !16, i64 0}
!16 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !10, i64 8, !7, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!19 = !{!"_ZTSSt6vectorIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!24, !12, i64 16}
!24 = !{!"_ZTSN8nvinfer16plugin20GridAnchorParametersE", !25, i64 0, !25, i64 4, !6, i64 8, !12, i64 16, !12, i64 20, !12, i64 24, !7, i64 28}
!25 = !{!"float", !7, i64 0}
!26 = !{!14, !6, i64 80}
!27 = !{!28, !10, i64 16}
!28 = !{!"_ZTSN8nvinfer17WeightsE", !29, i64 0, !6, i64 8, !10, i64 16}
!29 = !{!"_ZTSN8nvinfer18DataTypeE", !7, i64 0}
!30 = !{!14, !6, i64 88}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}


; 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::Weights" = type { i32, ptr, i64 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZNK8nvinfer16plugin19GridAnchorGenerator20getSerializationSizeEv(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = getelementptr inbounds i8, ptr %0, i64 80
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  br label %8

._crit_edge:                                      ; preds = %8, %1
  %.010.lcssa = phi i64 [ 4, %1 ], [ %21, %8 ]
  ret i64 %.010.lcssa

8:                                                ; preds = %.lr.ph, %8
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %8 ]
  %.01012 = phi i64 [ 4, %.lr.ph ], [ %21, %8 ]
  %9 = tail call noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorIN8nvinfer16plugin20GridAnchorParametersESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %indvars.iv) #1
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !20
  %12 = add nsw i32 %11, 6
  %13 = sext i32 %12 to i64
  %14 = load ptr, ptr %6, align 8, !tbaa !23
  %15 = getelementptr inbounds %"class.nvinfer1::Weights", ptr %14, i64 %indvars.iv, i32 2
  %16 = load i64, ptr %15, align 8, !tbaa !24
  %17 = load ptr, ptr %7, align 8, !tbaa !27
  %18 = getelementptr inbounds %"class.nvinfer1::Weights", ptr %17, i64 %indvars.iv, i32 2
  %19 = load i64, ptr %18, align 8, !tbaa !24
  %reass.add = add i64 %16, %13
  %reass.add11 = add i64 %reass.add, %19
  %reass.mul = shl i64 %reass.add11, 2
  %20 = add i64 %.01012, 16
  %21 = add i64 %20, %reass.mul
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = load i32, ptr %2, align 8, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = icmp slt i64 %indvars.iv.next, %23
  br i1 %24, label %8, label %._crit_edge, !llvm.loop !28
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(48) ptr @_ZNKSt6vectorIN8nvinfer16plugin20GridAnchorParametersESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 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 = { 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 40}
!6 = !{!"_ZTSN8nvinfer16plugin19GridAnchorGeneratorE", !7, i64 0, !9, i64 8, !15, i64 40, !16, i64 48, !11, i64 72, !11, i64 80, !11, i64 88, !9, i64 96}
!7 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !8, i64 0}
!8 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!9 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !10, i64 0, !14, i64 8, !12, i64 16}
!10 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !11, i64 0}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"long", !12, i64 0}
!15 = !{!"int", !12, i64 0}
!16 = !{!"_ZTSSt6vectorIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN8nvinfer16plugin20GridAnchorParametersESaIS2_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!20 = !{!21, !15, i64 16}
!21 = !{!"_ZTSN8nvinfer16plugin20GridAnchorParametersE", !22, i64 0, !22, i64 4, !11, i64 8, !15, i64 16, !15, i64 20, !15, i64 24, !12, i64 28}
!22 = !{!"float", !12, i64 0}
!23 = !{!6, !11, i64 80}
!24 = !{!25, !14, i64 16}
!25 = !{!"_ZTSN8nvinfer17WeightsE", !26, i64 0, !11, i64 8, !14, i64 16}
!26 = !{!"_ZTSN8nvinfer18DataTypeE", !12, i64 0}
!27 = !{!6, !11, i64 88}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass