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

; 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.cmsis_nn_dims = type { i32, i32, i32, i32 }
%struct.cmsis_nn_conv_params = type { i32, i32, %struct.cmsis_nn_tile, %struct.cmsis_nn_tile, %struct.cmsis_nn_tile, %struct.cmsis_nn_activation }
%struct.cmsis_nn_tile = type { i32, i32 }
%struct.cmsis_nn_activation = type { i32, i32 }
%struct.cmsis_nn_per_channel_quant_params = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_convolve_1x1_s8_fast(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10) #0 {
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca i32, align 4
  store ptr %0, ptr %13, align 8, !tbaa !5
  store ptr %1, ptr %14, align 8, !tbaa !5
  store ptr %2, ptr %15, align 8, !tbaa !5
  store ptr %3, ptr %16, align 8, !tbaa !5
  store ptr %4, ptr %17, align 8, !tbaa !5
  store ptr %5, ptr %18, align 8, !tbaa !5
  store ptr %6, ptr %19, align 8, !tbaa !5
  store ptr %7, ptr %20, align 8, !tbaa !5
  store ptr %8, ptr %21, align 8, !tbaa !5
  store ptr %9, ptr %22, align 8, !tbaa !5
  store ptr %10, ptr %23, align 8, !tbaa !5
  %27 = load ptr, ptr %16, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.cmsis_nn_dims, ptr %27, i32 0, i32 3
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = srem i32 %29, 4
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %56, label %32

32:                                               ; preds = %11
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %33, i32 0, i32 3
  %35 = getelementptr inbounds %struct.cmsis_nn_tile, ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 4, !tbaa !12
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %56, label %38

38:                                               ; preds = %32
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %39, i32 0, i32 3
  %41 = getelementptr inbounds %struct.cmsis_nn_tile, ptr %40, i32 0, i32 1
  %42 = load i32, ptr %41, align 4, !tbaa !15
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %56, label %44

44:                                               ; preds = %38
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %45, i32 0, i32 2
  %47 = getelementptr inbounds %struct.cmsis_nn_tile, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 4, !tbaa !16
  %49 = icmp ne i32 %48, 1
  br i1 %49, label %56, label %50

50:                                               ; preds = %44
  %51 = load ptr, ptr %14, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %51, i32 0, i32 2
  %53 = getelementptr inbounds %struct.cmsis_nn_tile, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %53, align 4, !tbaa !17
  %55 = icmp ne i32 %54, 1
  br i1 %55, label %56, label %57

56:                                               ; preds = %50, %44, %38, %32, %11
  store i32 -3, ptr %12, align 4
  br label %106

57:                                               ; preds = %50
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = load ptr, ptr %18, align 8, !tbaa !5
  %60 = load ptr, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #3
  %61 = load ptr, ptr %16, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.cmsis_nn_dims, ptr %61, i32 0, i32 2
  %63 = load i32, ptr %62, align 4, !tbaa !18
  %64 = load ptr, ptr %16, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.cmsis_nn_dims, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !19
  %67 = mul nsw i32 %63, %66
  %68 = load ptr, ptr %16, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.cmsis_nn_dims, ptr %68, i32 0, i32 0
  %70 = load i32, ptr %69, align 4, !tbaa !20
  %71 = mul nsw i32 %67, %70
  store i32 %71, ptr %24, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #3
  %72 = load ptr, ptr %22, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.cmsis_nn_dims, ptr %72, i32 0, i32 3
  %74 = load i32, ptr %73, align 4, !tbaa !9
  store i32 %74, ptr %25, align 4, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #3
  %75 = load ptr, ptr %16, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.cmsis_nn_dims, ptr %75, i32 0, i32 3
  %77 = load i32, ptr %76, align 4, !tbaa !9
  store i32 %77, ptr %26, align 4, !tbaa !21
  %78 = load ptr, ptr %17, align 8, !tbaa !5
  %79 = load ptr, ptr %19, align 8, !tbaa !5
  %80 = load ptr, ptr %21, align 8, !tbaa !5
  %81 = load ptr, ptr %23, align 8, !tbaa !5
  %82 = load ptr, ptr %15, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.cmsis_nn_per_channel_quant_params, ptr %82, i32 0, i32 0
  %84 = load ptr, ptr %83, align 8, !tbaa !22
  %85 = load ptr, ptr %15, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.cmsis_nn_per_channel_quant_params, ptr %85, i32 0, i32 1
  %87 = load ptr, ptr %86, align 8, !tbaa !24
  %88 = load i32, ptr %24, align 4, !tbaa !21
  %89 = load i32, ptr %25, align 4, !tbaa !21
  %90 = load i32, ptr %26, align 4, !tbaa !21
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %91, i32 0, i32 0
  %93 = load i32, ptr %92, align 4, !tbaa !25
  %94 = load ptr, ptr %14, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !26
  %97 = load ptr, ptr %14, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %97, i32 0, i32 5
  %99 = getelementptr inbounds %struct.cmsis_nn_activation, ptr %98, i32 0, i32 0
  %100 = load i32, ptr %99, align 4, !tbaa !27
  %101 = load ptr, ptr %14, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.cmsis_nn_conv_params, ptr %101, i32 0, i32 5
  %103 = getelementptr inbounds %struct.cmsis_nn_activation, ptr %102, i32 0, i32 1
  %104 = load i32, ptr %103, align 4, !tbaa !28
  %105 = call i32 @arm_nn_mat_mult_nt_t_s8(ptr noundef %78, ptr noundef %79, ptr noundef %80, ptr noundef %81, ptr noundef %84, ptr noundef %87, i32 noundef %88, i32 noundef %89, i32 noundef %90, i32 noundef %93, i32 noundef %96, i32 noundef %100, i32 noundef %104)
  store i32 0, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #3
  br label %106

106:                                              ; preds = %57, %56
  %107 = load i32, ptr %12, align 4
  ret i32 %107
}

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

declare i32 @arm_nn_mat_mult_nt_t_s8(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #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 = { "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 = { 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, !11, i64 12}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 16}
!13 = !{!"", !11, i64 0, !11, i64 4, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!14 = !{!"", !11, i64 0, !11, i64 4}
!15 = !{!13, !11, i64 20}
!16 = !{!13, !11, i64 8}
!17 = !{!13, !11, i64 12}
!18 = !{!10, !11, i64 8}
!19 = !{!10, !11, i64 4}
!20 = !{!10, !11, i64 0}
!21 = !{!11, !11, i64 0}
!22 = !{!23, !6, i64 0}
!23 = !{!"", !6, i64 0, !6, i64 8}
!24 = !{!23, !6, i64 8}
!25 = !{!13, !11, i64 0}
!26 = !{!13, !11, i64 4}
!27 = !{!13, !11, i64 32}
!28 = !{!13, !11, i64 36}


; 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: nounwind uwtable
define dso_local range(i32 -3, 1) i32 @arm_convolve_1x1_s8_fast(ptr nocapture noundef readnone %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr noundef %4, ptr nocapture noundef readnone %5, ptr noundef %6, ptr nocapture noundef readnone %7, ptr noundef %8, ptr nocapture noundef readonly %9, ptr noundef %10) local_unnamed_addr #0 {
  %12 = getelementptr inbounds i8, ptr %3, i64 12
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = and i32 %13, 3
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %15, label %48

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %1, i64 16
  %17 = load i32, ptr %16, align 4, !tbaa !10
  %.not26 = icmp eq i32 %17, 0
  br i1 %.not26, label %18, label %48

18:                                               ; preds = %15
  %19 = getelementptr inbounds i8, ptr %1, i64 20
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %.not27 = icmp eq i32 %20, 0
  br i1 %.not27, label %21, label %48

21:                                               ; preds = %18
  %22 = getelementptr inbounds i8, ptr %1, i64 8
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %.not28 = icmp eq i32 %23, 1
  br i1 %.not28, label %24, label %48

24:                                               ; preds = %21
  %25 = getelementptr inbounds i8, ptr %1, i64 12
  %26 = load i32, ptr %25, align 4, !tbaa !15
  %.not29 = icmp eq i32 %26, 1
  br i1 %.not29, label %27, label %48

27:                                               ; preds = %24
  %28 = getelementptr inbounds i8, ptr %3, i64 8
  %29 = load i32, ptr %28, align 4, !tbaa !16
  %30 = getelementptr inbounds i8, ptr %3, i64 4
  %31 = load i32, ptr %30, align 4, !tbaa !17
  %32 = mul nsw i32 %31, %29
  %33 = load i32, ptr %3, align 4, !tbaa !18
  %34 = mul nsw i32 %32, %33
  %35 = getelementptr inbounds i8, ptr %9, i64 12
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load ptr, ptr %2, align 8, !tbaa !19
  %38 = getelementptr inbounds i8, ptr %2, i64 8
  %39 = load ptr, ptr %38, align 8, !tbaa !22
  %40 = load i32, ptr %1, align 4, !tbaa !23
  %41 = getelementptr inbounds i8, ptr %1, i64 4
  %42 = load i32, ptr %41, align 4, !tbaa !24
  %43 = getelementptr inbounds i8, ptr %1, i64 32
  %44 = load i32, ptr %43, align 4, !tbaa !25
  %45 = getelementptr inbounds i8, ptr %1, i64 36
  %46 = load i32, ptr %45, align 4, !tbaa !26
  %47 = tail call i32 @arm_nn_mat_mult_nt_t_s8(ptr noundef %4, ptr noundef %6, ptr noundef %8, ptr noundef %10, ptr noundef %37, ptr noundef %39, i32 noundef %34, i32 noundef %36, i32 noundef %13, i32 noundef %40, i32 noundef %42, i32 noundef %44, i32 noundef %46) #2
  br label %48

48:                                               ; preds = %11, %15, %18, %21, %24, %27
  %.0 = phi i32 [ 0, %27 ], [ -3, %24 ], [ -3, %21 ], [ -3, %18 ], [ -3, %15 ], [ -3, %11 ]
  ret i32 %.0
}

declare i32 @arm_nn_mat_mult_nt_t_s8(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 = { "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 = { 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, !7, i64 12}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 16}
!11 = !{!"", !7, i64 0, !7, i64 4, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32}
!12 = !{!"", !7, i64 0, !7, i64 4}
!13 = !{!11, !7, i64 20}
!14 = !{!11, !7, i64 8}
!15 = !{!11, !7, i64 12}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 4}
!18 = !{!6, !7, i64 0}
!19 = !{!20, !21, i64 0}
!20 = !{!"", !21, i64 0, !21, i64 8}
!21 = !{!"any pointer", !8, i64 0}
!22 = !{!20, !21, i64 8}
!23 = !{!11, !7, i64 0}
!24 = !{!11, !7, i64 4}
!25 = !{!11, !7, i64 32}
!26 = !{!11, !7, i64 36}


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