; LLVM IR from huawei-noah/bolt :: compute/tensor/src/cpu/arm (depthwise_pointwise_convolution)

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

%struct.TensorDesc = type { i32, i32, i32, [20 x i32] }
%struct.ConvolutionParamSpec = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %union.ActivationSpec, i32, i32, i32, i32 }
%union.ActivationSpec = type { %struct.ClipParamSpec }
%struct.ClipParamSpec = type { float, float }
%struct.ActivationParamSpec = type { i32, [4 x float] }

; 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: 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: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z14tensorNumBytes10TensorDesc(ptr noundef byval(%struct.TensorDesc) align 8) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z35depthwise_pointwise_convolution_arm10TensorDescPvS_PKvS_S2_20ConvolutionParamSpec36DepthwiseConvolutionForwardAlgorithmS_S2_S_S2_jS0_S_S0_19ActivationParamSpecS5_4Arch(ptr noundef byval(%struct.TensorDesc) align 8 %0, ptr noundef %1, ptr noundef byval(%struct.TensorDesc) align 8 %2, ptr noundef %3, ptr noundef byval(%struct.TensorDesc) align 8 %4, ptr noundef %5, ptr noundef byval(%struct.ConvolutionParamSpec) align 8 %6, i32 noundef %7, ptr noundef byval(%struct.TensorDesc) align 8 %8, ptr noundef %9, ptr noundef byval(%struct.TensorDesc) align 8 %10, ptr noundef %11, i32 noundef %12, ptr noundef %13, ptr noundef byval(%struct.TensorDesc) align 8 %14, ptr noundef %15, ptr noundef byval(%struct.ActivationParamSpec) align 8 %16, ptr noundef byval(%struct.ActivationParamSpec) align 8 %17, i32 noundef %18) #3 {
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  %27 = alloca ptr, align 8
  %28 = alloca ptr, align 8
  %29 = alloca i32, align 4
  %30 = alloca %struct.TensorDesc, align 4
  %31 = alloca ptr, align 8
  %32 = alloca %struct.TensorDesc, align 8
  %33 = alloca %struct.TensorDesc, align 8
  %34 = alloca %struct.TensorDesc, align 8
  %35 = alloca %struct.TensorDesc, align 8
  %36 = alloca i32, align 4
  store ptr %1, ptr %20, align 8, !tbaa !5
  store ptr %3, ptr %21, align 8, !tbaa !5
  store ptr %5, ptr %22, align 8, !tbaa !5
  store i32 %7, ptr %23, align 4, !tbaa !9
  store ptr %9, ptr %24, align 8, !tbaa !5
  store ptr %11, ptr %25, align 8, !tbaa !5
  store i32 %12, ptr %26, align 4, !tbaa !11
  store ptr %13, ptr %27, align 8, !tbaa !5
  store ptr %15, ptr %28, align 8, !tbaa !5
  store i32 %18, ptr %29, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 92, ptr %30) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 8 %0, i64 92, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #5
  %37 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %37, ptr %31, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.TensorDesc, ptr %0, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !21
  %40 = icmp ne i32 %39, 2
  br i1 %40, label %41, label %54

41:                                               ; preds = %19
  %42 = getelementptr inbounds %struct.TensorDesc, ptr %30, i32 0, i32 1
  store i32 2, ptr %42, align 4, !tbaa !21
  %43 = load ptr, ptr %27, align 8, !tbaa !5
  store ptr %43, ptr %31, align 8, !tbaa !5
  %44 = load ptr, ptr %27, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 8 %0, i64 92, i1 false), !tbaa.struct !15
  %45 = call noundef i32 @_Z14tensorNumBytes10TensorDesc(ptr noundef byval(%struct.TensorDesc) align 8 %32)
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  store ptr %47, ptr %27, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %33, ptr align 8 %0, i64 92, i1 false), !tbaa.struct !15
  %48 = call noundef i32 @_Z14tensorNumBytes10TensorDesc(ptr noundef byval(%struct.TensorDesc) align 8 %33)
  %49 = load i32, ptr %26, align 4, !tbaa !11
  %50 = sub i32 %49, %48
  store i32 %50, ptr %26, align 4, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 8 %0, i64 92, i1 false), !tbaa.struct !15
  %51 = load ptr, ptr %20, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %35, ptr align 4 %30, i64 92, i1 false), !tbaa.struct !15
  %52 = load ptr, ptr %31, align 8, !tbaa !5
  %53 = call noundef i32 @_Z21transformNCHWToNCHWC810TensorDescPKvS_Pv(ptr noundef byval(%struct.TensorDesc) align 8 %34, ptr noundef %51, ptr noundef byval(%struct.TensorDesc) align 8 %35, ptr noundef %52)
  br label %54

54:                                               ; preds = %41, %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %36) #5
  store i32 0, ptr %36, align 4, !tbaa !23
  %55 = getelementptr inbounds %struct.TensorDesc, ptr %2, i32 0, i32 0
  %56 = load i32, ptr %55, align 8, !tbaa !25
  switch i32 %56, label %57 [
  ]

57:                                               ; preds = %54
  store i32 51, ptr %36, align 4, !tbaa !23
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %36, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, ptr %36) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #5
  call void @llvm.lifetime.end.p0(i64 92, ptr %30) #5
  ret i32 %59
}

declare noundef i32 @_Z21transformNCHWToNCHWC810TensorDescPKvS_Pv(ptr noundef byval(%struct.TensorDesc) align 8, ptr noundef, ptr noundef byval(%struct.TensorDesc) align 8, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #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 = { "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 }

!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 = !{!"_ZTS36DepthwiseConvolutionForwardAlgorithm", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTS4Arch", !7, i64 0}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !18, i64 8, i64 4, !11, i64 12, i64 80, !20}
!16 = !{!17, !17, i64 0}
!17 = !{!"_ZTS8DataType", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"_ZTS10DataFormat", !7, i64 0}
!20 = !{!7, !7, i64 0}
!21 = !{!22, !19, i64 4}
!22 = !{!"_ZTS10TensorDesc", !17, i64 0, !19, i64 4, !12, i64 8, !7, i64 12}
!23 = !{!24, !24, i64 0}
!24 = !{!"_ZTS2EE", !7, i64 0}
!25 = !{!22, !17, 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"

%struct.TensorDesc = type { i32, i32, i32, [20 x i32] }
%struct.ConvolutionParamSpec = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %union.ActivationSpec, i32, i32, i32, i32 }
%union.ActivationSpec = type { %struct.ClipParamSpec }
%struct.ClipParamSpec = type { float, float }
%struct.ActivationParamSpec = type { i32, [4 x float] }

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z14tensorNumBytes10TensorDesc(ptr noundef byval(%struct.TensorDesc) align 8) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z35depthwise_pointwise_convolution_arm10TensorDescPvS_PKvS_S2_20ConvolutionParamSpec36DepthwiseConvolutionForwardAlgorithmS_S2_S_S2_jS0_S_S0_19ActivationParamSpecS5_4Arch(ptr nocapture noundef readonly byval(%struct.TensorDesc) align 8 %0, ptr noundef %1, ptr nocapture noundef readnone byval(%struct.TensorDesc) align 8 %2, ptr nocapture noundef readnone %3, ptr nocapture noundef readnone byval(%struct.TensorDesc) align 8 %4, ptr nocapture noundef readnone %5, ptr nocapture noundef readnone byval(%struct.ConvolutionParamSpec) align 8 %6, i32 noundef %7, ptr nocapture noundef readnone byval(%struct.TensorDesc) align 8 %8, ptr nocapture noundef readnone %9, ptr nocapture noundef readnone byval(%struct.TensorDesc) align 8 %10, ptr nocapture noundef readnone %11, i32 noundef %12, ptr noundef %13, ptr nocapture noundef readnone byval(%struct.TensorDesc) align 8 %14, ptr nocapture noundef readnone %15, ptr nocapture noundef readnone byval(%struct.ActivationParamSpec) align 8 %16, ptr nocapture noundef readnone byval(%struct.ActivationParamSpec) align 8 %17, i32 noundef %18) local_unnamed_addr #3 {
  %.sroa.5 = alloca { i32, [20 x i32] }, align 8
  %20 = alloca %struct.TensorDesc, align 8
  call void @llvm.lifetime.start.p0(i64 84, ptr nonnull %.sroa.5)
  %.sroa.0.0.copyload = load i32, ptr %0, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 4
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(84) %.sroa.5, ptr noundef nonnull align 8 dereferenceable(84) %.sroa.5.0..sroa_idx, i64 84, i1 false), !tbaa.struct !9
  %21 = load i32, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !13
  %.not = icmp eq i32 %21, 2
  br i1 %.not, label %26, label %22

22:                                               ; preds = %19
  %23 = tail call noundef i32 @_Z14tensorNumBytes10TensorDesc(ptr noundef nonnull byval(%struct.TensorDesc) align 8 %0)
  %24 = tail call noundef i32 @_Z14tensorNumBytes10TensorDesc(ptr noundef nonnull byval(%struct.TensorDesc) align 8 %0)
  store i32 %.sroa.0.0.copyload, ptr %20, align 8, !tbaa !5
  %.sroa.4.0..sroa_idx2 = getelementptr inbounds i8, ptr %20, i64 4
  store i32 2, ptr %.sroa.4.0..sroa_idx2, align 4, !tbaa !16
  %.sroa.5.0..sroa_idx4 = getelementptr inbounds i8, ptr %20, i64 8
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(84) %.sroa.5.0..sroa_idx4, ptr noundef nonnull align 8 dereferenceable(84) %.sroa.5, i64 84, i1 false), !tbaa.struct !9
  %25 = tail call noundef i32 @_Z21transformNCHWToNCHWC810TensorDescPKvS_Pv(ptr noundef nonnull byval(%struct.TensorDesc) align 8 %0, ptr noundef %1, ptr noundef nonnull byval(%struct.TensorDesc) align 8 %20, ptr noundef %13)
  br label %26

26:                                               ; preds = %22, %19
  call void @llvm.lifetime.end.p0(i64 84, ptr nonnull %.sroa.5)
  ret i32 51
}

declare noundef i32 @_Z21transformNCHWToNCHWC810TensorDescPKvS_Pv(ptr noundef byval(%struct.TensorDesc) align 8, ptr noundef, ptr noundef byval(%struct.TensorDesc) align 8, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #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 = { "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 = !{!"_ZTS8DataType", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 4, !10, i64 4, i64 80, !12}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !15, i64 4}
!14 = !{!"_ZTS10TensorDesc", !6, i64 0, !15, i64 4, !11, i64 8, !7, i64 12}
!15 = !{!"_ZTS10DataFormat", !7, i64 0}
!16 = !{!15, !15, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass