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

; 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::SynetInnerProduct16b" = type { %"struct.Simd::Deletable", %"struct.Simd::InnerProductParam16b", %"struct.Simd::Array", %"struct.Simd::Array.0", %"struct.Simd::Array.1", %"class.std::__cxx11::basic_string", i64, i64, i64 }
%"struct.Simd::Deletable" = type { ptr }
%"struct.Simd::InnerProductParam16b" = type { i64, i64, i64, i32, i32, i32, i32, i32, i32 }
%"struct.Simd::Array" = type { ptr, i64 }
%"struct.Simd::Array.0" = type { ptr, i64 }
%"struct.Simd::Array.1" = 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] }
%"class.Simd::Base::SynetInnerProduct16bGemmNN" = type { %"class.Simd::SynetInnerProduct16b", %"struct.Simd::Base::SynetInnerProduct16bGemmNN::AlgParam", ptr, ptr, ptr }
%"struct.Simd::Base::SynetInnerProduct16bGemmNN::AlgParam" = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [96 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Simd4Base26SynetInnerProduct16bGemmNN9SetParamsEPKfS3_ = external hidden unnamed_addr constant [93 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base26SynetInnerProduct16bGemmNN9SetParamsEPKfS3_(ptr noundef nonnull align 8 dereferenceable(304) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %10 = getelementptr inbounds %"class.Simd::SynetInnerProduct16b", ptr %9, i32 0, i32 1
  store ptr %10, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %11 = getelementptr inbounds %"class.Simd::Base::SynetInnerProduct16bGemmNN", ptr %9, i32 0, i32 1
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.Simd::InnerProductParam16b", ptr %12, i32 0, i32 7
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %45

16:                                               ; preds = %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  br label %22

20:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 153, ptr noundef @__PRETTY_FUNCTION__._ZN4Simd4Base26SynetInnerProduct16bGemmNN9SetParamsEPKfS3_) #6
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  %23 = getelementptr inbounds %"class.Simd::SynetInnerProduct16b", ptr %9, i32 0, i32 3
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.Simd::Base::SynetInnerProduct16bGemmNN::AlgParam", ptr %24, i32 0, i32 9
  %26 = load i64, ptr %25, align 8, !tbaa !14
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.Simd::Base::SynetInnerProduct16bGemmNN::AlgParam", ptr %27, i32 0, i32 8
  %29 = load i64, ptr %28, align 8, !tbaa !16
  %30 = mul i64 %26, %29
  call void @_ZN4Simd5ArrayItE6ResizeEmbm(ptr noundef nonnull align 8 dereferenceable(16) %23, i64 noundef %30, i1 noundef zeroext true, i64 noundef 8)
  %31 = getelementptr inbounds %"class.Simd::Base::SynetInnerProduct16bGemmNN", ptr %9, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !17
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.Simd::InnerProductParam16b", ptr %36, i32 0, i32 1
  %38 = load i64, ptr %37, align 8, !tbaa !26
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.Simd::InnerProductParam16b", ptr %39, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !27
  %42 = getelementptr inbounds %"class.Simd::SynetInnerProduct16b", ptr %9, i32 0, i32 3
  %43 = getelementptr inbounds %"struct.Simd::Array.0", ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !28
  call void %32(ptr noundef %33, ptr noundef nonnull align 8 dereferenceable(48) %34, ptr noundef nonnull align 8 dereferenceable(120) %35, i64 noundef %38, i64 noundef %41, ptr noundef %44)
  br label %45

45:                                               ; preds = %22, %3
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.Simd::InnerProductParam16b", ptr %46, i32 0, i32 8
  %48 = load i32, ptr %47, align 4, !tbaa !29
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %62

50:                                               ; preds = %45
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %62

53:                                               ; preds = %50
  %54 = getelementptr inbounds %"class.Simd::SynetInnerProduct16b", ptr %9, i32 0, i32 4
  %55 = getelementptr inbounds %"struct.Simd::Array.1", ptr %54, i32 0, i32 0
  %56 = load ptr, ptr %55, align 8, !tbaa !30
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.Simd::InnerProductParam16b", ptr %58, i32 0, i32 1
  %60 = load i64, ptr %59, align 8, !tbaa !26
  %61 = mul i64 %60, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %56, ptr align 4 %57, i64 %61, i1 false)
  br label %62

62:                                               ; preds = %53, %50, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd5ArrayItE6ResizeEmbm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i1 noundef zeroext, i64 noundef) #3 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) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { noreturn nounwind "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 = { alwaysinline 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !13, i64 40}
!10 = !{!"_ZTSN4Simd20InnerProductParam16bE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 28, !12, i64 32, !13, i64 36, !13, i64 40, !13, i64 44}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTS18SimdTensorDataType", !7, i64 0}
!13 = !{!"_ZTS8SimdBool", !7, i64 0}
!14 = !{!15, !11, i64 72}
!15 = !{!"_ZTSN4Simd4Base26SynetInnerProduct16bGemmNN8AlgParamE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !11, i64 96, !11, i64 104, !11, i64 112}
!16 = !{!15, !11, i64 64}
!17 = !{!18, !6, i64 288}
!18 = !{!"_ZTSN4Simd4Base26SynetInnerProduct16bGemmNNE", !19, i64 0, !15, i64 160, !6, i64 280, !6, i64 288, !6, i64 296}
!19 = !{!"_ZTSN4Simd20SynetInnerProduct16bE", !20, i64 0, !10, i64 8, !21, i64 56, !22, i64 72, !23, i64 88, !24, i64 104, !11, i64 136, !11, i64 144, !11, i64 152}
!20 = !{!"_ZTSN4Simd9DeletableE"}
!21 = !{!"_ZTSN4Simd5ArrayIhEE", !6, i64 0, !11, i64 8}
!22 = !{!"_ZTSN4Simd5ArrayItEE", !6, i64 0, !11, i64 8}
!23 = !{!"_ZTSN4Simd5ArrayIfEE", !6, i64 0, !11, i64 8}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !25, i64 0, !11, i64 8, !7, i64 16}
!25 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!26 = !{!10, !11, i64 8}
!27 = !{!10, !11, i64 16}
!28 = !{!19, !6, i64 72}
!29 = !{!10, !13, i64 44}
!30 = !{!19, !6, i64 88}


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

@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [96 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Simd4Base26SynetInnerProduct16bGemmNN9SetParamsEPKfS3_ = external hidden unnamed_addr constant [93 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base26SynetInnerProduct16bGemmNN9SetParamsEPKfS3_(ptr noundef nonnull align 8 dereferenceable(304) %0, ptr noundef %1, ptr noundef readonly %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = getelementptr inbounds i8, ptr %0, i64 160
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %24, label %8

8:                                                ; preds = %3
  %.not16 = icmp eq ptr %1, null
  br i1 %.not16, label %9, label %10

9:                                                ; preds = %8
  tail call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 153, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4Simd4Base26SynetInnerProduct16bGemmNN9SetParamsEPKfS3_) #4
  unreachable

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %0, i64 72
  %12 = getelementptr inbounds i8, ptr %0, i64 232
  %13 = load i64, ptr %12, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 224
  %15 = load i64, ptr %14, align 8, !tbaa !14
  %16 = mul i64 %15, %13
  tail call void @_ZN4Simd5ArrayItE6ResizeEmbm(ptr noundef nonnull align 8 dereferenceable(16) %11, i64 noundef %16, i1 noundef zeroext true, i64 noundef 8)
  %17 = getelementptr inbounds i8, ptr %0, i64 288
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %0, i64 16
  %20 = load i64, ptr %19, align 8, !tbaa !25
  %21 = getelementptr inbounds i8, ptr %0, i64 24
  %22 = load i64, ptr %21, align 8, !tbaa !26
  %23 = load ptr, ptr %11, align 8, !tbaa !27
  tail call void %18(ptr noundef nonnull %1, ptr noundef nonnull align 8 dereferenceable(48) %4, ptr noundef nonnull align 8 dereferenceable(120) %5, i64 noundef %20, i64 noundef %22, ptr noundef %23)
  br label %24

24:                                               ; preds = %10, %3
  %25 = getelementptr inbounds i8, ptr %0, i64 52
  %26 = load i32, ptr %25, align 4, !tbaa !28
  %27 = icmp ne i32 %26, 0
  %28 = icmp ne ptr %2, null
  %or.cond = and i1 %28, %27
  br i1 %or.cond, label %29, label %35

29:                                               ; preds = %24
  %30 = getelementptr inbounds i8, ptr %0, i64 88
  %31 = load ptr, ptr %30, align 8, !tbaa !29
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  %33 = load i64, ptr %32, align 8, !tbaa !25
  %34 = shl i64 %33, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %31, ptr nonnull align 4 %2, i64 %34, i1 false)
  br label %35

35:                                               ; preds = %29, %24
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd5ArrayItE6ResizeEmbm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i1 noundef zeroext, i64 noundef) local_unnamed_addr #2 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) #3

attributes #0 = { 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 #1 = { noreturn nounwind "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 = { alwaysinline 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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !11, i64 40}
!6 = !{!"_ZTSN4Simd20InnerProductParam16bE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !11, i64 36, !11, i64 40, !11, i64 44}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS18SimdTensorDataType", !8, i64 0}
!11 = !{!"_ZTS8SimdBool", !8, i64 0}
!12 = !{!13, !7, i64 72}
!13 = !{!"_ZTSN4Simd4Base26SynetInnerProduct16bGemmNN8AlgParamE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !7, i64 112}
!14 = !{!13, !7, i64 64}
!15 = !{!16, !20, i64 288}
!16 = !{!"_ZTSN4Simd4Base26SynetInnerProduct16bGemmNNE", !17, i64 0, !13, i64 160, !20, i64 280, !20, i64 288, !20, i64 296}
!17 = !{!"_ZTSN4Simd20SynetInnerProduct16bE", !18, i64 0, !6, i64 8, !19, i64 56, !21, i64 72, !22, i64 88, !23, i64 104, !7, i64 136, !7, i64 144, !7, i64 152}
!18 = !{!"_ZTSN4Simd9DeletableE"}
!19 = !{!"_ZTSN4Simd5ArrayIhEE", !20, i64 0, !7, i64 8}
!20 = !{!"any pointer", !8, i64 0}
!21 = !{!"_ZTSN4Simd5ArrayItEE", !20, i64 0, !7, i64 8}
!22 = !{!"_ZTSN4Simd5ArrayIfEE", !20, i64 0, !7, i64 8}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !24, i64 0, !7, i64 8, !8, i64 16}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !20, i64 0}
!25 = !{!6, !7, i64 8}
!26 = !{!6, !7, i64 16}
!27 = !{!17, !20, i64 72}
!28 = !{!6, !11, i64 44}
!29 = !{!17, !20, i64 88}


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