; LLVM IR from ermig1979/Simd :: src/Simd (SimdBaseSynetDeconvolution16bNhwcGemm)

; 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.Simd::SynetDeconvolution16b" = type { %"struct.Simd::Deletable", %"struct.Simd::DeconvParam", %"struct.Simd::Array", %"class.std::__cxx11::basic_string", %"struct.Simd::Array.0", %"struct.Simd::Array.1", %"struct.Simd::Array.1", i8, i8, i8, i64, i64, i64, i64 }
%"struct.Simd::Deletable" = type { ptr }
%"struct.Simd::DeconvParam" = type <{ %struct.SimdConvolutionParameters, i32, [4 x i8], i64, i32, [4 x i8] }>
%struct.SimdConvolutionParameters = type { i64, i64, i64, i32, i32, i64, i64, i64, i32, i32, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i32 }
%"struct.Simd::Array" = type { ptr, i64 }
%"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.Simd::Array.0" = type { ptr, i64 }
%"struct.Simd::Array.1" = type { ptr, i64 }
%"class.Simd::Base::SynetDeconvolution16bNhwcGemm" = type { %"class.Simd::SynetDeconvolution16b", %"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam", ptr, ptr, ptr, ptr }
%"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam" = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_ZNK4Simd4Base29SynetDeconvolution16bNhwcGemm18ExternalBufferSizeEv(ptr noundef nonnull align 8 dereferenceable(488) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %7 = getelementptr inbounds %"class.Simd::SynetDeconvolution16b", ptr %6, i32 0, i32 1
  store ptr %7, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %8 = getelementptr inbounds %"class.Simd::Base::SynetDeconvolution16bNhwcGemm", ptr %6, i32 0, i32 1
  store ptr %8, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !9
  %9 = getelementptr inbounds %"class.Simd::SynetDeconvolution16b", ptr %6, i32 0, i32 7
  %10 = load i8, ptr %9, align 8, !tbaa !11, !range !27, !noundef !28
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %20

12:                                               ; preds = %1
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam", ptr %13, i32 0, i32 13
  %15 = load i64, ptr %14, align 8, !tbaa !29
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam", ptr %16, i32 0, i32 2
  %18 = load i64, ptr %17, align 8, !tbaa !31
  %19 = icmp ne i64 %15, %18
  br i1 %19, label %20, label %31

20:                                               ; preds = %12, %1
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam", ptr %21, i32 0, i32 13
  %23 = load i64, ptr %22, align 8, !tbaa !29
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam", ptr %24, i32 0, i32 11
  %26 = load i64, ptr %25, align 8, !tbaa !32
  %27 = mul i64 %23, %26
  %28 = mul i64 %27, 2
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = add i64 %29, %28
  store i64 %30, ptr %5, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %20, %12
  %32 = getelementptr inbounds %"class.Simd::SynetDeconvolution16b", ptr %6, i32 0, i32 9
  %33 = load i8, ptr %32, align 2, !tbaa !33, !range !27, !noundef !28
  %34 = trunc i8 %33 to i1
  br i1 %34, label %46, label %35

35:                                               ; preds = %31
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam", ptr %36, i32 0, i32 12
  %38 = load i64, ptr %37, align 8, !tbaa !34
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.Simd::Base::SynetDeconvolution16bNhwcGemm::AlgParam", ptr %39, i32 0, i32 11
  %41 = load i64, ptr %40, align 8, !tbaa !32
  %42 = mul i64 %38, %41
  %43 = mul i64 %42, 4
  %44 = load i64, ptr %5, align 8, !tbaa !9
  %45 = add i64 %44, %43
  store i64 %45, ptr %5, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %35, %31
  %47 = getelementptr inbounds %"class.Simd::SynetDeconvolution16b", ptr %6, i32 0, i32 8
  %48 = load i8, ptr %47, align 1, !tbaa !35, !range !27, !noundef !28
  %49 = trunc i8 %48 to i1
  br i1 %49, label %50, label %65

50:                                               ; preds = %46
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.SimdConvolutionParameters, ptr %51, i32 0, i32 6
  %53 = load i64, ptr %52, align 8, !tbaa !36
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.SimdConvolutionParameters, ptr %54, i32 0, i32 7
  %56 = load i64, ptr %55, align 8, !tbaa !37
  %57 = mul i64 %53, %56
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.SimdConvolutionParameters, ptr %58, i32 0, i32 5
  %60 = load i64, ptr %59, align 8, !tbaa !38
  %61 = mul i64 %57, %60
  %62 = mul i64 %61, 4
  %63 = load i64, ptr %5, align 8, !tbaa !9
  %64 = add i64 %63, %62
  store i64 %64, ptr %5, align 8, !tbaa !9
  br label %65

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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !26, i64 288}
!12 = !{!"_ZTSN4Simd21SynetDeconvolution16bE", !13, i64 0, !14, i64 8, !21, i64 192, !22, i64 208, !24, i64 240, !25, i64 256, !25, i64 272, !26, i64 288, !26, i64 289, !26, i64 290, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320}
!13 = !{!"_ZTSN4Simd9DeletableE"}
!14 = !{!"_ZTSN4Simd11DeconvParamE", !15, i64 0, !19, i64 160, !10, i64 168, !20, i64 176}
!15 = !{!"_ZTS25SimdConvolutionParameters", !10, i64 0, !10, i64 8, !10, i64 16, !16, i64 24, !17, i64 28, !10, i64 32, !10, i64 40, !10, i64 48, !16, i64 56, !17, i64 60, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !18, i64 152}
!16 = !{!"_ZTS18SimdTensorDataType", !7, i64 0}
!17 = !{!"_ZTS20SimdTensorFormatType", !7, i64 0}
!18 = !{!"_ZTS29SimdConvolutionActivationType", !7, i64 0}
!19 = !{!"_ZTS8SimdBool", !7, i64 0}
!20 = !{!"_ZTS26SimdSynetCompatibilityType", !7, i64 0}
!21 = !{!"_ZTSN4Simd5ArrayIhEE", !6, i64 0, !10, i64 8}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !23, i64 0, !10, i64 8, !7, i64 16}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!24 = !{!"_ZTSN4Simd5ArrayItEE", !6, i64 0, !10, i64 8}
!25 = !{!"_ZTSN4Simd5ArrayIfEE", !6, i64 0, !10, i64 8}
!26 = !{!"bool", !7, i64 0}
!27 = !{i8 0, i8 2}
!28 = !{}
!29 = !{!30, !10, i64 104}
!30 = !{!"_ZTSN4Simd4Base29SynetDeconvolution16bNhwcGemm8AlgParamE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!31 = !{!30, !10, i64 16}
!32 = !{!30, !10, i64 88}
!33 = !{!12, !26, i64 290}
!34 = !{!30, !10, i64 96}
!35 = !{!12, !26, i64 289}
!36 = !{!15, !10, i64 40}
!37 = !{!15, !10, i64 48}
!38 = !{!15, !10, i64 32}


; 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef i64 @_ZNK4Simd4Base29SynetDeconvolution16bNhwcGemm18ExternalBufferSizeEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(488) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 288
  %3 = load i8, ptr %2, align 8, !tbaa !5, !range !25, !noundef !26
  %4 = trunc nuw i8 %3 to i1
  %5 = getelementptr inbounds i8, ptr %0, i64 432
  %6 = load i64, ptr %5, align 8, !tbaa !27
  %7 = getelementptr inbounds i8, ptr %0, i64 344
  %8 = load i64, ptr %7, align 8
  %.not = icmp eq i64 %6, %8
  %or.cond = select i1 %4, i1 %.not, i1 false
  %9 = getelementptr inbounds i8, ptr %0, i64 416
  %10 = load i64, ptr %9, align 8
  %11 = shl i64 %6, 1
  %12 = mul i64 %11, %10
  %.0 = select i1 %or.cond, i64 0, i64 %12
  %13 = getelementptr inbounds i8, ptr %0, i64 290
  %14 = load i8, ptr %13, align 2, !tbaa !29, !range !25, !noundef !26
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %24, label %16

16:                                               ; preds = %1
  %17 = getelementptr inbounds i8, ptr %0, i64 424
  %18 = load i64, ptr %17, align 8, !tbaa !30
  %19 = getelementptr inbounds i8, ptr %0, i64 416
  %20 = load i64, ptr %19, align 8, !tbaa !31
  %21 = shl i64 %18, 2
  %22 = mul i64 %21, %20
  %23 = add i64 %22, %.0
  br label %24

24:                                               ; preds = %16, %1
  %.1 = phi i64 [ %.0, %1 ], [ %23, %16 ]
  %25 = getelementptr inbounds i8, ptr %0, i64 289
  %26 = load i8, ptr %25, align 1, !tbaa !32, !range !25, !noundef !26
  %27 = trunc nuw i8 %26 to i1
  br i1 %27, label %28, label %39

28:                                               ; preds = %24
  %29 = getelementptr inbounds i8, ptr %0, i64 48
  %30 = load i64, ptr %29, align 8, !tbaa !33
  %31 = getelementptr inbounds i8, ptr %0, i64 56
  %32 = load i64, ptr %31, align 8, !tbaa !34
  %33 = getelementptr inbounds i8, ptr %0, i64 40
  %34 = load i64, ptr %33, align 8, !tbaa !35
  %35 = shl i64 %30, 2
  %36 = mul i64 %35, %32
  %37 = mul i64 %36, %34
  %38 = add i64 %37, %.1
  br label %39

39:                                               ; preds = %28, %24
  %.2 = phi i64 [ %38, %28 ], [ %.1, %24 ]
  ret i64 %.2
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !24, i64 288}
!6 = !{!"_ZTSN4Simd21SynetDeconvolution16bE", !7, i64 0, !8, i64 8, !18, i64 192, !20, i64 208, !22, i64 240, !23, i64 256, !23, i64 272, !24, i64 288, !24, i64 289, !24, i64 290, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320}
!7 = !{!"_ZTSN4Simd9DeletableE"}
!8 = !{!"_ZTSN4Simd11DeconvParamE", !9, i64 0, !16, i64 160, !10, i64 168, !17, i64 176}
!9 = !{!"_ZTS25SimdConvolutionParameters", !10, i64 0, !10, i64 8, !10, i64 16, !13, i64 24, !14, i64 28, !10, i64 32, !10, i64 40, !10, i64 48, !13, i64 56, !14, i64 60, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !15, i64 152}
!10 = !{!"long", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"_ZTS18SimdTensorDataType", !11, i64 0}
!14 = !{!"_ZTS20SimdTensorFormatType", !11, i64 0}
!15 = !{!"_ZTS29SimdConvolutionActivationType", !11, i64 0}
!16 = !{!"_ZTS8SimdBool", !11, i64 0}
!17 = !{!"_ZTS26SimdSynetCompatibilityType", !11, i64 0}
!18 = !{!"_ZTSN4Simd5ArrayIhEE", !19, i64 0, !10, i64 8}
!19 = !{!"any pointer", !11, i64 0}
!20 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !21, i64 0, !10, i64 8, !11, i64 16}
!21 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !19, i64 0}
!22 = !{!"_ZTSN4Simd5ArrayItEE", !19, i64 0, !10, i64 8}
!23 = !{!"_ZTSN4Simd5ArrayIfEE", !19, i64 0, !10, i64 8}
!24 = !{!"bool", !11, i64 0}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!28, !10, i64 104}
!28 = !{!"_ZTSN4Simd4Base29SynetDeconvolution16bNhwcGemm8AlgParamE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120}
!29 = !{!6, !24, i64 290}
!30 = !{!28, !10, i64 96}
!31 = !{!28, !10, i64 88}
!32 = !{!6, !24, i64 289}
!33 = !{!9, !10, i64 40}
!34 = !{!9, !10, i64 48}
!35 = !{!9, !10, i64 32}


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