; LLVM IR from Seeed-Studio/Seeed_Arduino_edgeimpulse :: src/edge-impulse-sdk/CMSIS/NN/Source/ConcatenationFunctions (z)

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

; Function Attrs: nounwind uwtable
define dso_local void @arm_concatenation_s8_z(ptr noundef %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i16 noundef zeroext %3, i16 noundef zeroext %4, ptr noundef %5, i16 noundef zeroext %6, i32 noundef %7) #0 {
  %9 = alloca ptr, align 8
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca i16, align 2
  %13 = alloca i16, align 2
  %14 = alloca ptr, align 8
  %15 = alloca i16, align 2
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store i16 %1, ptr %10, align 2, !tbaa !9
  store i16 %2, ptr %11, align 2, !tbaa !9
  store i16 %3, ptr %12, align 2, !tbaa !9
  store i16 %4, ptr %13, align 2, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !5
  store i16 %6, ptr %15, align 2, !tbaa !9
  store i32 %7, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %20 = load i16, ptr %10, align 2, !tbaa !9
  %21 = zext i16 %20 to i32
  %22 = load i16, ptr %11, align 2, !tbaa !9
  %23 = zext i16 %22 to i32
  %24 = mul nsw i32 %21, %23
  %25 = load i16, ptr %12, align 2, !tbaa !9
  %26 = zext i16 %25 to i32
  %27 = mul nsw i32 %24, %26
  store i32 %27, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %28 = load i16, ptr %10, align 2, !tbaa !9
  %29 = zext i16 %28 to i32
  %30 = load i16, ptr %11, align 2, !tbaa !9
  %31 = zext i16 %30 to i32
  %32 = mul nsw i32 %29, %31
  %33 = load i16, ptr %15, align 2, !tbaa !9
  %34 = zext i16 %33 to i32
  %35 = mul nsw i32 %32, %34
  store i32 %35, ptr %18, align 4, !tbaa !11
  %36 = load i32, ptr %16, align 4, !tbaa !11
  %37 = load i16, ptr %10, align 2, !tbaa !9
  %38 = zext i16 %37 to i32
  %39 = load i16, ptr %11, align 2, !tbaa !9
  %40 = zext i16 %39 to i32
  %41 = mul nsw i32 %38, %40
  %42 = mul i32 %36, %41
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = zext i32 %42 to i64
  %45 = getelementptr inbounds i8, ptr %43, i64 %44
  store ptr %45, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !11
  br label %46

46:                                               ; preds = %64, %8
  %47 = load i32, ptr %19, align 4, !tbaa !11
  %48 = load i16, ptr %13, align 2, !tbaa !9
  %49 = zext i16 %48 to i32
  %50 = icmp ult i32 %47, %49
  br i1 %50, label %51, label %67

51:                                               ; preds = %46
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = load i32, ptr %17, align 4, !tbaa !11
  %55 = zext i32 %54 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %52, ptr align 1 %53, i64 %55, i1 false)
  %56 = load i32, ptr %17, align 4, !tbaa !11
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = zext i32 %56 to i64
  %59 = getelementptr inbounds i8, ptr %57, i64 %58
  store ptr %59, ptr %9, align 8, !tbaa !5
  %60 = load i32, ptr %18, align 4, !tbaa !11
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = zext i32 %60 to i64
  %63 = getelementptr inbounds i8, ptr %61, i64 %62
  store ptr %63, ptr %14, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %51
  %65 = load i32, ptr %19, align 4, !tbaa !11
  %66 = add i32 %65, 1
  store i32 %66, ptr %19, align 4, !tbaa !11
  br label %46, !llvm.loop !13

67:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  ret void
}

; 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 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @arm_concatenation_s8_z(ptr nocapture noundef readonly %0, i16 noundef zeroext %1, i16 noundef zeroext %2, i16 noundef zeroext %3, i16 noundef zeroext %4, ptr nocapture noundef writeonly %5, i16 noundef zeroext %6, i32 noundef %7) local_unnamed_addr #0 {
  %9 = zext i16 %4 to i32
  %.not = icmp eq i16 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %10 = zext i16 %2 to i32
  %11 = zext i16 %1 to i32
  %12 = mul nuw nsw i32 %10, %11
  %13 = mul i32 %12, %7
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds i8, ptr %5, i64 %14
  %16 = zext i16 %6 to i32
  %17 = mul nuw nsw i32 %12, %16
  %18 = zext i16 %3 to i32
  %19 = mul nuw nsw i32 %12, %18
  %20 = zext nneg i32 %19 to i64
  %21 = zext nneg i32 %17 to i64
  %xtraiter = and i32 %9, 3
  %22 = icmp ult i16 %4, 4
  br i1 %22, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i32 %9, 65532
  br label %23

23:                                               ; preds = %23, %.lr.ph.new
  %.01922 = phi ptr [ %0, %.lr.ph.new ], [ %30, %23 ]
  %.02021 = phi ptr [ %15, %.lr.ph.new ], [ %31, %23 ]
  %niter = phi i32 [ 0, %.lr.ph.new ], [ %niter.next.3, %23 ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.02021, ptr align 1 %.01922, i64 %20, i1 false)
  %24 = getelementptr inbounds i8, ptr %.01922, i64 %20
  %25 = getelementptr inbounds i8, ptr %.02021, i64 %21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %25, ptr align 1 %24, i64 %20, i1 false)
  %26 = getelementptr inbounds i8, ptr %24, i64 %20
  %27 = getelementptr inbounds i8, ptr %25, i64 %21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %27, ptr align 1 %26, i64 %20, i1 false)
  %28 = getelementptr inbounds i8, ptr %26, i64 %20
  %29 = getelementptr inbounds i8, ptr %27, i64 %21
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %29, ptr align 1 %28, i64 %20, i1 false)
  %30 = getelementptr inbounds i8, ptr %28, i64 %20
  %31 = getelementptr inbounds i8, ptr %29, i64 %21
  %niter.next.3 = add i32 %niter, 4
  %niter.ncmp.3 = icmp eq i32 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %23, !llvm.loop !5

._crit_edge.loopexit.unr-lcssa:                   ; preds = %23, %.lr.ph
  %.01922.unr = phi ptr [ %0, %.lr.ph ], [ %30, %23 ]
  %.02021.unr = phi ptr [ %15, %.lr.ph ], [ %31, %23 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %.01922.epil = phi ptr [ %32, %.epil.preheader ], [ %.01922.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.02021.epil = phi ptr [ %33, %.epil.preheader ], [ %.02021.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i32 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.02021.epil, ptr align 1 %.01922.epil, i64 %20, i1 false)
  %32 = getelementptr inbounds i8, ptr %.01922.epil, i64 %20
  %33 = getelementptr inbounds i8, ptr %.02021.epil, i64 %21
  %epil.iter.next = add i32 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i32 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !7

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %8
  ret void
}

; 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

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !8}
!8 = !{!"llvm.loop.unroll.disable"}


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