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

; 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::Dims64" = type { i32, [8 x i64] }

@.str.107 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.116 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.117 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.118 = external hidden unnamed_addr constant [48 x i8], align 1

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8nvinfer16plugin15PyramidROIAlign18check_valid_inputsEPKNS_6Dims64Ei(ptr noundef nonnull align 8 dereferenceable(120) %0, ptr noundef %1, i32 noundef %2) #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.nvinfer1::Dims64", align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.nvinfer1::Dims64", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp eq i32 %11, 5
  br i1 %12, label %14, label %13

13:                                               ; preds = %3
  call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.115, ptr noundef @.str.107, i32 noundef 250)
  br label %14

14:                                               ; preds = %13, %3
  call void @llvm.lifetime.start.p0(i64 72, ptr %7) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %15, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %16, i64 72, i1 false), !tbaa.struct !11
  %17 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %7, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = icmp eq i32 %18, 2
  br i1 %19, label %21, label %20

20:                                               ; preds = %14
  call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.116, ptr noundef @.str.107, i32 noundef 253)
  br label %21

21:                                               ; preds = %20, %14
  %22 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %7, i32 0, i32 1
  %23 = getelementptr inbounds [8 x i64], ptr %22, i64 0, i64 1
  %24 = load i64, ptr %23, align 8, !tbaa !15
  %25 = icmp eq i64 %24, 4
  br i1 %25, label %27, label %26

26:                                               ; preds = %21
  call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.117, ptr noundef @.str.107, i32 noundef 254)
  br label %27

27:                                               ; preds = %26, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %55, %27
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %58

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 72, ptr %9) #4
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %34, i64 %36
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %37, i64 72, i1 false), !tbaa.struct !11
  %38 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %9, i32 0, i32 0
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = icmp eq i32 %39, 3
  br i1 %40, label %41, label %53

41:                                               ; preds = %33
  %42 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %9, i32 0, i32 1
  %43 = getelementptr inbounds [8 x i64], ptr %42, i64 0, i64 0
  %44 = load i64, ptr %43, align 8, !tbaa !15
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load i32, ptr %8, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %45, i64 %47
  %49 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %48, i32 0, i32 1
  %50 = getelementptr inbounds [8 x i64], ptr %49, i64 0, i64 0
  %51 = load i64, ptr %50, align 8, !tbaa !15
  %52 = icmp eq i64 %44, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %41, %33
  call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.118, ptr noundef @.str.107, i32 noundef 261)
  br label %54

54:                                               ; preds = %53, %41
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #4
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %8, align 4, !tbaa !9
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %8, align 4, !tbaa !9
  br label %28, !llvm.loop !17

58:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 72, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 = !{i64 0, i64 4, !9, i64 8, i64 64, !12}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN8nvinfer16Dims64E", !10, i64 0, !7, i64 8}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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::Dims64" = type { i32, [8 x i64] }

@.str.107 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.115 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.116 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.117 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.118 = external hidden unnamed_addr constant [48 x i8], align 1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8nvinfer16plugin15PyramidROIAlign18check_valid_inputsEPKNS_6Dims64Ei(ptr nocapture noundef nonnull readnone align 8 dereferenceable(120) %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = icmp eq i32 %2, 5
  br i1 %4, label %6, label %5

5:                                                ; preds = %3
  tail call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.115, ptr noundef nonnull @.str.107, i32 noundef 250)
  br label %6

6:                                                ; preds = %5, %3
  %.sroa.05.0.copyload = load i32, ptr %1, align 8, !tbaa !5
  %.sroa.47.0..sroa_idx = getelementptr inbounds i8, ptr %1, i64 16
  %.sroa.47.0.copyload = load i64, ptr %.sroa.47.0..sroa_idx, align 8
  %7 = icmp eq i32 %.sroa.05.0.copyload, 2
  br i1 %7, label %9, label %8

8:                                                ; preds = %6
  tail call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.116, ptr noundef nonnull @.str.107, i32 noundef 253)
  br label %9

9:                                                ; preds = %8, %6
  %10 = icmp eq i64 %.sroa.47.0.copyload, 4
  br i1 %10, label %12, label %11

11:                                               ; preds = %9
  tail call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.117, ptr noundef nonnull @.str.107, i32 noundef 254)
  br label %12

12:                                               ; preds = %11, %9
  %13 = icmp sgt i32 %2, 1
  br i1 %13, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %12
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %17, %12
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %17 ]
  %14 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %1, i64 %indvars.iv
  %.sroa.0.0.copyload = load i32, ptr %14, align 8, !tbaa !5
  %15 = icmp eq i32 %.sroa.0.0.copyload, 3
  br i1 %15, label %17, label %16

16:                                               ; preds = %.lr.ph
  tail call void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.118, ptr noundef nonnull @.str.107, i32 noundef 261)
  br label %17

17:                                               ; preds = %.lr.ph, %16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9
}

attributes #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 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass