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

; 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_y(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
  %20 = 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
  %21 = load i16, ptr %12, align 2, !tbaa !9
  %22 = zext i16 %21 to i32
  %23 = load i16, ptr %13, align 2, !tbaa !9
  %24 = zext i16 %23 to i32
  %25 = mul nsw i32 %22, %24
  store i32 %25, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %26 = load i16, ptr %10, align 2, !tbaa !9
  %27 = zext i16 %26 to i32
  %28 = load i16, ptr %11, align 2, !tbaa !9
  %29 = zext i16 %28 to i32
  %30 = mul nsw i32 %27, %29
  store i32 %30, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %31 = load i16, ptr %10, align 2, !tbaa !9
  %32 = zext i16 %31 to i32
  %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 %19, 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 = mul i32 %36, %38
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = zext i32 %39 to i64
  %42 = getelementptr inbounds i8, ptr %40, i64 %41
  store ptr %42, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %43

43:                                               ; preds = %60, %8
  %44 = load i32, ptr %20, align 4, !tbaa !11
  %45 = load i32, ptr %17, align 4, !tbaa !11
  %46 = icmp ult i32 %44, %45
  br i1 %46, label %47, label %63

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

60:                                               ; preds = %47
  %61 = load i32, ptr %20, align 4, !tbaa !11
  %62 = add i32 %61, 1
  store i32 %62, ptr %20, align 4, !tbaa !11
  br label %43, !llvm.loop !13

63:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  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_y(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 %3 to i32
  %10 = zext i16 %4 to i32
  %11 = mul nuw nsw i32 %10, %9
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %12 = zext i16 %1 to i32
  %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 %16, %12
  %18 = zext i16 %2 to i32
  %19 = mul nuw nsw i32 %18, %12
  %20 = zext nneg i32 %19 to i64
  %21 = zext nneg i32 %17 to i64
  %xtraiter = and i32 %11, 3
  %22 = icmp ult i32 %11, 4
  br i1 %22, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

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

23:                                               ; preds = %23, %.lr.ph.new
  %.01821 = phi ptr [ %0, %.lr.ph.new ], [ %30, %23 ]
  %.01920 = 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 %.01920, ptr align 1 %.01821, i64 %20, i1 false)
  %24 = getelementptr inbounds i8, ptr %.01821, i64 %20
  %25 = getelementptr inbounds i8, ptr %.01920, 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
  %.01821.unr = phi ptr [ %0, %.lr.ph ], [ %30, %23 ]
  %.01920.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
  %.01821.epil = phi ptr [ %32, %.epil.preheader ], [ %.01821.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01920.epil = phi ptr [ %33, %.epil.preheader ], [ %.01920.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 %.01920.epil, ptr align 1 %.01821.epil, i64 %20, i1 false)
  %32 = getelementptr inbounds i8, ptr %.01821.epil, i64 %20
  %33 = getelementptr inbounds i8, ptr %.01920.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