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

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

31:                                               ; preds = %50, %8
  %32 = load i32, ptr %18, align 4, !tbaa !11
  %33 = load i32, ptr %17, align 4, !tbaa !11
  %34 = icmp ult i32 %32, %33
  br i1 %34, label %35, label %53

35:                                               ; preds = %31
  %36 = load ptr, ptr %14, align 8, !tbaa !5
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = load i16, ptr %10, align 2, !tbaa !9
  %39 = zext i16 %38 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %36, ptr align 1 %37, i64 %39, i1 false)
  %40 = load i16, ptr %10, align 2, !tbaa !9
  %41 = zext i16 %40 to i32
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = sext i32 %41 to i64
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  store ptr %44, ptr %9, align 8, !tbaa !5
  %45 = load i16, ptr %15, align 2, !tbaa !9
  %46 = zext i16 %45 to i32
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = sext i32 %46 to i64
  %49 = getelementptr inbounds i8, ptr %47, i64 %48
  store ptr %49, ptr %14, align 8, !tbaa !5
  br label %50

50:                                               ; preds = %35
  %51 = load i32, ptr %18, align 4, !tbaa !11
  %52 = add i32 %51, 1
  store i32 %52, ptr %18, align 4, !tbaa !11
  br label %31, !llvm.loop !13

53:                                               ; preds = %31
  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_x(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 %2 to i32
  %10 = zext i16 %3 to i32
  %11 = mul nuw nsw i32 %10, %9
  %12 = zext i16 %4 to i32
  %13 = mul nuw nsw i32 %11, %12
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %14 = zext i32 %7 to i64
  %15 = getelementptr inbounds i8, ptr %5, i64 %14
  %16 = zext i16 %1 to i64
  %17 = zext i16 %6 to i64
  %xtraiter = and i32 %13, 3
  %18 = icmp ult i32 %13, 4
  br i1 %18, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

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

19:                                               ; preds = %19, %.lr.ph.new
  %.01417 = phi ptr [ %0, %.lr.ph.new ], [ %26, %19 ]
  %.01516 = phi ptr [ %15, %.lr.ph.new ], [ %27, %19 ]
  %niter = phi i32 [ 0, %.lr.ph.new ], [ %niter.next.3, %19 ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.01516, ptr align 1 %.01417, i64 %16, i1 false)
  %20 = getelementptr inbounds i8, ptr %.01417, i64 %16
  %21 = getelementptr inbounds i8, ptr %.01516, i64 %17
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %21, ptr align 1 %20, i64 %16, i1 false)
  %22 = getelementptr inbounds i8, ptr %20, i64 %16
  %23 = getelementptr inbounds i8, ptr %21, i64 %17
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %23, ptr align 1 %22, i64 %16, i1 false)
  %24 = getelementptr inbounds i8, ptr %22, i64 %16
  %25 = getelementptr inbounds i8, ptr %23, i64 %17
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %25, ptr align 1 %24, i64 %16, i1 false)
  %26 = getelementptr inbounds i8, ptr %24, i64 %16
  %27 = getelementptr inbounds i8, ptr %25, i64 %17
  %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 %19, !llvm.loop !5

._crit_edge.loopexit.unr-lcssa:                   ; preds = %19, %.lr.ph
  %.01417.unr = phi ptr [ %0, %.lr.ph ], [ %26, %19 ]
  %.01516.unr = phi ptr [ %15, %.lr.ph ], [ %27, %19 ]
  %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
  %.01417.epil = phi ptr [ %28, %.epil.preheader ], [ %.01417.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.01516.epil = phi ptr [ %29, %.epil.preheader ], [ %.01516.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 %.01516.epil, ptr align 1 %.01417.epil, i64 %16, i1 false)
  %28 = getelementptr inbounds i8, ptr %.01417.epil, i64 %16
  %29 = getelementptr inbounds i8, ptr %.01516.epil, i64 %17
  %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