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

; 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.98 = external hidden unnamed_addr constant [120 x i8], align 1
@.str.103 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.104 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.106 = 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

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: 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) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8nvinfer16plugin23MultilevelCropAndResize18check_valid_inputsEPKNS_6Dims64Ei(ptr noundef nonnull align 8 dereferenceable(116) %0, ptr noundef %1, i32 noundef %2) #3 align 2 personality ptr @__gxx_personality_v0 {
  %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, 6
  br i1 %12, label %15, label %13

13:                                               ; preds = %3
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.103, ptr noundef @.str.98, i32 noundef 190)
          to label %14 unwind label %61

14:                                               ; preds = %13
  br label %15

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

21:                                               ; preds = %15
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.104, ptr noundef @.str.98, i32 noundef 193)
          to label %22 unwind label %61

22:                                               ; preds = %21
  br label %23

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

28:                                               ; preds = %23
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.105, ptr noundef @.str.98, i32 noundef 194)
          to label %29 unwind label %61

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29, %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %57, %30
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %60

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

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

54:                                               ; preds = %44, %36
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.106, ptr noundef @.str.98, i32 noundef 201)
          to label %55 unwind label %61

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55, %44
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #5
  br label %57

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

60:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 72, ptr %7) #5
  ret void

61:                                               ; preds = %54, %28, %21, %13
  %62 = landingpad { ptr, i32 }
          catch ptr null
  %63 = extractvalue { ptr, i32 } %62, 0
  call void @__clang_call_terminate(ptr %63) #6
  unreachable
}

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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 }
attributes #6 = { 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 = !{!"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.98 = external hidden unnamed_addr constant [120 x i8], align 1
@.str.103 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.104 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.105 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.106 = external hidden unnamed_addr constant [48 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

5:                                                ; preds = %3
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.103, ptr noundef nonnull @.str.98, i32 noundef 190)
          to label %6 unwind label %.loopexit.split-lp

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

8:                                                ; preds = %6
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.104, ptr noundef nonnull @.str.98, i32 noundef 193)
          to label %9 unwind label %.loopexit.split-lp

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

11:                                               ; preds = %9
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.105, ptr noundef nonnull @.str.98, i32 noundef 194)
          to label %12 unwind label %.loopexit.split-lp

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

.lr.ph:                                           ; preds = %12
  %14 = getelementptr inbounds i8, ptr %1, i64 80
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %15

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

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

18:                                               ; preds = %15
  %.sroa.41.0..sroa_idx = getelementptr inbounds i8, ptr %16, i64 8
  %.sroa.41.0.copyload = load i64, ptr %.sroa.41.0..sroa_idx, align 8
  %19 = load i64, ptr %14, align 8, !tbaa !9
  %20 = icmp eq i64 %.sroa.41.0.copyload, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %18, %15
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.106, ptr noundef nonnull @.str.98, i32 noundef 201)
          to label %22 unwind label %.loopexit

22:                                               ; preds = %21, %18
  %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 %15, !llvm.loop !11

.loopexit:                                        ; preds = %21
  %lpad.loopexit = landingpad { ptr, i32 }
          catch ptr null
  br label %23

.loopexit.split-lp:                               ; preds = %5, %8, %11
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          catch ptr null
  br label %23

23:                                               ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  %24 = extractvalue { ptr, i32 } %lpad.phi, 0
  tail call void @__clang_call_terminate(ptr %24) #3
  unreachable
}

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

attributes #0 = { 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 #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 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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