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

; 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] }
%"class.nvinfer1::Dims3" = type { %"class.nvinfer1::Dims2" }
%"class.nvinfer1::Dims2" = type { %"class.nvinfer1::Dims64" }
%"class.nvinfer1::plugin::Reorg" = type { %"class.nvinfer1::IPluginV2Ext", i32, %"class.std::__cxx11::basic_string" }
%"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] }

@.str.3 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [11 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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8nvinfer16plugin11ReorgStatic19getOutputDimensionsEiPKNS_6Dims64Ei(ptr dead_on_unwind noalias writable sret(%"class.nvinfer1::Dims64") align 8 %0, ptr noundef nonnull align 8 dereferenceable(60) %1, i32 noundef %2, ptr noundef %3, i32 noundef %4) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.nvinfer1::Dims3", align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  store i32 %4, ptr %9, align 4, !tbaa !9
  %11 = load ptr, ptr %6, align 8
  %12 = load i32, ptr %9, align 4, !tbaa !9
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %16, label %14

14:                                               ; preds = %5
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.23, ptr noundef @.str.3, i32 noundef 261)
          to label %15 unwind label %54

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %15, %5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %21, label %19

19:                                               ; preds = %16
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef @.str.24, ptr noundef @.str.3, i32 noundef 262)
          to label %20 unwind label %54

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %20, %16
  call void @llvm.lifetime.start.p0(i64 72, ptr %10) #6
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %22, i64 0
  %24 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %23, i32 0, i32 1
  %25 = getelementptr inbounds [8 x i64], ptr %24, i64 0, i64 0
  %26 = load i64, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %"class.nvinfer1::plugin::Reorg", ptr %11, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = sext i32 %28 to i64
  %30 = mul nsw i64 %26, %29
  %31 = getelementptr inbounds %"class.nvinfer1::plugin::Reorg", ptr %11, i32 0, i32 1
  %32 = load i32, ptr %31, align 8, !tbaa !13
  %33 = sext i32 %32 to i64
  %34 = mul nsw i64 %30, %33
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %35, i64 0
  %37 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %36, i32 0, i32 1
  %38 = getelementptr inbounds [8 x i64], ptr %37, i64 0, i64 1
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = getelementptr inbounds %"class.nvinfer1::plugin::Reorg", ptr %11, i32 0, i32 1
  %41 = load i32, ptr %40, align 8, !tbaa !13
  %42 = sext i32 %41 to i64
  %43 = sdiv i64 %39, %42
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %44, i64 0
  %46 = getelementptr inbounds %"class.nvinfer1::Dims64", ptr %45, i32 0, i32 1
  %47 = getelementptr inbounds [8 x i64], ptr %46, i64 0, i64 2
  %48 = load i64, ptr %47, align 8, !tbaa !11
  %49 = getelementptr inbounds %"class.nvinfer1::plugin::Reorg", ptr %11, i32 0, i32 1
  %50 = load i32, ptr %49, align 8, !tbaa !13
  %51 = sext i32 %50 to i64
  %52 = sdiv i64 %48, %51
  invoke void @_ZN8nvinfer15Dims3C2Elll(ptr noundef nonnull align 8 dereferenceable(72) %10, i64 noundef %34, i64 noundef %43, i64 noundef %52)
          to label %53 unwind label %54

53:                                               ; preds = %21
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %0, ptr align 8 %10, i64 72, i1 false), !tbaa.struct !19
  call void @llvm.lifetime.end.p0(i64 72, ptr %10) #6
  ret void

54:                                               ; preds = %21, %19, %14
  %55 = landingpad { ptr, i32 }
          catch ptr null
  %56 = extractvalue { ptr, i32 } %55, 0
  call void @__clang_call_terminate(ptr %56) #7
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8nvinfer15Dims3C2Elll(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef, i64 noundef, i64 noundef) unnamed_addr #4 align 2

; 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) #5

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 = { "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 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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN8nvinfer16plugin5ReorgINS_12IPluginV2ExtEEE", !15, i64 0, !10, i64 8, !17, i64 16}
!15 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !16, i64 0}
!16 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !18, i64 0, !12, i64 8, !7, i64 16}
!18 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!19 = !{i64 0, i64 4, !9, i64 8, i64 64, !20}
!20 = !{!7, !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::Dims64" = type { i32, [8 x i64] }
%"class.nvinfer1::Dims3" = type { %"class.nvinfer1::Dims2" }
%"class.nvinfer1::Dims2" = type { %"class.nvinfer1::Dims64" }

@.str.3 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [11 x i8], align 1

; 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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8nvinfer16plugin11ReorgStatic19getOutputDimensionsEiPKNS_6Dims64Ei(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"class.nvinfer1::Dims64") align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(60) %1, i32 noundef %2, ptr nocapture noundef readonly %3, i32 noundef %4) unnamed_addr #3 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %"class.nvinfer1::Dims3", align 8
  %7 = icmp eq i32 %4, 1
  br i1 %7, label %9, label %8

8:                                                ; preds = %5
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.3, i32 noundef 261)
          to label %9 unwind label %27

9:                                                ; preds = %8, %5
  %10 = icmp eq i32 %2, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %9
  invoke void @_ZN8nvinfer16plugin15reportAssertionEPKcS2_i(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.3, i32 noundef 262)
          to label %12 unwind label %27

12:                                               ; preds = %11, %9
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %6) #6
  %13 = getelementptr inbounds i8, ptr %3, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = mul nsw i64 %14, %17
  %19 = mul nsw i64 %18, %17
  %20 = getelementptr inbounds i8, ptr %3, i64 16
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = sdiv i64 %21, %17
  %23 = getelementptr inbounds i8, ptr %3, i64 24
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = sdiv i64 %24, %17
  invoke void @_ZN8nvinfer15Dims3C2Elll(ptr noundef nonnull align 8 dereferenceable(72) %6, i64 noundef %19, i64 noundef %22, i64 noundef %25)
          to label %26 unwind label %27

26:                                               ; preds = %12
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(72) %6, i64 72, i1 false), !tbaa.struct !17
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %6) #6
  ret void

27:                                               ; preds = %12, %11, %8
  %28 = landingpad { ptr, i32 }
          catch ptr null
  %29 = extractvalue { ptr, i32 } %28, 0
  call void @__clang_call_terminate(ptr %29) #7
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8nvinfer15Dims3C2Elll(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef, i64 noundef, i64 noundef) unnamed_addr #4 align 2

; Function Attrs: mustprogress 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) #5

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 = { "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 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 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !13, i64 8}
!10 = !{!"_ZTSN8nvinfer16plugin5ReorgINS_12IPluginV2ExtEEE", !11, i64 0, !13, i64 8, !14, i64 16}
!11 = !{!"_ZTSN8nvinfer112IPluginV2ExtE", !12, i64 0}
!12 = !{!"_ZTSN8nvinfer19IPluginV2E"}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !6, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !16, i64 0}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{i64 0, i64 4, !18, i64 8, i64 64, !19}
!18 = !{!13, !13, i64 0}
!19 = !{!7, !7, i64 0}


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